From patchwork Thu Nov 8 21:26:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kani, Toshi" X-Patchwork-Id: 10675041 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 AB75B1709 for ; Thu, 8 Nov 2018 21:27:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A9EE2E545 for ; Thu, 8 Nov 2018 21:27:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E7082E574; Thu, 8 Nov 2018 21:27:07 +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 A12EF2E573 for ; Thu, 8 Nov 2018 21:27:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4769521A07A80; Thu, 8 Nov 2018 13:27:06 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=15.241.140.75; helo=g4t3426.houston.hpe.com; envelope-from=toshi.kani@hpe.com; receiver=linux-nvdimm@lists.01.org Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) (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 6ECE22118DC32 for ; Thu, 8 Nov 2018 13:27:04 -0800 (PST) Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id 5DDC64E; Thu, 8 Nov 2018 21:27:03 +0000 (UTC) Received: from misato.americas.hpqcorp.net (misato.americas.hpqcorp.net [10.34.81.122]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id F00A248; Thu, 8 Nov 2018 21:27:02 +0000 (UTC) From: Toshi Kani To: dan.j.williams@intel.com, vishal.l.verma@intel.com Subject: [PATCH] ndctl: fix zero-labels to handle firmware error properly Date: Thu, 8 Nov 2018 14:26:59 -0700 Message-Id: <20181108212659.15570-1-toshi.kani@hpe.com> X-Mailer: git-send-email 2.17.2 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: , Cc: linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP ndctl zero-labels completes with a large number of zeroed nmems when it fails to do zeroing on a protected NVDIMM. # ndctl zero-labels nmem1 zeroed 65504 nmems do_cmd() called from ndctl_dimm_zero_labels() sets a transfer size to rc when FW status is non-zero. This transfer size gets mistreated as zeroed nmems count in the end. Fix ndctl_dimm_zero_labels() to handle this FW error case properly. Reported-by: Robert Elliott Signed-off-by: Toshi Kani Cc: Vishal Verma Cc: Dan Williams Reviewed-by: Dan Williams --- ndctl/lib/dimm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ndctl/lib/dimm.c b/ndctl/lib/dimm.c index 5e41734..79e2ca0 100644 --- a/ndctl/lib/dimm.c +++ b/ndctl/lib/dimm.c @@ -537,8 +537,12 @@ NDCTL_EXPORT int ndctl_dimm_zero_labels(struct ndctl_dimm *dimm) goto out_write; } rc = ndctl_cmd_submit(cmd_write); - if (rc || ndctl_cmd_get_firmware_status(cmd_write)) + if (rc < 0) goto out_write; + if (ndctl_cmd_get_firmware_status(cmd_write)) { + rc = -ENXIO; + goto out_write; + } /* * If the dimm is already disabled the kernel is not holding a cached