All of lore.kernel.org
 help / color / mirror / Atom feed
From: Redhairer Li <redhairer.li@intel.com>
To: linux-nvdimm@lists.01.org, dan.j.williams@intel.com
Cc: Redhairer Li <redhairer.li@intel.com>
Subject: [PATCH 1/1] ndctl/namespace: Fix disable-namespace accounting relative to seed devices
Date: Sun, 10 May 2020 23:32:07 +0800	[thread overview]
Message-ID: <20200510153207.19296-1-redhairer.li@intel.com> (raw)

Seed namespaces are included in "ndctl disable-namespace all". However
since the user never "creates" them it is surprising to see
"disable-namespace" report 1 more namespace relative to the number that
have been created. Catch attempts to disable a zero-sized namespace:

Before:
{
  "dev":"namespace1.0",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1"
}
{
  "dev":"namespace1.1",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.1"
}
{
  "dev":"namespace1.2",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.2"
}
disabled 4 namespaces

After:
{
  "dev":"namespace1.0",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1"
}
{
  "dev":"namespace1.3",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.3"
}
{
  "dev":"namespace1.1",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.1"
}
disabled 3 namespaces

Signed-off-by: Redhairer Li <redhairer.li@intel.com>
---
 ndctl/namespace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 0550580..1bfe736 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2034,6 +2034,7 @@ static int do_xaction_namespace(const char *namespace,
 	struct ndctl_region *region;
 	const char *ndns_name;
 	struct ndctl_bus *bus;
+	unsigned long long size;
 
 	*processed = 0;
 
@@ -2134,7 +2135,8 @@ static int do_xaction_namespace(const char *namespace,
 				switch (action) {
 				case ACTION_DISABLE:
 					rc = ndctl_namespace_disable_safe(ndns);
-					if (rc == 0)
+					size = ndctl_namespace_get_size(ndns);
+					if (rc == 0 && size != 0)
 						(*processed)++;
 					break;
 				case ACTION_ENABLE:
-- 
2.20.1.windows.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

             reply	other threads:[~2020-05-10 15:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10 15:32 Redhairer Li [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-04-26  9:52 [PATCH 1/1] ndctl/namespace: Fix disable-namespace accounting relative to seed devices Redhairer Li
2020-04-27 20:31 ` Dan Williams
2020-04-28  1:09   ` Li, Redhairer
2021-01-13  7:07     ` Dan Williams
2021-01-15 14:50       ` redhairer
2021-01-15 17:22       ` Li, Redhairer
2021-01-28  8:47         ` Dan Williams
2021-01-28 14:03           ` redhairer
2021-01-28 16:16           ` Li, Redhairer
2021-01-29  8:44             ` Li, Redhairer

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=20200510153207.19296-1-redhairer.li@intel.com \
    --to=redhairer.li@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.