diff mbox series

[14/15] to_shrink_list(): call only if refcount is 0

Message ID 20231101062104.2104951-14-viro@zeniv.linux.org.uk (mailing list archive)
State New, archived
Headers show
Series [01/15] fast_dput(): having ->d_delete() is not reason to delay refcount decrement | expand

Commit Message

Al Viro Nov. 1, 2023, 6:21 a.m. UTC
The only thing it does if refcount is not zero is d_lru_del(); no
point, IMO, seeing that plain dput() does nothing of that sort...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/dcache.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/fs/dcache.c b/fs/dcache.c
index 19f6eb6f2bde..7c763a8c916b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -915,8 +915,7 @@  __must_hold(&dentry->d_lock)
 	if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) {
 		if (dentry->d_flags & DCACHE_LRU_LIST)
 			d_lru_del(dentry);
-		if (!dentry->d_lockref.count)
-			d_shrink_add(dentry, list);
+		d_shrink_add(dentry, list);
 	}
 }
 
@@ -1128,10 +1127,8 @@  void shrink_dentry_list(struct list_head *list)
 		rcu_read_unlock();
 		d_shrink_del(dentry);
 		parent = dentry->d_parent;
-		if (parent != dentry) {
-			--parent->d_lockref.count;
+		if (parent != dentry && !--parent->d_lockref.count)
 			to_shrink_list(parent, list);
-		}
 		__dentry_kill(dentry);
 	}
 }
@@ -1577,10 +1574,9 @@  void shrink_dcache_parent(struct dentry *parent)
 			} else {
 				rcu_read_unlock();
 				parent = data.victim->d_parent;
-				if (parent != data.victim) {
-					--parent->d_lockref.count;
+				if (parent != data.victim &&
+				    !--parent->d_lockref.count)
 					to_shrink_list(parent, &data.dispose);
-				}
 				__dentry_kill(data.victim);
 			}
 		}