@@ -145,6 +145,7 @@ struct dentry_stat_t dentry_stat = {
long nfree; /* Negative dentry free pool */
struct super_block *prune_sb; /* Super_block for pruning */
int neg_count, prune_count; /* Pruning counts */
+ atomic_long_t nr_neg_killed; /* # of negative entries killed */
} ndblk ____cacheline_aligned_in_smp;
static void clear_prune_sb_for_umount(struct super_block *sb);
@@ -204,6 +205,7 @@ int proc_nr_dentry(struct ctl_table *table, int write, void __user *buffer,
dentry_stat.nr_dentry = get_nr_dentry();
dentry_stat.nr_unused = get_nr_dentry_unused();
dentry_stat.nr_negative = get_nr_dentry_neg();
+ dentry_stat.nr_killed = atomic_long_read(&ndblk.nr_neg_killed);
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
}
#endif
@@ -802,6 +804,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
spin_unlock(&parent->d_lock);
goto failed;
}
+ atomic_long_inc(&ndblk.nr_neg_killed);
} else if (unlikely(!spin_trylock(&parent->d_lock))) {
if (inode)
@@ -3932,6 +3935,7 @@ static void __init neg_dentry_init(void)
raw_spin_lock_init(&ndblk.nfree_lock);
spin_lock_init(&ndblk.prune_lock);
+ atomic_long_set(&ndblk.nr_neg_killed, 0);
/* 20% in global pool & 80% in percpu free */
ndblk.nfree = neg_dentry_nfree_init
@@ -66,7 +66,7 @@ struct dentry_stat_t {
long age_limit; /* age in seconds */
long want_pages; /* pages requested by system */
long nr_negative; /* # of negative dentries */
- long dummy;
+ long nr_killed; /* # of negative dentries killed */
};
extern struct dentry_stat_t dentry_stat;
There is performance concern about killing recently created negative dentries. This should rarely happen under normal working condition. To understand the extent of how often this negative dentry killing is happening, the /proc/sys/fs/denty-state file is extended to track this number. This allows us to see if additional measures will be needed to reduce the chance of negative dentries killing. One possible measure is to increase the percentage of system memory allowed for negative dentries by adding or adjusting the "neg_dentry_pc=" parameter in the kernel boot command line. Signed-off-by: Waiman Long <longman@redhat.com> --- fs/dcache.c | 4 ++++ include/linux/dcache.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)