All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ndctl/namespace: skip zero namespaces when processing all namespaces.
@ 2020-07-23 17:51 Michal Suchanek
  2020-07-23 17:51 ` [PATCH 2/2] ndctl/namespace: Suppress ENODEV " Michal Suchanek
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Suchanek @ 2020-07-23 17:51 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Michal Suchanek, Harish Sriram

The kernel always creates zero length namespace with uuid 0 in each
region.

When processing all namespaces the user gets confusing errors from ndctl
trying to process this namespace. Skip it.

The user can still specify the namespace by name directly in case
processing it is desirable.

Fixes: #41
Reviewed-by: Santosh S <santosh@fossix.org>
Tested-by: Harish Sriram <harish@linux.ibm.com>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 ndctl/namespace.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index e734248c9752..3fabe4799d75 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2171,9 +2171,19 @@ static int do_xaction_namespace(const char *namespace,
 			ndctl_namespace_foreach_safe(region, ndns, _n) {
 				ndns_name = ndctl_namespace_get_devname(ndns);
 
-				if (strcmp(namespace, "all") != 0
-						&& strcmp(namespace, ndns_name) != 0)
-					continue;
+				if (strcmp(namespace, "all") == 0) {
+					static const uuid_t zero_uuid;
+					uuid_t uuid;
+
+					ndctl_namespace_get_uuid(ndns, uuid);
+					if (!ndctl_namespace_get_size(ndns) &&
+					    !memcmp(uuid, zero_uuid, sizeof(uuid_t)))
+						continue;
+				} else {
+					if (strcmp(namespace, ndns_name) != 0)
+						continue;
+				}
+
 				switch (action) {
 				case ACTION_DISABLE:
 					rc = ndctl_namespace_disable_safe(ndns);
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ndctl/namespace: Suppress ENODEV when processing all namespaces.
  2020-07-23 17:51 [PATCH 1/2] ndctl/namespace: skip zero namespaces when processing all namespaces Michal Suchanek
@ 2020-07-23 17:51 ` Michal Suchanek
  2020-08-28  8:39   ` Santosh Sivaraj
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Suchanek @ 2020-07-23 17:51 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Michal Suchanek

When processing all namespaces and no namespaces exist user gets the
default -ENOENT. Set default rc to 0 when processing all namespaces.
This avoids confusing error message printed in addition to the message
saying 0 namespaces were affected.

Before:

 # ndctl check-namespace all
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
error checking namespaces: Device or resource busy
checked 0 namespaces
 # ndctl disable-namespace all
disabled 1 namespace
 # ndctl check-namespace all
namespace0.0: namespace_check: Unable to recover any BTT info blocks
error checking namespaces: No such device or address
checked 0 namespaces
 # ndctl destroy-namespace all
destroyed 1 namespace
 # ndctl check-namespace all
error checking namespaces: No such device or address
checked 0 namespaces
 # ndctl destroy-namespace all
error destroying namespaces: No such device or address
destroyed 0 namespaces

After:

 # ndctl check-namespace all
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
error checking namespaces: Device or resource busy
checked 0 namespaces
 # ndctl disable-namespace namespace0.0
disabled 1 namespace
 # ndctl check-namespace all
namespace0.0: namespace_check: Unable to recover any BTT info blocks
error checking namespaces: No such device or address
checked 0 namespaces
 # ndctl destroy-namespace all
destroyed 1 namespace
 # ndctl check-namespace all
checked 0 namespaces
 # ndctl destroy-namespace all
destroyed 0 namespaces
 # ndctl destroy-namespace all
destroyed 0 namespaces

Note: this does change the return value from -ENOENT to 0 in the cases
when no namespaces exist and processing all namespaces was requested.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 ndctl/namespace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 3fabe4799d75..835f4076008a 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2112,6 +2112,9 @@ static int do_xaction_namespace(const char *namespace,
 	if (!namespace && action != ACTION_CREATE)
 		return rc;
 
+	if (namespace && (strcmp(namespace, "all") == 0))
+		rc = 0;
+
 	if (verbose)
 		ndctl_set_log_priority(ctx, LOG_DEBUG);
 
-- 
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ndctl/namespace: Suppress ENODEV when processing all namespaces.
  2020-07-23 17:51 ` [PATCH 2/2] ndctl/namespace: Suppress ENODEV " Michal Suchanek
@ 2020-08-28  8:39   ` Santosh Sivaraj
  0 siblings, 0 replies; 3+ messages in thread
From: Santosh Sivaraj @ 2020-08-28  8:39 UTC (permalink / raw)
  To: Michal Suchanek, linux-nvdimm; +Cc: Michal Suchanek

Michal Suchanek <msuchanek@suse.de> writes:

> When processing all namespaces and no namespaces exist user gets the
> default -ENOENT. Set default rc to 0 when processing all namespaces.
> This avoids confusing error message printed in addition to the message
> saying 0 namespaces were affected.
>
> Before:
>
>  # ndctl check-namespace all
> namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
> error checking namespaces: Device or resource busy
> checked 0 namespaces
>  # ndctl disable-namespace all
> disabled 1 namespace
>  # ndctl check-namespace all
> namespace0.0: namespace_check: Unable to recover any BTT info blocks
> error checking namespaces: No such device or address
> checked 0 namespaces
>  # ndctl destroy-namespace all
> destroyed 1 namespace
>  # ndctl check-namespace all
> error checking namespaces: No such device or address
> checked 0 namespaces
>  # ndctl destroy-namespace all
> error destroying namespaces: No such device or address
> destroyed 0 namespaces
>
> After:
>
>  # ndctl check-namespace all
> namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
> error checking namespaces: Device or resource busy
> checked 0 namespaces
>  # ndctl disable-namespace namespace0.0
> disabled 1 namespace
>  # ndctl check-namespace all
> namespace0.0: namespace_check: Unable to recover any BTT info blocks
> error checking namespaces: No such device or address
> checked 0 namespaces
>  # ndctl destroy-namespace all
> destroyed 1 namespace
>  # ndctl check-namespace all
> checked 0 namespaces
>  # ndctl destroy-namespace all
> destroyed 0 namespaces
>  # ndctl destroy-namespace all
> destroyed 0 namespaces
>
> Note: this does change the return value from -ENOENT to 0 in the cases
> when no namespaces exist and processing all namespaces was requested.
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>

I missed this patch and had a different approach of solving this, fiddling
around with processed and saved_rc in the end of the function. This is
cleaner.

Nit: The default return value is -ENXIO, if that matters in the commit message.

Reviewed-by: Santosh S <santosh@fossix.org>

Thanks,
Santosh

> ---
>  ndctl/namespace.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index 3fabe4799d75..835f4076008a 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -2112,6 +2112,9 @@ static int do_xaction_namespace(const char *namespace,
>  	if (!namespace && action != ACTION_CREATE)
>  		return rc;
>  
> +	if (namespace && (strcmp(namespace, "all") == 0))
> +		rc = 0;
> +
>  	if (verbose)
>  		ndctl_set_log_priority(ctx, LOG_DEBUG);
>  
> -- 
> 2.26.2
> _______________________________________________
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-28  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 17:51 [PATCH 1/2] ndctl/namespace: skip zero namespaces when processing all namespaces Michal Suchanek
2020-07-23 17:51 ` [PATCH 2/2] ndctl/namespace: Suppress ENODEV " Michal Suchanek
2020-08-28  8:39   ` Santosh Sivaraj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.