ChangeSet
2004/05/29 10:58:56-07:00 akpm@osdl.org
[PATCH] fs/dcache.c: avoid race when updating nr_unused count of unused dentries.
From: NeilBrown <neilb@cse.unsw.edu.au>
d_count == 1 is no guarantee that dentry is on the dentry_unused list, even
if it has just been incremented inside dcache_lock, as dput can decrement
at any time.
This test from Greg Banks is much safer, and is more transparently correct.
Cc: Maneesh Soni <maneesh@in.ibm.com>, Dipankar Sarma <dipankar@in.ibm.com>
From: Greg Banks <gnb@melbourne.sgi.com>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
static inline struct dentry * __dget_locked(struct dentry *dentry)
{
atomic_inc(&dentry->d_count);
- if (atomic_read(&dentry->d_count) == 1) {
+ if (!list_empty(&dentry->d_lru)) {
dentry_stat.nr_unused--;
list_del_init(&dentry->d_lru);
}