* [PATCH 2.4] fix dcache nr_dentry race
@ 2004-09-19 7:50 Leandro Santi
2004-09-19 13:07 ` Marc-Christian Petersen
2004-09-20 16:55 ` Marcelo Tosatti
0 siblings, 2 replies; 3+ messages in thread
From: Leandro Santi @ 2004-09-19 7:50 UTC (permalink / raw)
To: marcelo.tosatti; +Cc: linux-kernel
Hi Marcelo,
The dentry_stat.nr_dentry counter isn't being properly protected against
concurrent access. We've been observing a drift of about 8000 units per
day on some large MP Maildir++ mailstore nodes.
The following (trivial) patch is pretty much a backport from 2.6.
diff -ru linux-2.4.27.orig/fs/dcache.c linux-2.4.27.patched/fs/dcache.c
--- linux-2.4.27.orig/fs/dcache.c Fri Jun 13 11:51:37 2003
+++ linux-2.4.27.patched/fs/dcache.c Thu Sep 9 17:37:56 2004
@@ -55,7 +55,10 @@
/* Statistics gathering. */
struct dentry_stat_t dentry_stat = {0, 0, 45, 0,};
-/* no dcache_lock, please */
+/*
+ * no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry
+ * inside dcache_lock.
+ */
static inline void d_free(struct dentry *dentry)
{
if (dentry->d_op && dentry->d_op->d_release)
@@ -63,7 +66,6 @@
if (dname_external(dentry))
kfree(dentry->d_name.name);
kmem_cache_free(dentry_cache, dentry);
- dentry_stat.nr_dentry--;
}
/*
@@ -148,6 +150,7 @@
kill_it: {
struct dentry *parent;
list_del(&dentry->d_child);
+ dentry_stat.nr_dentry--; /* For d_free, below */
/* drops the lock, at that point nobody can reach this dentry */
dentry_iput(dentry);
parent = dentry->d_parent;
@@ -297,6 +300,7 @@
list_del_init(&dentry->d_hash);
list_del(&dentry->d_child);
+ dentry_stat.nr_dentry--; /* For d_free, below */
dentry_iput(dentry);
parent = dentry->d_parent;
d_free(dentry);
@@ -623,13 +627,15 @@
if (parent) {
dentry->d_parent = dget(parent);
dentry->d_sb = parent->d_sb;
- spin_lock(&dcache_lock);
- list_add(&dentry->d_child, &parent->d_subdirs);
- spin_unlock(&dcache_lock);
} else
INIT_LIST_HEAD(&dentry->d_child);
+ spin_lock(&dcache_lock);
+ if (parent)
+ list_add(&dentry->d_child, &parent->d_subdirs);
dentry_stat.nr_dentry++;
+ spin_unlock(&dcache_lock);
+
return dentry;
}
Bye,
Leandro.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.4] fix dcache nr_dentry race
2004-09-19 7:50 [PATCH 2.4] fix dcache nr_dentry race Leandro Santi
@ 2004-09-19 13:07 ` Marc-Christian Petersen
2004-09-20 16:55 ` Marcelo Tosatti
1 sibling, 0 replies; 3+ messages in thread
From: Marc-Christian Petersen @ 2004-09-19 13:07 UTC (permalink / raw)
To: Leandro Santi; +Cc: marcelo.tosatti, linux-kernel
On Sunday 19 September 2004 09:50, Leandro Santi wrote:
Hi Leandro,
> The dentry_stat.nr_dentry counter isn't being properly protected against
> concurrent access. We've been observing a drift of about 8000 units per
> day on some large MP Maildir++ mailstore nodes.
> The following (trivial) patch is pretty much a backport from 2.6.
Almost the same fix was posted in August 2003.
http://marc.theaimsgroup.com/?l=linux-kernel&m=106203778320540&w=2
ciao, Marc
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.4] fix dcache nr_dentry race
2004-09-19 7:50 [PATCH 2.4] fix dcache nr_dentry race Leandro Santi
2004-09-19 13:07 ` Marc-Christian Petersen
@ 2004-09-20 16:55 ` Marcelo Tosatti
1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2004-09-20 16:55 UTC (permalink / raw)
To: Leandro Santi; +Cc: linux-kernel
This one should have been applied long time ago, as Marc noted.
Thanks Leandro, committed to 2.4 BK repo.
On Sun, Sep 19, 2004 at 04:50:57AM -0300, Leandro Santi wrote:
>
> Hi Marcelo,
>
> The dentry_stat.nr_dentry counter isn't being properly protected against
> concurrent access. We've been observing a drift of about 8000 units per
> day on some large MP Maildir++ mailstore nodes.
>
> The following (trivial) patch is pretty much a backport from 2.6.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-09-20 18:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-19 7:50 [PATCH 2.4] fix dcache nr_dentry race Leandro Santi
2004-09-19 13:07 ` Marc-Christian Petersen
2004-09-20 16:55 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox