]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
vmscan: fix shrinker callback bug in fs/super.c
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 1 Nov 2011 00:08:57 +0000 (17:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 1 Nov 2011 00:30:49 +0000 (17:30 -0700)
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 <mpatocka@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/super.c
include/linux/shrinker.h

index 3f56a269a4f4e30c4c31feb0b73b05064cc974b9..32a81f3467e06835abdf8e5a3beb91acc3a2c161 100644 (file)
@@ -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);
index 790651b4e5baf6ea9625cd186065019e8133784e..a83833a1f7a26f589a7584252ff413333286f5ea 100644 (file)
@@ -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.