From patchwork Tue Jul 28 07:53:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 6880011 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC2A79F380 for ; Tue, 28 Jul 2015 07:55:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C79BE206BE for ; Tue, 28 Jul 2015 07:55:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B374920674 for ; Tue, 28 Jul 2015 07:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755047AbbG1Hzi (ORCPT ); Tue, 28 Jul 2015 03:55:38 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:35799 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753934AbbG1Hzh (ORCPT ); Tue, 28 Jul 2015 03:55:37 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="98974165" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 28 Jul 2015 15:59:10 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t6S7riwM015895 for ; Tue, 28 Jul 2015 15:53:44 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 28 Jul 2015 15:55:34 +0800 From: Zhaolei To: CC: Zhao Lei Subject: [PATCH] btrfs-progs: Increase running state's priority in stat output Date: Tue, 28 Jul 2015 15:53:58 +0800 Message-ID: <7c723cfb3f6b2d792b832b96f2b6b0258a13044e.1438070027.git.zhaolei@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.1 MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zhao Lei 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 --- cmds-scrub.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cmds-scrub.c b/cmds-scrub.c index b7aa809..7c9318e 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -252,17 +252,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,