nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Toshi Kani <toshi.kani@hpe.com>
To: dan.j.williams@intel.com, vishal.l.verma@intel.com
Cc: linux-nvdimm@lists.01.org
Subject: [PATCH] ndctl: fix zero-labels to handle firmware error properly
Date: Thu,  8 Nov 2018 14:26:59 -0700	[thread overview]
Message-ID: <20181108212659.15570-1-toshi.kani@hpe.com> (raw)

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 <elliott@hpe.com>
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
---
 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
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

             reply	other threads:[~2018-11-08 21:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08 21:26 Toshi Kani [this message]
2018-11-08 21:38 ` [PATCH] ndctl: fix zero-labels to handle firmware error properly Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181108212659.15570-1-toshi.kani@hpe.com \
    --to=toshi.kani@hpe.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).