From cde38029bdfa7acc43ec91877d8e89cda6cedb11 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Tue, 28 Jul 2015 15:53:58 +0800 Subject: btrfs-progs: Increase running state's priority in stat output Anthony Plack reported a output bug in maillist: title: btrfs-progs SCRUB reporting aborted but still running - minor btrfs scrub status report it was aborted but still runs to completion. # btrfs scrub status /mnt/data scrub status for f591ac13-1a69-476d-bd30-346f87a491da scrub started at Mon Apr 27 06:48:44 2015 and was aborted after 1089 seconds total bytes scrubbed: 1.02TiB with 0 errors # # btrfs scrub status /mnt/data scrub status for f591ac13-1a69-476d-bd30-346f87a491da scrub started at Mon Apr 27 06:48:44 2015 and was aborted after 1664 seconds total bytes scrubbed: 1.53TiB with 0 errors # ... Reason: When scrub multi-device simultaneously, if some device canceled, and some device is still running, cancel state have higher priority to be outputed in global report. So we can see "scrub aborted" in status line, with running-time keeps increased. Fix: We can increase running state's priority in output, if there is some device in scrub state, we output running state instead of cancelled state. Reported-by: Anthony Plack Signed-off-by: Zhao Lei Signed-off-by: David Sterba --- cmds-scrub.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'cmds-scrub.c') diff --git a/cmds-scrub.c b/cmds-scrub.c index 0340471a..3ebda9dc 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -254,17 +254,15 @@ static void _print_scrub_ss(struct scrub_stats *ss) hours = ss->duration / (60 * 60); gmtime_r(&seconds, &tm); strftime(t, sizeof(t), "%M:%S", &tm); - if (ss->finished && !ss->canceled) { - printf(" and finished after %02u:%s\n", hours, t); - } else if (ss->canceled) { + if (ss->in_progress) + printf(", running for %02u:%s\n", hours, t); + else if (ss->canceled) printf(" and was aborted after %02u:%s\n", hours, t); - } else { - if (ss->in_progress) - printf(", running for %02u:%s\n", hours, t); - else - printf(", interrupted after %02u:%s, not running\n", - hours, t); - } + else if (ss->finished) + printf(" and finished after %02u:%s\n", hours, t); + else + printf(", interrupted after %02u:%s, not running\n", + hours, t); } static void print_scrub_dev(struct btrfs_ioctl_dev_info_args *di, -- cgit v1.2.3