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

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