Commit de8e3749 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] dentry_stat accounting fix

From: Maneesh Soni <maneesh@in.ibm.com>

This patch the corrects the dentry_stat.nr_unused calculation.

In select_parent() and shrink_dcache_anon() we were not doing any adjustments
to the nr_unused count after manipulating the dentry_unused list.  Now the
nr_unused count is decremented if the dentry is on dentry_unused list and is
removed from there.

Further in the same routines, we have to adjust the nr_unused count again if
the dentry is moved to the end of d_lru list for pruning.
parent 70d67000
......@@ -538,13 +538,18 @@ static int select_parent(struct dentry * parent)
struct list_head *tmp = next;
struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
next = tmp->next;
list_del_init(&dentry->d_lru);
/* don't add non zero d_count dentries
* back to d_lru list
if (!list_empty(&dentry->d_lru)) {
dentry_stat.nr_unused--;
list_del_init(&dentry->d_lru);
}
/*
* move only zero ref count dentries to the end
* of the unused list for prune_dcache
*/
if (!atomic_read(&dentry->d_count)) {
list_add(&dentry->d_lru, dentry_unused.prev);
dentry_stat.nr_unused++;
found++;
}
/*
......@@ -609,13 +614,18 @@ void shrink_dcache_anon(struct hlist_head *head)
spin_lock(&dcache_lock);
hlist_for_each(lp, head) {
struct dentry *this = hlist_entry(lp, struct dentry, d_hash);
if (!list_empty(&this->d_lru)) {
dentry_stat.nr_unused--;
list_del(&this->d_lru);
}
/* don't add non zero d_count dentries
* back to d_lru list
/*
* move only zero ref count dentries to the end
* of the unused list for prune_dcache
*/
if (!atomic_read(&this->d_count)) {
list_add_tail(&this->d_lru, &dentry_unused);
dentry_stat.nr_unused++;
found++;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment