Blame SOURCES/0028-ndctl-namespace-Skip-seed-namespaces-when-processing.patch

26ccd9
From 9bd2994f91bb77604521cbe09a76a51d092c2cfd Mon Sep 17 00:00:00 2001
26ccd9
From: Michal Suchanek <msuchanek@suse.de>
26ccd9
Date: Wed, 6 Jan 2021 14:17:40 +0100
26ccd9
Subject: [PATCH 028/217] ndctl/namespace: Skip seed namespaces when processing
26ccd9
 all namespaces.
0670da
26ccd9
The seed namespaces are exposed by the kernel but most operations are
26ccd9
not valid on seed namespaces.
0670da
26ccd9
When processing all namespaces the user gets confusing errors from ndctl
26ccd9
trying to process seed namespaces. The kernel does not provide any way
26ccd9
to tell that a namspace is seed namespace but skipping namespaces with
26ccd9
zero size and UUID is a good heuristic.
0670da
26ccd9
The user can still specify the namespace by name directly in case
26ccd9
processing it is desirable.
26ccd9
26ccd9
Link: https://patchwork.kernel.org/patch/11473645/
26ccd9
Link: https://lore.kernel.org/r/e55ae2c17b8b9c3288491efe6214338118e8c5ae.1609938610.git.msuchanek@suse.de
26ccd9
Fixes: #41
26ccd9
Tested-by: Harish Sriram <harish@linux.ibm.com>
26ccd9
Reviewed-by: Santosh S <santosh@fossix.org>
26ccd9
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
26ccd9
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
26ccd9
---
26ccd9
 ndctl/namespace.c | 16 +++++++++++++---
26ccd9
 1 file changed, 13 insertions(+), 3 deletions(-)
0670da
0670da
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
0670da
index 1e8a2cd..5e65ed5 100644
0670da
--- a/ndctl/namespace.c
0670da
+++ b/ndctl/namespace.c
0670da
@@ -2210,9 +2210,19 @@ static int do_xaction_namespace(const char *namespace,
0670da
 			ndctl_namespace_foreach_safe(region, ndns, _n) {
0670da
 				ndns_name = ndctl_namespace_get_devname(ndns);
0670da
 
0670da
-				if (strcmp(namespace, "all") != 0
0670da
-						&& strcmp(namespace, ndns_name) != 0)
0670da
-					continue;
0670da
+				if (strcmp(namespace, "all") == 0) {
0670da
+					static const uuid_t zero_uuid;
0670da
+					uuid_t uuid;
0670da
+
0670da
+					ndctl_namespace_get_uuid(ndns, uuid);
0670da
+					if (!ndctl_namespace_get_size(ndns) &&
0670da
+					    !memcmp(uuid, zero_uuid, sizeof(uuid_t)))
0670da
+						continue;
0670da
+				} else {
0670da
+					if (strcmp(namespace, ndns_name) != 0)
0670da
+						continue;
0670da
+				}
0670da
+
0670da
 				switch (action) {
0670da
 				case ACTION_DISABLE:
0670da
 					rc = ndctl_namespace_disable_safe(ndns);
26ccd9
-- 
26ccd9
2.27.0
26ccd9