Skip to content

Commit f05441c

Browse files
author
Al Viro
committed
fold the call of retain_dentry() into fast_dput()
Calls of retain_dentry() happen immediately after getting false from fast_dput() and getting true from retain_dentry() is treated the same way as non-zero refcount would be treated by fast_dput() - unlock dentry and bugger off. Doing that in fast_dput() itself is simpler. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 2f42f1e commit f05441c

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fs/dcache.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static struct dentry *dentry_kill(struct dentry *dentry)
757757
* Try to do a lockless dput(), and return whether that was successful.
758758
*
759759
* If unsuccessful, we return false, having already taken the dentry lock.
760+
* In that case refcount is guaranteed to be zero and we have already
761+
* decided that it's not worth keeping around.
760762
*
761763
* The caller needs to hold the RCU read lock, so that the dentry is
762764
* guaranteed to stay around even if the refcount goes down to zero!
@@ -842,7 +844,7 @@ static inline bool fast_dput(struct dentry *dentry)
842844
* don't need to do anything else.
843845
*/
844846
locked:
845-
if (dentry->d_lockref.count) {
847+
if (dentry->d_lockref.count || retain_dentry(dentry)) {
846848
spin_unlock(&dentry->d_lock);
847849
return true;
848850
}
@@ -889,12 +891,6 @@ void dput(struct dentry *dentry)
889891

890892
/* Slow case: now with the dentry lock held */
891893
rcu_read_unlock();
892-
893-
if (likely(retain_dentry(dentry))) {
894-
spin_unlock(&dentry->d_lock);
895-
return;
896-
}
897-
898894
dentry->d_lockref.count = 1;
899895
dentry = dentry_kill(dentry);
900896
}
@@ -920,8 +916,7 @@ void dput_to_list(struct dentry *dentry, struct list_head *list)
920916
return;
921917
}
922918
rcu_read_unlock();
923-
if (!retain_dentry(dentry))
924-
to_shrink_list(dentry, list);
919+
to_shrink_list(dentry, list);
925920
spin_unlock(&dentry->d_lock);
926921
}
927922

0 commit comments

Comments
 (0)