From patchwork Thu Sep 6 18:58:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10590945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F24C112B for ; Thu, 6 Sep 2018 18:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D8E92AA60 for ; Thu, 6 Sep 2018 18:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51B1C2AF7F; Thu, 6 Sep 2018 18:57:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0DBE22AA60 for ; Thu, 6 Sep 2018 18:57:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E23882112387B; Thu, 6 Sep 2018 11:57:22 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=keith.busch@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EF07221122E5C for ; Thu, 6 Sep 2018 11:57:20 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 11:57:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,339,1531810800"; d="scan'208";a="260460381" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.44]) by fmsmga005.fm.intel.com with ESMTP; 06 Sep 2018 11:57:20 -0700 From: Keith Busch To: linux-nvdimm@lists.01.org, Vishal Verma Subject: [ndctl PATCH] ndctl: Suppress command errors if fallback exists Date: Thu, 6 Sep 2018 12:58:48 -0600 Message-Id: <20180906185848.31198-1-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP If a command has a fallback to handle an error, this patch will not emit an error message and instead let the handler report any errors. Signed-off-by: Keith Busch --- ndctl/lib/intel.c | 9 +++++++-- ndctl/lib/libndctl.c | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c index b1254bb..15c5d1a 100644 --- a/ndctl/lib/intel.c +++ b/ndctl/lib/intel.c @@ -64,15 +64,17 @@ static struct ndctl_cmd *alloc_intel_cmd(struct ndctl_dimm *dimm, static int intel_smart_handle_error(struct ndctl_cmd *cmd) { struct ndctl_dimm *dimm = cmd->dimm; + struct ndctl_bus *bus = cmd_to_bus(cmd); + struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus); char *path = NULL, shutdown_count[16] = {}; int fd, rc = cmd->status; if (!dimm) - return 0; + goto out; if (asprintf(&path, DEF_TMPFS_DIR "/%s/usc", ndctl_dimm_get_devname(dimm)) < 0) - return rc; + goto out; fd = open(path, O_RDONLY); if (fd < 0) @@ -88,6 +90,9 @@ static int intel_smart_handle_error(struct ndctl_cmd *cmd) close (fd); free_path: free(path); + out: + if (rc) + err(ctx, "failed: %s\n", strerror(errno)); return rc; } diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 226a577..481b110 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -2753,7 +2753,9 @@ NDCTL_EXPORT int ndctl_cmd_submit(struct ndctl_cmd *cmd) fd = open(path, O_RDWR); if (fd < 0) { - err(ctx, "failed to open %s: %s\n", path, strerror(errno)); + if (!cmd->handle_error) + err(ctx, "failed to open %s: %s\n", path, + strerror(errno)); rc = -errno; goto out; }