Skip to contentSkip to conversation

ndctl/namespace: skip seed namespaces for 'enable-namespace'

PATCH New Vishal Verma 1 participant 2 messages Nov 4, 2019 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/2 ndctl/namespace: skip seed namespaces for 'enable-namespace'

Performing 'ndctl enable-namespace all' results in ndctl going through a number of seed namespaces, one per region, and trying to enable them, which fails as expected. This results in error messages like the following, which are almost always going to be present, and are almost always pointless:

  $ sudo ndctl enable-namespace all
  libndctl: ndctl_namespace_enable: namespace3.0: failed to enable
  libndctl: ndctl_namespace_enable: namespace5.0: failed to enable
  error enabling namespaces: No such device or address
  enabled 5 namespaces

Using the new 'ndctl_namespace_is_configuration_idle()' API to determine whether a given namespace might be a 'seed' namespace, we can avoid these error messages.

Ad a debug message gated behind the verbose option that prints when a namespace is skipped when it it detected as a 'seed'.

---
 ndctl/namespace.c | 5 +++++
 1 file changed, 5 insertions(+)
ndctl/namespace.c +5 -0
index a07d7e2..ed0421b 100644
@@ -1401,6 +1401,11 @@ static int do_xaction_namespace(const char *namespace,
 						(*processed)++;
 					break;
 				case ACTION_ENABLE:
+					if (ndctl_namespace_is_configuration_idle(ndns)) {
+						debug("%s: skip seed namespace\n",
+							ndctl_namespace_get_devname(ndns));
+						continue;
+					}
 					rc = ndctl_namespace_enable(ndns);
 					if (rc >= 0) {
 						(*processed)++;
Signature · 4 lines
2.20.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
author maintainer
#1 lore raw

PATCH 2/2 ndctl/namespace: For enable-namespace all, don't count no-op namespaces

When ndctl-enable-namespace is called for namespaces that are already enabled, it shouldn't report that a positive number of namespaces were enabled. Check whether the namespace is enabled, and if so, omit it from the 'processed' count.

Since the indentation-heavy section for ACTION_ENABLE is getting larger than a simgle libndctl call, break it out into its own namespace_enable() helper.

---
 ndctl/namespace.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
ndctl/namespace.c +18 -8
index ed0421b..cebc312 100644
@@ -961,6 +961,20 @@ out:
 	return rc;
 }
 
+static int namespace_enable(struct ndctl_namespace *ndns)
+{
+	if (ndctl_namespace_is_enabled(ndns))
+		return 1;
+
+	if (ndctl_namespace_is_configuration_idle(ndns)) {
+		debug("%s: skip seed namespace\n",
+			ndctl_namespace_get_devname(ndns));
+		return 1;
+	}
+
+	return ndctl_namespace_enable(ndns);
+}
+
 static int enable_labels(struct ndctl_region *region)
 {
 	int mappings = ndctl_region_get_mappings(region);
@@ -1401,16 +1415,12 @@ static int do_xaction_namespace(const char *namespace,
 						(*processed)++;
 					break;
 				case ACTION_ENABLE:
-					if (ndctl_namespace_is_configuration_idle(ndns)) {
-						debug("%s: skip seed namespace\n",
-							ndctl_namespace_get_devname(ndns));
-						continue;
-					}
-					rc = ndctl_namespace_enable(ndns);
-					if (rc >= 0) {
+					rc = namespace_enable(ndns);
+					if (rc == 0)
 						(*processed)++;
+					/* return success if skipped */
+					if (rc > 0)
 						rc = 0;
-					}
 					break;
 				case ACTION_DESTROY:
 					rc = namespace_destroy(region, ndns);
Signature · 4 lines
2.20.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]