From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: [PATCH 04/10] fs: improve DCACHE_REFERENCED usage Date: Sun, 10 Oct 2010 05:36:24 -0400 Message-ID: <20101010093721.101934098@canuck.infradead.org> References: <20101010093620.416498597@canuck.infradead.org> Cc: eparis@redhat.com, linux-fsdevel@vger.kernel.org, Nick Piggin To: viro@zeniv.linux.org.uk Return-path: Received: from canuck.infradead.org ([134.117.69.58]:40672 "EHLO canuck.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754279Ab0JJJhc (ORCPT ); Sun, 10 Oct 2010 05:37:32 -0400 Content-Disposition: inline; filename=dcache-improve-DCACHE_REFERENCE Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Nick Piggin 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 Index: linux-2.6/fs/dcache.c =================================================================== --- linux-2.6.orig/fs/dcache.c 2010-10-09 10:26:11.000000000 +0200 +++ linux-2.6/fs/dcache.c 2010-10-09 10:29:04.611003707 +0200 @@ -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;