From patchwork Wed Oct 8 09:42:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 5052911 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 577D09F295 for ; Wed, 8 Oct 2014 09:44:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4CEC7203C0 for ; Wed, 8 Oct 2014 09:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 112062026F for ; Wed, 8 Oct 2014 09:43:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756239AbaJHJni (ORCPT ); Wed, 8 Oct 2014 05:43:38 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:38928 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756225AbaJHJnd (ORCPT ); Wed, 8 Oct 2014 05:43:33 -0400 Received: by mail-pa0-f49.google.com with SMTP id hz1so8654394pad.8 for ; Wed, 08 Oct 2014 02:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=d+NuQbaHbJJ1/MAvTNWN1f5iNHnXlpOuBRwJrduOtgk=; b=WraEDNYBkyibVbX+36Ikir9cT5oeOqCk8qIzT0PJGSi2zssytfzNz4oys9fylcybbg Xzrrb7nqZ/CN4CgqVKVh3+ve3x8nfyBpEjUdjn3YgKdWvvMJIl6G9cK4nDhAXFRUkytv s4pyAisd/4uHzYeLt7nB/ePsWX1Cc8Mmf6nDDwoUnW4gjmwJtQdlb82VijUhiblxjZdQ nG2dsU/ogvr80/K8Pbc11NXE2YXS3BDLS+exvQcRqfGwpWJBqcOcXaXywLnIshwD8LA0 +Vp5RrWKktNmzMbdY0qTs3+7vAIKCRFZMwvbNxzCGshge6OS8VDE4jfLo+dOmhMP3LnF sr7Q== X-Received: by 10.70.96.102 with SMTP id dr6mr9378710pdb.86.1412761413006; Wed, 08 Oct 2014 02:43:33 -0700 (PDT) Received: from localhost ([203.114.244.88]) by mx.google.com with ESMTPSA id hs8sm18130861pbc.35.2014.10.08.02.43.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Oct 2014 02:43:31 -0700 (PDT) From: Eryu Guan To: linux-btrfs@vger.kernel.org Cc: Eryu Guan Subject: [PATCH 1/2] btrfs-progs: don't report internal dev replace result if ioctl failed Date: Wed, 8 Oct 2014 17:42:28 +0800 Message-Id: <1412761349-32721-1-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 1.9.3 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 If BTRFS_IOC_DEV_REPLACE ioctl failed, there's no result returned to fill args.result, it doesn't make sense to report this internal result to user. And the arg has been initialized with 0, the result is always 0, which is BTRFS_IOCTL_DEV_REPLACE_REPLACE_NO_ERROR, and the resulting error message looks confusing too: ERROR: ioctl(DEV_REPLACE_START) failed on "/mnt/btrfs": No such file or directory, no error So just skip the internal dev replace result if the whole ioctl failed. Signed-off-by: Eryu Guan --- cmds-replace.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/cmds-replace.c b/cmds-replace.c index 9fe7ad8..51b7aaf 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -187,9 +187,8 @@ static int cmd_start_replace(int argc, char **argv) ret = ioctl(fdmnt, BTRFS_IOC_DEV_REPLACE, &status_args); if (ret) { fprintf(stderr, - "ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s, %s\n", - path, strerror(errno), - replace_dev_result2string(status_args.result)); + "ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s\n", + path, strerror(errno)); goto leave_with_error; } @@ -305,9 +304,8 @@ static int cmd_start_replace(int argc, char **argv) if (do_not_background) { if (ret) { fprintf(stderr, - "ERROR: ioctl(DEV_REPLACE_START) failed on \"%s\": %s, %s\n", - path, strerror(errno), - replace_dev_result2string(start_args.result)); + "ERROR: ioctl(DEV_REPLACE_START) failed on \"%s\": %s\n", + path, strerror(errno)); if (errno == EOPNOTSUPP) fprintf(stderr, @@ -404,9 +402,8 @@ static int print_replace_status(int fd, const char *path, int once) args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS; ret = ioctl(fd, BTRFS_IOC_DEV_REPLACE, &args); if (ret) { - fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s, %s\n", - path, strerror(errno), - replace_dev_result2string(args.result)); + fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s\n", + path, strerror(errno)); return ret; } @@ -554,9 +551,8 @@ static int cmd_cancel_replace(int argc, char **argv) e = errno; close_file_or_dir(fd, dirstream); if (ret) { - fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_CANCEL) failed on \"%s\": %s, %s\n", - path, strerror(e), - replace_dev_result2string(args.result)); + fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_CANCEL) failed on \"%s\": %s\n", + path, strerror(e)); return 1; } if (args.result == BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED) {