From patchwork Fri Aug 3 17:27:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 10555335 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 050BC13BB for ; Fri, 3 Aug 2018 17:27:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D75D82BE90 for ; Fri, 3 Aug 2018 17:27:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C99082BE9B; Fri, 3 Aug 2018 17:27:22 +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 7A5A92BE90 for ; Fri, 3 Aug 2018 17:27:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 426B3210D93AA; Fri, 3 Aug 2018 10:27: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=192.55.52.43; helo=mga05.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 79810210D8528 for ; Fri, 3 Aug 2018 10:27:21 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 10:27:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,439,1526367600"; d="scan'208";a="69863910" Received: from vverma7-desk1.lm.intel.com ([10.232.112.133]) by FMSMGA003.fm.intel.com with ESMTP; 03 Aug 2018 10:27:13 -0700 From: Vishal Verma To: Subject: [ndctl PATCH] ndctl, inject-smart: continue in spite of errors for uninject-all Date: Fri, 3 Aug 2018 11:27:11 -0600 Message-Id: <20180803172712.3219-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.14.4 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.27 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 When the missing command submissions for ctrl-temperature were added to inject-smart, as a side effect, uninject-all also started trying to uninject ctrl-temperature. Since DSMs for smart injection for certain platforms don't support ctrl-temperature injection, this failed the command. For the uninject-all command, add a sctx flag that allows command submissions to continue in spite of errors. The error messages are still printed out, so they are not lost. This way, uninject-all does a best-effort uninjection of all fields, even if some fields are unsupported by the given platform. Signed-off-by: Vishal Verma --- ndctl/inject-smart.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ndctl/inject-smart.c b/ndctl/inject-smart.c index 56c39ab..d60bbf1 100644 --- a/ndctl/inject-smart.c +++ b/ndctl/inject-smart.c @@ -54,6 +54,7 @@ static struct parameters { static struct smart_ctx { bool alarms_present; + bool err_continue; unsigned long op_mask; unsigned long flags; unsigned int media_temperature; @@ -220,6 +221,7 @@ static int smart_init(void) { if (param.human) sctx.flags |= UTIL_JSON_HUMAN; + sctx.err_continue = false; /* setup attributes and thresholds except alarm_control */ smart_param_setup_temps(media_temperature) @@ -244,6 +246,7 @@ static int smart_init(void) param.spares_uninject = true; param.fatal_uninject = true; param.unsafe_shutdown_uninject = true; + sctx.err_continue = true; } smart_param_setup_uninj(media_temperature) smart_param_setup_uninj(ctrl_temperature) @@ -337,7 +340,8 @@ out: si_cmd = ndctl_dimm_cmd_new_smart_inject(dimm); \ if (!si_cmd) { \ error("%s: no smart inject command support\n", name); \ - goto out; \ + if (sctx.err_continue == false) \ + goto out; \ } \ if (param.arg##_uninject) \ enable = false; \ @@ -345,13 +349,15 @@ out: if (rc) { \ error("%s: smart inject %s cmd invalid: %s (%d)\n", \ name, #arg, strerror(abs(rc)), rc); \ - goto out; \ + if (sctx.err_continue == false) \ + goto out; \ } \ rc = ndctl_cmd_submit(si_cmd); \ if (rc) { \ error("%s: smart inject %s command failed: %s (%d)\n", \ name, #arg, strerror(abs(rc)), rc); \ - goto out; \ + if (sctx.err_continue == false) \ + goto out; \ } \ ndctl_cmd_unref(si_cmd); \ } \ @@ -365,7 +371,8 @@ out: si_cmd = ndctl_dimm_cmd_new_smart_inject(dimm); \ if (!si_cmd) { \ error("%s: no smart inject command support\n", name); \ - goto out; \ + if (sctx.err_continue == false) \ + goto out; \ } \ if (param.arg##_uninject) \ enable = false; \ @@ -373,13 +380,15 @@ out: if (rc) { \ error("%s: smart inject %s cmd invalid: %s (%d)\n", \ name, #arg, strerror(abs(rc)), rc); \ - goto out; \ + if (sctx.err_continue == false) \ + goto out; \ } \ rc = ndctl_cmd_submit(si_cmd); \ if (rc) { \ error("%s: smart inject %s command failed: %s (%d)\n", \ name, #arg, strerror(abs(rc)), rc); \ - goto out; \ + if (sctx.err_continue == false) \ + goto out; \ } \ ndctl_cmd_unref(si_cmd); \ } \