From: David Howells <dhowells@redhat.com>
To: Vasily Averin <vvs@sw.ru>, aviro@redhat.com
Cc: Neil Brown <neilb@suse.de>, Jan Blunck <jblunck@suse.de>,
Olaf Hering <olh@suse.de>, Balbir Singh <balbir@in.ibm.com>,
Kirill Korotaev <dev@openvz.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
devel@openvz.org, Andrew Morton <akpm@osdl.org>
Subject: Re: [Q] missing unused dentry in prune_dcache()?
Date: Thu, 26 Oct 2006 14:23:35 +0100 [thread overview]
Message-ID: <19857.1161869015@redhat.com> (raw)
In-Reply-To: <4540A0C5.60700@sw.ru>
Vasily Averin <vvs@sw.ru> wrote:
> I've noticed one more minor issue in your patch: in
> shrink_dcache_for_umount_subtree() function you decrement
> dentry_stat.nr_dentry without dcache_lock.
How about the attached patch?
David
---
VFS: Fix an error in unused dentry counting
From: David Howells <dhowells@redhat.com>
Fix an error in unused dentry counting in shrink_dcache_for_umount_subtree() in
which the count is modified without the dcache_lock held.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
fs/dcache.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index a1ff91e..eab1bf4 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -553,16 +553,17 @@ repeat:
* - see the comments on shrink_dcache_for_umount() for a description of the
* locking
*/
-static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
+static unsigned shrink_dcache_for_umount_subtree(struct dentry *dentry)
{
struct dentry *parent;
+ unsigned detached = 0;
BUG_ON(!IS_ROOT(dentry));
/* detach this root from the system */
spin_lock(&dcache_lock);
if (!list_empty(&dentry->d_lru)) {
- dentry_stat.nr_unused--;
+ detached++;
list_del_init(&dentry->d_lru);
}
__d_drop(dentry);
@@ -579,7 +580,7 @@ static void shrink_dcache_for_umount_sub
list_for_each_entry(loop, &dentry->d_subdirs,
d_u.d_child) {
if (!list_empty(&loop->d_lru)) {
- dentry_stat.nr_unused--;
+ detached++;
list_del_init(&loop->d_lru);
}
@@ -620,7 +621,7 @@ static void shrink_dcache_for_umount_sub
atomic_dec(&parent->d_count);
list_del(&dentry->d_u.d_child);
- dentry_stat.nr_dentry--; /* For d_free, below */
+ detached++; /* For d_free, below */
inode = dentry->d_inode;
if (inode) {
@@ -638,7 +639,7 @@ static void shrink_dcache_for_umount_sub
* otherwise we ascend to the parent and move to the
* next sibling if there is one */
if (!parent)
- return;
+ return detached;
dentry = parent;
@@ -663,6 +664,7 @@ static void shrink_dcache_for_umount_sub
void shrink_dcache_for_umount(struct super_block *sb)
{
struct dentry *dentry;
+ unsigned detached = 0;
if (down_read_trylock(&sb->s_umount))
BUG();
@@ -670,11 +672,17 @@ void shrink_dcache_for_umount(struct sup
dentry = sb->s_root;
sb->s_root = NULL;
atomic_dec(&dentry->d_count);
- shrink_dcache_for_umount_subtree(dentry);
+ detached = shrink_dcache_for_umount_subtree(dentry);
while (!hlist_empty(&sb->s_anon)) {
dentry = hlist_entry(sb->s_anon.first, struct dentry, d_hash);
- shrink_dcache_for_umount_subtree(dentry);
+ detached += shrink_dcache_for_umount_subtree(dentry);
+ }
+
+ if (detached) {
+ spin_lock(&dcache_lock);
+ dentry_stat.nr_unused -= detached;
+ spin_unlock(&dcache_lock);
}
}
next prev parent reply other threads:[~2006-10-26 13:25 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-25 12:30 [Q] missing unused dentry in prune_dcache()? Vasily Averin
2006-10-25 13:51 ` David Howells
2006-10-25 13:58 ` Vasily Averin
2006-10-25 14:23 ` David Howells
2006-10-26 11:36 ` Vasily Averin
2006-10-26 13:25 ` David Howells
2006-10-27 8:05 ` Vasily Averin
2006-10-27 10:42 ` David Howells
2006-10-27 11:50 ` Vasily Averin
2006-10-27 12:11 ` David Howells
2006-10-27 13:47 ` Vasily Averin
2006-10-27 14:29 ` David Howells
2006-10-27 14:39 ` Kirill Korotaev
2006-10-27 14:05 ` [PATCH 2.6.19-rc3] VFS: per-sb dentry lru list Vasily Averin
2006-10-27 18:06 ` Andrew Morton
2006-10-30 14:24 ` Vasily Averin
2006-10-30 15:08 ` Eric Dumazet
2006-10-30 15:34 ` Kirill Korotaev
2006-10-30 16:09 ` Eric Dumazet
2006-10-30 15:14 ` Kirill Korotaev
2006-10-30 4:24 ` David Chinner
2006-10-30 6:28 ` [Devel] " Kirill Korotaev
2006-10-31 4:38 ` Neil Brown
2006-10-31 10:40 ` David Howells
2006-11-01 6:32 ` Neil Brown
2006-11-01 13:32 ` Vasily Averin
2006-11-14 5:44 ` Neil Brown
2006-11-14 6:12 ` Vasily Averin
2006-10-31 13:08 ` Vasily Averin
2006-11-01 10:55 ` [Devel] " Kirill Korotaev
2006-11-14 4:51 ` Neil Brown
2006-11-14 9:29 ` David Howells
2006-10-27 13:42 ` [PATCH 2.6.19-rc3] VFS: missing unused dentry in prune_dcache() Vasily Averin
2006-10-27 14:24 ` David Howells
2006-10-26 11:49 ` [Q] missing unused dentry in prune_dcache()? Vasily Averin
2006-10-26 12:33 ` David Howells
2006-10-26 13:23 ` David Howells [this message]
2006-10-26 13:58 ` Vasily Averin
2006-10-26 14:07 ` David Howells
2006-10-27 6:32 ` Vasily Averin
2006-10-27 6:50 ` Vasily Averin
2006-10-27 9:36 ` David Howells
2006-10-31 13:24 ` [Q] missing ->d_delete() in shrink_dcache_for_umount()? Vasily Averin
2006-10-31 15:06 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19857.1161869015@redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=aviro@redhat.com \
--cc=balbir@in.ibm.com \
--cc=dev@openvz.org \
--cc=devel@openvz.org \
--cc=jblunck@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=olh@suse.de \
--cc=vvs@sw.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox