zfs_prune: reset sc.nr_to_scan

sc.nr_to_scan is an input to super_cache_clean (via
shrinker->scan_objects), used to set the number of objects to scan
in the various caches. However super_cache_scan also modifies
sc.nr_to_scan, so when used in a loop we need to reset
sc.nr_to_scan back to our desired nr_to_scan for the next
iteration.

Issue discovered and solution suggested by
Tenzin Lhakhang @tlhakhan.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Dunlop <chris@onthe.net.au>
Issue #12433
Closes #12908
This commit is contained in:
chrisrd 2022-01-05 12:07:33 +11:00 committed by GitHub
parent 3c80e0742a
commit 2a149775b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -1251,6 +1251,11 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects)
*objects = 0; *objects = 0;
for_each_online_node(sc.nid) { for_each_online_node(sc.nid) {
*objects += (*shrinker->scan_objects)(shrinker, &sc); *objects += (*shrinker->scan_objects)(shrinker, &sc);
/*
* reset sc.nr_to_scan, modified by
* scan_objects == super_cache_scan
*/
sc.nr_to_scan = nr_to_scan;
} }
} else { } else {
*objects = (*shrinker->scan_objects)(shrinker, &sc); *objects = (*shrinker->scan_objects)(shrinker, &sc);