fsnotify: Clarify connector assignment in fsnotify_add_mark_list()
authorJan Kara <jack@suse.cz>
Wed, 1 May 2019 16:05:11 +0000 (18:05 +0200)
committerJan Kara <jack@suse.cz>
Wed, 1 May 2019 16:05:11 +0000 (18:05 +0200)
Add a comment explaining why WRITE_ONCE() is enough when setting
mark->connector which can get dereferenced by RCU protected readers.

Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/mark.c

index 22acb0a..b251105 100644 (file)
@@ -619,6 +619,11 @@ restart:
        /* mark should be the last entry.  last is the current last entry */
        hlist_add_behind_rcu(&mark->obj_list, &last->obj_list);
 added:
+       /*
+        * Since connector is attached to object using cmpxchg() we are
+        * guaranteed that connector initialization is fully visible by anyone
+        * seeing mark->connector set.
+        */
        WRITE_ONCE(mark->connector, conn);
 out_err:
        spin_unlock(&conn->lock);