Skip to content

Commit 15220fb

Browse files
author
Al Viro
committed
fast_dput(): having ->d_delete() is not reason to delay refcount decrement
->d_delete() is a way for filesystem to tell that dentry is not worth keeping cached. It is not guaranteed to be called every time a dentry has refcount drop down to zero; it is not guaranteed to be called before dentry gets evicted. In other words, it is not suitable for any kind of keeping track of dentry state. None of the in-tree filesystems attempt to use it that way, fortunately. So the contortions done by fast_dput() (as well as dentry_kill()) are not warranted. fast_dput() certainly should treat having ->d_delete() instance as "can't assume we'll be keeping it", but that's not different from the way we treat e.g. DCACHE_DONTCACHE (which is rather similar to making ->d_delete() returns true when called). Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent cd9f84f commit 15220fb

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

fs/dcache.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -768,15 +768,7 @@ static inline bool fast_dput(struct dentry *dentry)
768768
unsigned int d_flags;
769769

770770
/*
771-
* If we have a d_op->d_delete() operation, we sould not
772-
* let the dentry count go to zero, so use "put_or_lock".
773-
*/
774-
if (unlikely(dentry->d_flags & DCACHE_OP_DELETE))
775-
return lockref_put_or_lock(&dentry->d_lockref);
776-
777-
/*
778-
* .. otherwise, we can try to just decrement the
779-
* lockref optimistically.
771+
* try to decrement the lockref optimistically.
780772
*/
781773
ret = lockref_put_return(&dentry->d_lockref);
782774

@@ -830,7 +822,7 @@ static inline bool fast_dput(struct dentry *dentry)
830822
*/
831823
smp_rmb();
832824
d_flags = READ_ONCE(dentry->d_flags);
833-
d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST |
825+
d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST | DCACHE_OP_DELETE |
834826
DCACHE_DISCONNECTED | DCACHE_DONTCACHE;
835827

836828
/* Nothing to do? Dropping the reference was all we needed? */

0 commit comments

Comments
 (0)