Skip to content

Commit

Permalink
zfs_prune: reset sc.nr_to_scan
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chris Dunlop <[email protected]>
Issue openzfs#12433
Closes openzfs#12908
  • Loading branch information
chrisrd authored and Ryan Moeller committed Jan 18, 2022
1 parent d43236a commit a0c70ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions module/os/linux/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,11 @@ zfs_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects)
*objects = 0;
for_each_online_node(sc.nid) {
*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 {
*objects = (*shrinker->scan_objects)(shrinker, &sc);
Expand Down

0 comments on commit a0c70ee

Please sign in to comment.