Skip to contentSkip to conversation

ndctl/namespace: Fix enable-namespace error for seed namespaces

PATCH In review Santosh Sivaraj 2 participants 3 messages Jan 13, 2020 – Feb 20, 2020 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ndctl/namespace: Fix enable-namespace error for seed namespaces

'ndctl enable-namespace all' tries to enable seed namespaces too, which results in a error like

libndctl: ndctl_namespace_enable: namespace1.0: failed to enable

---
 ndctl/lib/libndctl.c | 5 +++++
 1 file changed, 5 insertions(+)
ndctl/lib/libndctl.c +5 -0
index 6596f94..9c6ccb8 100644
@@ -4010,11 +4010,16 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
 	struct ndctl_region *region = ndns->region;
+	unsigned long long size = ndctl_namespace_get_size(ndns);
 	int rc;
 
 	if (ndctl_namespace_is_enabled(ndns))
 		return 0;
 
+	/* Don't try to enable idle namespace (no capacity allocated) */
+	if (size == 0)
+		return -ENXIO;
+
 	rc = ndctl_bind(ctx, ndns->module, devname);
 
 	/*
Signature · 4 lines
2.24.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#1 lore raw
Quoted 4 lines · Santosh Sivaraj

'ndctl enable-namespace all' tries to enable seed namespaces too, which results in a error like

libndctl: ndctl_namespace_enable: namespace1.0: failed to enable

Dan/Vishal,

Will this patch be taken in the next ndctl release?

Thanks,
Santosh

Quoted 29 lines
---
 ndctl/lib/libndctl.c | 5 +++++
 1 file changed, 5 insertions(+)
ndctl/lib/libndctl.c +5 -0
index 6596f94..9c6ccb8 100644
@@ -4010,11 +4010,16 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
 	struct ndctl_region *region = ndns->region;
+	unsigned long long size = ndctl_namespace_get_size(ndns);
 	int rc;
 
 	if (ndctl_namespace_is_enabled(ndns))
 		return 0;
 
+	/* Don't try to enable idle namespace (no capacity allocated) */
+	if (size == 0)
+		return -ENXIO;
+
 	rc = ndctl_bind(ctx, ndns->module, devname);
 
 	/*
Signature · 1 line
2.24.1

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

#2 lore raw
Quoted 11 lines · Santosh Sivaraj
Quoted 4 lines · Santosh Sivaraj

'ndctl enable-namespace all' tries to enable seed namespaces too, which results in a error like

libndctl: ndctl_namespace_enable: namespace1.0: failed to enable

Dan/Vishal,

Will this patch be taken in the next ndctl release?

Thanks for the reminder. I've picked this up.
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]