diff mbox series

ndctl: fix zero-labels to handle firmware error properly

Message ID 20181108212659.15570-1-toshi.kani@hpe.com (mailing list archive)
State Accepted
Commit c7e235e625f18a0f4782453bafaa0336ed264992
Headers show
Series ndctl: fix zero-labels to handle firmware error properly | expand

Commit Message

Kani, Toshi Nov. 8, 2018, 9:26 p.m. UTC
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(-)

Comments

Dan Williams Nov. 8, 2018, 9:38 p.m. UTC | #1
On Thu, Nov 8, 2018 at 1:27 PM Toshi Kani <toshi.kani@hpe.com> wrote:
>
> 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>

Looks good,

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
diff mbox series

Patch

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