From 8fb85072acc97528fe7725c38290d84ac873415e Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 10 Jan 2012 18:22:25 +0100 Subject: [PATCH] --- yaml --- r: 283218 b: refs/heads/master c: eaf5f9073533cde21c7121c136f1c3f072d9cf59 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/dcache.c | 15 +++++++++++---- trunk/include/linux/dcache.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index b117f14c9eda..f62e884ba2fe 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f4947fbce208990266920d51837e4e7ba9779db1 +refs/heads/master: eaf5f9073533cde21c7121c136f1c3f072d9cf59 diff --git a/trunk/fs/dcache.c b/trunk/fs/dcache.c index 3c6d3113a255..616fedff011a 100644 --- a/trunk/fs/dcache.c +++ b/trunk/fs/dcache.c @@ -243,6 +243,7 @@ static void dentry_lru_add(struct dentry *dentry) static void __dentry_lru_del(struct dentry *dentry) { list_del_init(&dentry->d_lru); + dentry->d_flags &= ~DCACHE_SHRINK_LIST; dentry->d_sb->s_nr_dentry_unused--; dentry_stat.nr_unused--; } @@ -806,6 +807,7 @@ void prune_dcache_sb(struct super_block *sb, int count) spin_unlock(&dentry->d_lock); } else { list_move_tail(&dentry->d_lru, &tmp); + dentry->d_flags |= DCACHE_SHRINK_LIST; spin_unlock(&dentry->d_lock); if (!--count) break; @@ -1097,14 +1099,19 @@ static int select_parent(struct dentry *parent, struct list_head *dispose) /* * move only zero ref count dentries to the dispose list. + * + * Those which are presently on the shrink list, being processed + * by shrink_dentry_list(), shouldn't be moved. Otherwise the + * loop in shrink_dcache_parent() might not make any progress + * and loop forever. */ - if (!dentry->d_count) { + if (dentry->d_count) { + dentry_lru_del(dentry); + } else if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) { dentry_lru_move_list(dentry, dispose); + dentry->d_flags |= DCACHE_SHRINK_LIST; found++; - } else { - dentry_lru_del(dentry); } - /* * We can return to the caller if we have found some (this * ensures forward progress). We'll be coming back to find diff --git a/trunk/include/linux/dcache.h b/trunk/include/linux/dcache.h index a47bda5f76db..31f73220e7d7 100644 --- a/trunk/include/linux/dcache.h +++ b/trunk/include/linux/dcache.h @@ -203,6 +203,7 @@ struct dentry_operations { #define DCACHE_CANT_MOUNT 0x0100 #define DCACHE_GENOCIDE 0x0200 +#define DCACHE_SHRINK_LIST 0x0400 #define DCACHE_NFSFS_RENAMED 0x1000 /* this dentry has been "silly renamed" and has to be deleted on the last