Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vmscan: fix shrinker callback bug in fs/super.c

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>

authored by

Mikulas Patocka and committed by
Linus Torvalds
09f363c7 20c8c628

+2 -1
+1 -1
fs/super.c
··· 61 61 return -1; 62 62 63 63 if (!grab_super_passive(sb)) 64 - return -1; 64 + return !sc->nr_to_scan ? 0 : -1; 65 65 66 66 if (sb->s_op && sb->s_op->nr_cached_objects) 67 67 fs_objects = sb->s_op->nr_cached_objects(sb);
+1
include/linux/shrinker.h
··· 20 20 * 'nr_to_scan' entries and attempt to free them up. It should return 21 21 * the number of objects which remain in the cache. If it returns -1, it means 22 22 * it cannot do any scanning at this time (eg. there is a risk of deadlock). 23 + * The callback must not return -1 if nr_to_scan is zero. 23 24 * 24 25 * The 'gfpmask' refers to the allocation we are currently trying to 25 26 * fulfil.