diff mbox series

[ndctl,v2,23/26] ndctl/namespace: Report ENOSPC when regions are full

Message ID 156426368351.531577.5819409272263585965.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Superseded
Headers show
Series Improvements for namespace creation/interrogation | expand

Commit Message

Dan Williams July 27, 2019, 9:41 p.m. UTC
The create-namespace error message:

    failed to create namespace: Resource temporarily unavailable

...is misleading because the lack of capacity is permanent until the
user frees up space.

Trap EAGAIN and translate to ENOSPC in case the region capacity search
fails:

    failed to create namespace: No space left on device

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/namespace.c |    9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 75ea366574f8..f215f77a94e1 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -1806,6 +1806,15 @@  static int do_xaction_namespace(const char *namespace,
 	if (ri_ctx.f_out && ri_ctx.f_out != stdout)
 		fclose(ri_ctx.f_out);
 
+	if (action == ACTION_CREATE && rc == -EAGAIN) {
+		/*
+		 * Namespace creation searched through all candidate
+		 * regions and all of them said "nope, I don't have
+		 * enough capacity", so report -ENOSPC
+		 */
+		rc = -ENOSPC;
+	}
+
 	return rc;
 }