Linux-NVDIMM Archive on lore.kernel.org
 help / color / Atom feed
* [ndctl PATCH 1/2] ndctl/namespace: skip seed namespaces for 'enable-namespace'
@ 2019-11-04 23:08 Vishal Verma
  2019-11-04 23:08 ` [ndctl PATCH 2/2] ndctl/namespace: For enable-namespace all, don't count no-op namespaces Vishal Verma
  0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2019-11-04 23:08 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Aneesh Kumar K . V

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'.

Link: https://github.com/pmem/ndctl/issues/119
Cc: Dan Williams <dan.j.williams@intel.com>
Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/namespace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index a07d7e2..ed0421b 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -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)++;
-- 
2.20.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ndctl PATCH 2/2] ndctl/namespace: For enable-namespace all, don't count no-op namespaces
  2019-11-04 23:08 [ndctl PATCH 1/2] ndctl/namespace: skip seed namespaces for 'enable-namespace' Vishal Verma
@ 2019-11-04 23:08 ` Vishal Verma
  0 siblings, 0 replies; 2+ messages in thread
From: Vishal Verma @ 2019-11-04 23:08 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Dan Williams, Vishal Verma

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.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/namespace.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index ed0421b..cebc312 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -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);
-- 
2.20.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 23:08 [ndctl PATCH 1/2] ndctl/namespace: skip seed namespaces for 'enable-namespace' Vishal Verma
2019-11-04 23:08 ` [ndctl PATCH 2/2] ndctl/namespace: For enable-namespace all, don't count no-op namespaces Vishal Verma

Linux-NVDIMM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvdimm/0 linux-nvdimm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvdimm linux-nvdimm/ https://lore.kernel.org/linux-nvdimm \
		linux-nvdimm@lists.01.org
	public-inbox-index linux-nvdimm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.01.lists.linux-nvdimm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git