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

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