Skip to content

Commit

Permalink
fs: dcache: Use READ_ONCE when accessing i_dir_seq
Browse files Browse the repository at this point in the history
[ Upstream commit 8cc07c8 ]

i_dir_seq is subject to concurrent modification by a cmpxchg or
store-release operation, so ensure that the relaxed access in
d_alloc_parallel uses READ_ONCE.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
wildea01 authored and gregkh committed May 30, 2018
1 parent 3623c1f commit 2565b27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent,
}

hlist_bl_lock(b);
if (unlikely(parent->d_inode->i_dir_seq != seq)) {
if (unlikely(READ_ONCE(parent->d_inode->i_dir_seq) != seq)) {
hlist_bl_unlock(b);
rcu_read_unlock();
goto retry;
Expand Down

0 comments on commit 2565b27

Please sign in to comment.