From e7a9f45de8f3b5a118753fae91984f3911d81d6d Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Sun, 10 Oct 2010 05:36:24 -0400 Subject: [PATCH] fs: improve DCACHE_REFERENCED usage dentry referenced bit is only set when installing the dentry back onto the LRU. However with lazy LRU, the dentry can already be on the LRU list at dput time, thus missing out on setting the referenced bit. Fix this. Signed-off-by: Nick Piggin Signed-off-by: Christoph Hellwig Signed-off-by: Al Viro --- fs/dcache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index c37a656802b0f..1a976d4efbe1c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -246,13 +246,16 @@ repeat: if (dentry->d_op->d_delete(dentry)) goto unhash_it; } + /* Unreachable? Get rid of it */ if (d_unhashed(dentry)) goto kill_it; - if (list_empty(&dentry->d_lru)) { - dentry->d_flags |= DCACHE_REFERENCED; + + /* Otherwise leave it cached and ensure it's on the LRU */ + dentry->d_flags |= DCACHE_REFERENCED; + if (list_empty(&dentry->d_lru)) dentry_lru_add(dentry); - } + spin_unlock(&dentry->d_lock); spin_unlock(&dcache_lock); return; -- 2.39.5