From: Vishal Verma <vishal.l.verma@intel.com>
To: <linux-nvdimm@lists.01.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [ndctl PATCH 2/2] ndctl/namespace: For enable-namespace all, don't count no-op namespaces
Date: Mon, 4 Nov 2019 16:08:57 -0700 [thread overview]
Message-ID: <20191104230857.28172-2-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20191104230857.28172-1-vishal.l.verma@intel.com>
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
prev parent reply other threads:[~2019-11-04 23:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191104230857.28172-2-vishal.l.verma@intel.com \
--to=vishal.l.verma@intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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).