Blame SOURCES/07011a3-ndctl-namespace-Suppress-ENXIO-when-processing-all-namespaces.patch

0dc130
ndctl/namespace: Suppress -ENXIO when processing all namespaces.
0dc130
0dc130
BZ: 
0dc130
Brew: 
0dc130
0dc130
commit 07011a334fd1e4b641cdbfaf5de7500f7bdc941d
0dc130
Author: Michal Suchanek <msuchanek@suse.de>
0dc130
Date:   Wed Jan 6 14:17:41 2021 +0100
0dc130
0dc130
    ndctl/namespace: Suppress -ENXIO when processing all namespaces.
0dc130
    
0dc130
    When processing all namespaces and no namespaces exist user gets the
0dc130
    default -ENXIO. Set default rc to 0 when processing all namespaces.
0dc130
    This avoids confusing error message printed in addition to the message
0dc130
    saying 0 namespaces were affected.
0dc130
    
0dc130
    Before:
0dc130
    
0dc130
     # ndctl check-namespace all
0dc130
    namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
0dc130
    error checking namespaces: Device or resource busy
0dc130
    checked 0 namespaces
0dc130
     # ndctl disable-namespace all
0dc130
    disabled 1 namespace
0dc130
     # ndctl check-namespace all
0dc130
    namespace0.0: namespace_check: Unable to recover any BTT info blocks
0dc130
    error checking namespaces: No such device or address
0dc130
    checked 0 namespaces
0dc130
     # ndctl destroy-namespace all
0dc130
    destroyed 1 namespace
0dc130
     # ndctl check-namespace all
0dc130
    error checking namespaces: No such device or address
0dc130
    checked 0 namespaces
0dc130
     # ndctl destroy-namespace all
0dc130
    error destroying namespaces: No such device or address
0dc130
    destroyed 0 namespaces
0dc130
    
0dc130
    After:
0dc130
    
0dc130
     # ndctl check-namespace all
0dc130
    namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
0dc130
    error checking namespaces: Device or resource busy
0dc130
    checked 0 namespaces
0dc130
     # ndctl disable-namespace namespace0.0
0dc130
    disabled 1 namespace
0dc130
     # ndctl check-namespace all
0dc130
    namespace0.0: namespace_check: Unable to recover any BTT info blocks
0dc130
    error checking namespaces: No such device or address
0dc130
    checked 0 namespaces
0dc130
     # ndctl destroy-namespace all
0dc130
    destroyed 1 namespace
0dc130
     # ndctl check-namespace all
0dc130
    checked 0 namespaces
0dc130
     # ndctl destroy-namespace all
0dc130
    destroyed 0 namespaces
0dc130
     # ndctl destroy-namespace all
0dc130
    destroyed 0 namespaces
0dc130
    
0dc130
    Note: this does change the return value from -ENXIO to 0 in the cases
0dc130
    when no namespaces exist and processing all namespaces was requested.
0dc130
    
0dc130
    Link: https://patchwork.kernel.org/patch/11681431/
0dc130
    Link: https://lore.kernel.org/r/32c8cd8d2716f5e52aebea4e4d303eeb4e0550f9.1609938610.git.msuchanek@suse.de
0dc130
    Reviewed-by: Santosh S <santosh@fossix.org>
0dc130
    Signed-off-by: Michal Suchanek <msuchanek@suse.de>
0dc130
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
0dc130
0dc130
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
0dc130
index 5e65ed5..cd822b3 100644
0dc130
--- a/ndctl/namespace.c
0dc130
+++ b/ndctl/namespace.c
0dc130
@@ -2151,6 +2151,9 @@ static int do_xaction_namespace(const char *namespace,
0dc130
 	if (!namespace && action != ACTION_CREATE)
0dc130
 		return rc;
0dc130
 
0dc130
+	if (namespace && (strcmp(namespace, "all") == 0))
0dc130
+		rc = 0;
0dc130
+
0dc130
 	if (verbose)
0dc130
 		ndctl_set_log_priority(ctx, LOG_DEBUG);
0dc130