nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: nvdimm@lists.linux.dev, dan.j.williams@intel.com,
	Vishal L Verma <vishal.l.verma@intel.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: [PATCH] ndctl: Avoid confusing error message when operating on all the namespaces
Date: Thu,  8 Jul 2021 15:31:04 +0530	[thread overview]
Message-ID: <20210708100104.168348-1-aneesh.kumar@linux.ibm.com> (raw)

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

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

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

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)

             reply	other threads:[~2021-07-08 10:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 10:01 Aneesh Kumar K.V [this message]
2021-07-13  0:19 ` [PATCH] ndctl: Avoid confusing error message when operating on all the namespaces 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708100104.168348-1-aneesh.kumar@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).