diff mbox

[ndctl,1/8] ndctl, create-namespace: make zero_info_block() more robust

Message ID 146135442769.4228.5883488750920483205.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit b050c9f6cf16
Headers show

Commit Message

Dan Williams April 22, 2016, 7:47 p.m. UTC
Arrange for zero_info_block() to continue in the case when the namespace
cannot be enabled.  This allows a partially configured namespace to be
reset.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 builtin-xaction-namespace.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
index d83ad91a7258..3e13a1c0c3a1 100644
--- a/builtin-xaction-namespace.c
+++ b/builtin-xaction-namespace.c
@@ -463,12 +463,17 @@  static int zero_info_block(struct ndctl_namespace *ndns)
 	char path[50];
 	void *buf;
 
+	ndctl_namespace_set_raw_mode(ndns, 1);
+	rc = ndctl_namespace_enable(ndns);
+	if (rc < 0) {
+		debug("%s failed to enable for zeroing, continuing\n", devname);
+		rc = 0;
+		goto out;
+	}
+
 	if (posix_memalign(&buf, 4096, 4096) != 0)
 		return -ENXIO;
 
-	ndctl_namespace_set_raw_mode(ndns, 1);
-	ndctl_namespace_enable(ndns);
-
 	sprintf(path, "/dev/%s", ndctl_namespace_get_block_device(ndns));
 	fd = open(path, O_RDWR|O_DIRECT|O_EXCL);
 	if (fd < 0) {