From 96011debe45d8924bbb0a90cf5c521c79b8bfeaa Mon Sep 17 00:00:00 2001 From: Jonas Malaco Date: Mon, 15 Jan 2024 08:28:56 -0300 Subject: 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: 7e4a235df1ac ("btrfs-progs: scrub status: print device speed limit in status if set") Signed-off-by: Jonas Malaco Signed-off-by: David Sterba --- cmds/scrub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmds/scrub.c b/cmds/scrub.c index 36017135..59845622 100644 --- a/cmds/scrub.c +++ b/cmds/scrub.c @@ -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); -- cgit 1.2.3-korg