Blame SOURCES/0029-ndctl-namespace-Suppress-ENXIO-when-processing-all-n.patch

2eb93d
From 07011a334fd1e4b641cdbfaf5de7500f7bdc941d Mon Sep 17 00:00:00 2001
2eb93d
From: Michal Suchanek <msuchanek@suse.de>
2eb93d
Date: Wed, 6 Jan 2021 14:17:41 +0100
2eb93d
Subject: [PATCH 029/217] ndctl/namespace: Suppress -ENXIO when processing all
2eb93d
 namespaces.
8afcf0
2eb93d
When processing all namespaces and no namespaces exist user gets the
2eb93d
default -ENXIO. Set default rc to 0 when processing all namespaces.
2eb93d
This avoids confusing error message printed in addition to the message
2eb93d
saying 0 namespaces were affected.
8afcf0
2eb93d
Before:
8afcf0
2eb93d
 # ndctl check-namespace all
2eb93d
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
2eb93d
error checking namespaces: Device or resource busy
2eb93d
checked 0 namespaces
2eb93d
 # ndctl disable-namespace all
2eb93d
disabled 1 namespace
2eb93d
 # ndctl check-namespace all
2eb93d
namespace0.0: namespace_check: Unable to recover any BTT info blocks
2eb93d
error checking namespaces: No such device or address
2eb93d
checked 0 namespaces
2eb93d
 # ndctl destroy-namespace all
2eb93d
destroyed 1 namespace
2eb93d
 # ndctl check-namespace all
2eb93d
error checking namespaces: No such device or address
2eb93d
checked 0 namespaces
2eb93d
 # ndctl destroy-namespace all
2eb93d
error destroying namespaces: No such device or address
2eb93d
destroyed 0 namespaces
2eb93d
2eb93d
After:
2eb93d
2eb93d
 # ndctl check-namespace all
2eb93d
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
2eb93d
error checking namespaces: Device or resource busy
2eb93d
checked 0 namespaces
2eb93d
 # ndctl disable-namespace namespace0.0
2eb93d
disabled 1 namespace
2eb93d
 # ndctl check-namespace all
2eb93d
namespace0.0: namespace_check: Unable to recover any BTT info blocks
2eb93d
error checking namespaces: No such device or address
2eb93d
checked 0 namespaces
2eb93d
 # ndctl destroy-namespace all
2eb93d
destroyed 1 namespace
2eb93d
 # ndctl check-namespace all
2eb93d
checked 0 namespaces
2eb93d
 # ndctl destroy-namespace all
2eb93d
destroyed 0 namespaces
2eb93d
 # ndctl destroy-namespace all
2eb93d
destroyed 0 namespaces
2eb93d
2eb93d
Note: this does change the return value from -ENXIO to 0 in the cases
2eb93d
when no namespaces exist and processing all namespaces was requested.
2eb93d
2eb93d
Link: https://patchwork.kernel.org/patch/11681431/
2eb93d
Link: https://lore.kernel.org/r/32c8cd8d2716f5e52aebea4e4d303eeb4e0550f9.1609938610.git.msuchanek@suse.de
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 | 3 +++
2eb93d
 1 file changed, 3 insertions(+)
8afcf0
8afcf0
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
8afcf0
index 5e65ed5..cd822b3 100644
8afcf0
--- a/ndctl/namespace.c
8afcf0
+++ b/ndctl/namespace.c
8afcf0
@@ -2151,6 +2151,9 @@ static int do_xaction_namespace(const char *namespace,
8afcf0
 	if (!namespace && action != ACTION_CREATE)
8afcf0
 		return rc;
8afcf0
 
8afcf0
+	if (namespace && (strcmp(namespace, "all") == 0))
8afcf0
+		rc = 0;
8afcf0
+
8afcf0
 	if (verbose)
8afcf0
 		ndctl_set_log_priority(ctx, LOG_DEBUG);
8afcf0
 
2eb93d
-- 
2eb93d
2.27.0
2eb93d