diff mbox series

[ndctl] libndctl: ignore ENXIO in ndctl_namespace_delete

Message ID 20190108221510.28553-1-vishal.l.verma@intel.com (mailing list archive)
State Accepted
Commit 720d5590a0ac00cb9725f50876ccb96eba6f6aa8
Headers show
Series [ndctl] libndctl: ignore ENXIO in ndctl_namespace_delete | expand

Commit Message

Verma, Vishal L Jan. 8, 2019, 10:15 p.m. UTC
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 <vishal.l.verma@intel.com>
---
 ndctl/lib/libndctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Dan Williams Jan. 8, 2019, 10:59 p.m. UTC | #1
On Tue, Jan 8, 2019 at 2:15 PM Vishal Verma <vishal.l.verma@intel.com> wrote:
>
> 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 <vishal.l.verma@intel.com>

Looks good.

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

Patch

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;