Shrink rcu_read_lock() scope around lock_for_kill() into lock_for_kill() itself. Note that spin_unlock() can be transposed with rcu_read_unlock() - RCU read-side critical area remains the same and even if the structure containing the spinlock gets freed from RCU callback run immediately after spin_unlock(), we are OK - it won't run until after the last access to spinlock done by spin_unlock(). Inside lock_for_kill() the scope can be shrunk down to the area where we drop and regain ->d_lock - rcu_read_lock() scope is needed only to bridge the ->d_lock scopes together. Signed-off-by: Al Viro --- fs/dcache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index bcaf17840939..4222d89692a8 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -763,6 +763,7 @@ static bool lock_for_kill(struct dentry *dentry) if (!inode || likely(spin_trylock(&inode->i_lock))) return true; + rcu_read_lock(); do { spin_unlock(&dentry->d_lock); spin_lock(&inode->i_lock); @@ -772,6 +773,7 @@ static bool lock_for_kill(struct dentry *dentry) spin_unlock(&inode->i_lock); inode = dentry->d_inode; } while (inode); + rcu_read_unlock(); if (likely(!dentry->d_lockref.count)) return true; if (inode) @@ -781,13 +783,10 @@ static bool lock_for_kill(struct dentry *dentry) static struct dentry *dentry_kill(struct dentry *dentry) { - rcu_read_lock(); if (unlikely(!lock_for_kill(dentry))) { spin_unlock(&dentry->d_lock); - rcu_read_unlock(); return NULL; } - rcu_read_unlock(); return __dentry_kill(dentry); } -- 2.47.3