Skip to content

Commit

Permalink
fsnotify: Clarify connector assignment in fsnotify_add_mark_list()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jankara committed May 1, 2019
1 parent b1da6a5 commit 11a6f8e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/notify/mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ static int fsnotify_add_mark_list(struct fsnotify_mark *mark,
/* 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);
Expand Down

0 comments on commit 11a6f8e

Please sign in to comment.