btrfs-progs: scrub status: consider the lowest non-zero limit

On multi-device filesystems, a scrub limit may be applied to any of the
devices. Ensure that any limit found is not disregarded.

Since it's more intuitive, keep the lowest non-zero limit found, even
though at the present we don't actually use the exact value.

Pull-request: #733
Issue: #727
Fixes: 7e4a235df1 ("btrfs-progs: scrub status: print device speed limit in status if set")
Signed-off-by: Jonas Malaco <jonas@protocubo.io>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Jonas Malaco 2024-01-15 08:28:56 -03:00 committed by David Sterba
parent 8bca55d1e7
commit 96011debe4

View File

@ -1947,8 +1947,10 @@ static int cmd_scrub_status(const struct cmd_struct *cmd, int argc, char **argv)
init_fs_stat(&fs_stat);
fs_stat.s.in_progress = in_progress;
for (i = 0; i < fi_args.num_devices; ++i) {
/* Save the last limit only, works for a single device filesystem. */
limit = read_scrub_device_limit(fdmnt, di_args[i].devid);
/* On a multi-device filesystem, keep the lowest limit only. */
u64 this_limit = read_scrub_device_limit(fdmnt, di_args[i].devid);
if (!limit || (this_limit && this_limit < limit))
limit = this_limit;
last_scrub = last_dev_scrub(past_scrubs,
di_args[i].devid);