Skip to contentSkip to conversation

libndctl: ignore ENXIO in ndctl_namespace_delete

PATCH In review Vishal Verma 2 participants 2 messages Jan 8, 2019 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 libndctl: ignore ENXIO in ndctl_namespace_delete

The kernel will return ENXIO and fail attempts to set the size of a namespace that has already been deleted. When we are deleting a namespace, we don't care that it has been previously destroyed, or is in an uninitialized state.

Ignore the ENXIO from setting the size to zero in this case, and report to the callers of this API that the deletion was successful.

This addresses github issue #73.

---
 ndctl/lib/libndctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
ndctl/lib/libndctl.c +6 -1
index 0c3a35e..e82a08d 100644
@@ -4303,7 +4303,12 @@ NDCTL_EXPORT int ndctl_namespace_delete(struct ndctl_namespace *ndns)
 	}
 
 	rc = namespace_set_size(ndns, 0);
-	if (rc)
+	/*
+	 * if the namespace has already been deleted, this will return
+	 * -ENXIO due to the uuid check in __size_store. We can safely
+	 *  ignore it in the case of writing a zero.
+	 */
+	if (rc && (rc != -ENXIO))
 		return rc;
 
 	region->namespaces_init = 0;
Signature · 6 lines
2.17.2

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Vishal Verma

The kernel will return ENXIO and fail attempts to set the size of a namespace that has already been deleted. When we are deleting a namespace, we don't care that it has been previously destroyed, or is in an uninitialized state.

Quoted 6 lines

Ignore the ENXIO from setting the size to zero in this case, and report to the callers of this API that the deletion was successful.

This addresses github issue #73.

Looks good.

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm