nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] ndctl: Avoid confusing error message when operating on all the namespaces
@ 2021-07-08 10:01 Aneesh Kumar K.V
  2021-07-13  0:19 ` Yi Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Aneesh Kumar K.V @ 2021-07-08 10:01 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, Vishal L Verma; +Cc: Aneesh Kumar K.V

With only seed namespace present, ndctl results in confusing error messages as
below.

ndctl# ./ndctl/ndctl  enable-namespace all
error enabling namespaces: No such device or address
enabled 0 namespaces

ndctl# ./ndctl/ndctl  disable-namespace all
disabled 3 namespaces

ndctl# ./ndctl/ndctl  destroy-namespace all -f
  Error: destroy namespace: namespace1.0 failed to enable for zeroing, continuing

  Error: destroy namespace: namespace1.1 failed to enable for zeroing, continuing

  Error: destroy namespace: namespace0.0 failed to enable for zeroing, continuing

destroyed 0 namespaces
ndctl#

With the patch we get
ndctl# ./ndctl/ndctl  disable-namespace all
disabled 0 namespaces

ndctl# ./ndctl/ndctl  enable-namespace all
enabled 0 namespaces

ndctl# ./ndctl/ndctl  destroy-namespace all -f
destroyed 0 namespaces
ndctl#

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 ndctl/namespace.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 0c8df9fa8b47..c52daeae562a 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2205,8 +2205,15 @@ static int do_xaction_namespace(const char *namespace,
 				return rc;
 			}
 			ndctl_namespace_foreach_safe(region, ndns, _n) {
-				ndns_name = ndctl_namespace_get_devname(ndns);
 
+				if (!strcmp(namespace, "all")
+						&& !ndctl_namespace_get_size(ndns)) {
+					if (!*processed && rc)
+						rc  = 0;
+					continue;
+				}
+
+				ndns_name = ndctl_namespace_get_devname(ndns);
 				if (strcmp(namespace, "all") != 0
 						&& strcmp(namespace, ndns_name) != 0)
 					continue;
-- 
2.31.1


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

end of thread, other threads:[~2021-09-13  4:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 10:01 [PATCH] ndctl: Avoid confusing error message when operating on all the namespaces Aneesh Kumar K.V
2021-07-13  0:19 ` Yi Zhang
2021-07-13  4:14   ` Aneesh Kumar K.V
2021-07-13  5:16   ` Dan Williams
2021-07-15  3:39     ` Yi Zhang
2021-09-13  4:57     ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).