From patchwork Wed Aug 5 08:32:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 6946921 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 4D3489F358 for ; Wed, 5 Aug 2015 08:34:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 766ED20481 for ; Wed, 5 Aug 2015 08:34:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9000F20452 for ; Wed, 5 Aug 2015 08:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751639AbbHEIeI (ORCPT ); Wed, 5 Aug 2015 04:34:08 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:11950 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751093AbbHEIeG (ORCPT ); Wed, 5 Aug 2015 04:34:06 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="99289003" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 05 Aug 2015 16:37:31 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t758W8la016291 for ; Wed, 5 Aug 2015 16:32:08 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 5 Aug 2015 16:34:02 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH] btrfs-progs: Modify confuse error message in scrub Date: Wed, 5 Aug 2015 16:32:26 +0800 Message-ID: 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=-7.0 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 Scrub output following error message in my test: ERROR: scrubbing /var/ltf/tester/scratch_mnt failed for device id 5 (Success) It is caused by a broken kernel and fs, but the we need to avoid outputting both "error and success" in oneline message as above. This patch modified above message to: ERROR: scrubbing /var/ltf/tester/scratch_mnt failed for device id 5, ret=1, errno=0(Success) Signed-off-by: Zhao Lei --- cmds-scrub.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/cmds-scrub.c b/cmds-scrub.c index 7c9318e..2529956 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -1457,21 +1457,25 @@ static int scrub_start(int argc, char **argv, int resume) ++err; continue; } - if (sp[i].ret && sp[i].ioctl_errno == ENODEV) { - if (do_print) - fprintf(stderr, "WARNING: device %lld not " - "present\n", devid); - continue; - } - if (sp[i].ret && sp[i].ioctl_errno == ECANCELED) { - ++err; - } else if (sp[i].ret) { - if (do_print) - fprintf(stderr, "ERROR: scrubbing %s failed " - "for device id %lld (%s)\n", path, - devid, strerror(sp[i].ioctl_errno)); - ++err; - continue; + if (sp[i].ret) { + switch (sp[i].ioctl_errno) { + case ENODEV: + if (do_print) + fprintf(stderr, "WARNING: device %lld not present\n", + devid); + continue; + case ECANCELED: + ++err; + break; + default: + if (do_print) + fprintf(stderr, "ERROR: scrubbing %s failed for device id %lld, ret=%d, errno=%d(%s)\n", + path, devid, + sp[i].ret, sp[i].ioctl_errno, + strerror(sp[i].ioctl_errno)); + ++err; + continue; + } } if (sp[i].scrub_args.progress.uncorrectable_errors > 0) e_uncorrectable++;