From: Mikulas Patocka Date: Tue, 1 Nov 2011 00:08:57 +0000 (-0700) Subject: vmscan: fix shrinker callback bug in fs/super.c X-Git-Tag: v3.1.3~1 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=26e15787b98f3cac67d0b9458befd24adbef7272;p=unionfs-2.6.39.y.git vmscan: fix shrinker callback bug in fs/super.c commit 09f363c7363eb10cfb4b82094bd7064e5608258b upstream. The callback must not return -1 when nr_to_scan is zero. Fix the bug in fs/super.c and add this requirement to the callback specification. Signed-off-by: Mikulas Patocka Cc: Dave Chinner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/super.c b/fs/super.c index 3f56a269a4f..32a81f3467e 100644 --- a/fs/super.c +++ b/fs/super.c @@ -61,7 +61,7 @@ static int prune_super(struct shrinker *shrink, struct shrink_control *sc) return -1; if (!grab_super_passive(sb)) - return -1; + return !sc->nr_to_scan ? 0 : -1; if (sb->s_op && sb->s_op->nr_cached_objects) fs_objects = sb->s_op->nr_cached_objects(sb); diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index 790651b4e5b..a83833a1f7a 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -20,6 +20,7 @@ struct shrink_control { * 'nr_to_scan' entries and attempt to free them up. It should return * the number of objects which remain in the cache. If it returns -1, it means * it cannot do any scanning at this time (eg. there is a risk of deadlock). + * The callback must not return -1 if nr_to_scan is zero. * * The 'gfpmask' refers to the allocation we are currently trying to * fulfil.