linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ndctl rebased 1/3] ndctl/namespace: Skip seed namespaces when processing all namespaces.
@ 2021-01-06 13:17 Michal Suchanek
  2021-01-06 13:17 ` [PATCH ndctl rebased 2/3] ndctl/namespace: Suppress -ENXIO " Michal Suchanek
  2021-01-06 13:17 ` [PATCH ndctl rebased 3/3] namespace-action: Drop zero namespace checks Michal Suchanek
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Suchanek @ 2021-01-06 13:17 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Michal Suchanek, Harish Sriram

The seed namespaces are exposed by the kernel but most operations are
not valid on seed namespaces.

When processing all namespaces the user gets confusing errors from ndctl
trying to process seed namespaces. The kernel does not provide any way
to tell that a namspace is seed namespace but skipping namespaces with
zero size and UUID is a good heuristic.

The user can still specify the namespace by name directly in case
processing it is desirable.

Fixes: #41
Link: https://patchwork.kernel.org/patch/11473645/
Reviewed-by: Santosh S <santosh@fossix.org>
Tested-by: Harish Sriram <harish@linux.ibm.com>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 ndctl/namespace.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 0c8df9fa8b47..b9ffd21fe7bf 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2207,9 +2207,19 @@ static int do_xaction_namespace(const char *namespace,
 			ndctl_namespace_foreach_safe(region, ndns, _n) {
 				ndns_name = ndctl_namespace_get_devname(ndns);
 
-				if (strcmp(namespace, "all") != 0
-						&& strcmp(namespace, ndns_name) != 0)
-					continue;
+				if (strcmp(namespace, "all") == 0) {
+					static const uuid_t zero_uuid;
+					uuid_t uuid;
+
+					ndctl_namespace_get_uuid(ndns, uuid);
+					if (!ndctl_namespace_get_size(ndns) &&
+					    !memcmp(uuid, zero_uuid, sizeof(uuid_t)))
+						continue;
+				} else {
+					if (strcmp(namespace, ndns_name) != 0)
+						continue;
+				}
+
 				switch (action) {
 				case ACTION_DISABLE:
 					rc = ndctl_namespace_disable_safe(ndns);
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

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

* [PATCH ndctl rebased 2/3] ndctl/namespace: Suppress -ENXIO when processing all namespaces.
  2021-01-06 13:17 [PATCH ndctl rebased 1/3] ndctl/namespace: Skip seed namespaces when processing all namespaces Michal Suchanek
@ 2021-01-06 13:17 ` Michal Suchanek
  2021-01-06 13:17 ` [PATCH ndctl rebased 3/3] namespace-action: Drop zero namespace checks Michal Suchanek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Suchanek @ 2021-01-06 13:17 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Michal Suchanek, Harish Sriram

When processing all namespaces and no namespaces exist user gets the
default -ENXIO. Set default rc to 0 when processing all namespaces.
This avoids confusing error message printed in addition to the message
saying 0 namespaces were affected.

Before:

 # ndctl check-namespace all
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
error checking namespaces: Device or resource busy
checked 0 namespaces
 # ndctl disable-namespace all
disabled 1 namespace
 # ndctl check-namespace all
namespace0.0: namespace_check: Unable to recover any BTT info blocks
error checking namespaces: No such device or address
checked 0 namespaces
 # ndctl destroy-namespace all
destroyed 1 namespace
 # ndctl check-namespace all
error checking namespaces: No such device or address
checked 0 namespaces
 # ndctl destroy-namespace all
error destroying namespaces: No such device or address
destroyed 0 namespaces

After:

 # ndctl check-namespace all
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
error checking namespaces: Device or resource busy
checked 0 namespaces
 # ndctl disable-namespace namespace0.0
disabled 1 namespace
 # ndctl check-namespace all
namespace0.0: namespace_check: Unable to recover any BTT info blocks
error checking namespaces: No such device or address
checked 0 namespaces
 # ndctl destroy-namespace all
destroyed 1 namespace
 # ndctl check-namespace all
checked 0 namespaces
 # ndctl destroy-namespace all
destroyed 0 namespaces
 # ndctl destroy-namespace all
destroyed 0 namespaces

Note: this does change the return value from -ENXIO to 0 in the cases
when no namespaces exist and processing all namespaces was requested.

Link: https://patchwork.kernel.org/patch/11681431/
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Reviewed-by: Santosh S <santosh@fossix.org>
---
v2: fix the error code references in the commit message
---
 ndctl/namespace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index b9ffd21fe7bf..c3a058d8ff1a 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2148,6 +2148,9 @@ static int do_xaction_namespace(const char *namespace,
 	if (!namespace && action != ACTION_CREATE)
 		return rc;
 
+	if (namespace && (strcmp(namespace, "all") == 0))
+		rc = 0;
+
 	if (verbose)
 		ndctl_set_log_priority(ctx, LOG_DEBUG);
 
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

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

* [PATCH ndctl rebased 3/3] namespace-action: Drop zero namespace checks.
  2021-01-06 13:17 [PATCH ndctl rebased 1/3] ndctl/namespace: Skip seed namespaces when processing all namespaces Michal Suchanek
  2021-01-06 13:17 ` [PATCH ndctl rebased 2/3] ndctl/namespace: Suppress -ENXIO " Michal Suchanek
@ 2021-01-06 13:17 ` Michal Suchanek
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Suchanek @ 2021-01-06 13:17 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Michal Suchanek, Harish Sriram

From: Santosh Sivaraj <santosh@fossix.org>

With seed namespaces catched early on these checks for sizes in enable
and destroy namespace code path are not needed.

Reverts commit b9cb03f6d5a8 ("ndctl/namespace: Fix enable-namespace
error for seed namespaces")

Reverts commit e01045e58ad5 ("ndctl/namespace: Fix destroy-namespace
accounting relative to seed devices")

Fixes: b9cb03f6d5a8 ("ndctl/namespace: Fix enable-namespace error for seed namespaces")
Fixes: e01045e58ad5 ("ndctl/namespace: Fix destroy-namespace accounting relative to seed devices")
Link: https://patchwork.kernel.org/patch/11739975/
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
[rebased on top of the previous patches]
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 ndctl/lib/libndctl.c |  5 -----
 ndctl/namespace.c    | 10 ----------
 2 files changed, 15 deletions(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 36fb6fe0f4cf..9f50f76c57e4 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -4501,16 +4501,11 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
 	struct ndctl_region *region = ndns->region;
-	unsigned long long size = ndctl_namespace_get_size(ndns);
 	int rc;
 
 	if (ndctl_namespace_is_enabled(ndns))
 		return 0;
 
-	/* Don't try to enable idle namespace (no capacity allocated) */
-	if (size == 0)
-		return -ENXIO;
-
 	rc = ndctl_bind(ctx, ndns->module, devname);
 
 	/*
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index c3a058d8ff1a..4535372cb0f7 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -1161,15 +1161,12 @@ static int namespace_destroy(struct ndctl_region *region,
 		struct ndctl_namespace *ndns)
 {
 	const char *devname = ndctl_namespace_get_devname(ndns);
-	unsigned long long size;
 	int rc;
 
 	rc = namespace_prep_reconfig(region, ndns);
 	if (rc < 0)
 		return rc;
 
-	size = ndctl_namespace_get_size(ndns);
-
 	/* Labeled namespace, destroy label / allocation */
 	if (rc == 2) {
 		rc = ndctl_namespace_delete(ndns);
@@ -1177,13 +1174,6 @@ static int namespace_destroy(struct ndctl_region *region,
 			debug("%s: failed to reclaim\n", devname);
 	}
 
-	/*
-	 * Don't report a destroyed namespace when no capacity was
-	 * allocated.
-	 */
-	if (size == 0 && rc == 0)
-		rc = 1;
-
 	return rc;
 }
 
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

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

end of thread, other threads:[~2021-01-06 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06 13:17 [PATCH ndctl rebased 1/3] ndctl/namespace: Skip seed namespaces when processing all namespaces Michal Suchanek
2021-01-06 13:17 ` [PATCH ndctl rebased 2/3] ndctl/namespace: Suppress -ENXIO " Michal Suchanek
2021-01-06 13:17 ` [PATCH ndctl rebased 3/3] namespace-action: Drop zero namespace checks Michal Suchanek

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