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.

Signed-off-by: Vishal Verma <[email protected]>
---
 ndctl/lib/libndctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 0c3a35e..e82a08d 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -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;
-- 
2.17.2

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

Reply via email to