Blame SOURCES/9bd2994-ndctl-namespace-Skip-seed-namespaces-when-processing-all-namespaces.patch

0670da
ndctl/namespace: Skip seed namespaces when processing all namespaces.
0670da
0670da
BZ: 
0670da
Brew: 
0670da
0670da
commit 9bd2994f91bb77604521cbe09a76a51d092c2cfd
0670da
Author: Michal Suchanek <msuchanek@suse.de>
0670da
Date:   Wed Jan 6 14:17:40 2021 +0100
0670da
0670da
    ndctl/namespace: Skip seed namespaces when processing all namespaces.
0670da
    
0670da
    The seed namespaces are exposed by the kernel but most operations are
0670da
    not valid on seed namespaces.
0670da
    
0670da
    When processing all namespaces the user gets confusing errors from ndctl
0670da
    trying to process seed namespaces. The kernel does not provide any way
0670da
    to tell that a namspace is seed namespace but skipping namespaces with
0670da
    zero size and UUID is a good heuristic.
0670da
    
0670da
    The user can still specify the namespace by name directly in case
0670da
    processing it is desirable.
0670da
    
0670da
    Link: https://patchwork.kernel.org/patch/11473645/
0670da
    Link: https://lore.kernel.org/r/e55ae2c17b8b9c3288491efe6214338118e8c5ae.1609938610.git.msuchanek@suse.de
0670da
    Fixes: #41
0670da
    Tested-by: Harish Sriram <harish@linux.ibm.com>
0670da
    Reviewed-by: Santosh S <santosh@fossix.org>
0670da
    Signed-off-by: Michal Suchanek <msuchanek@suse.de>
0670da
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
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);