All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ndctl/namespace: skip zero namespaces when processing
@ 2020-04-03 21:05 Michal Suchanek
  2020-04-06 11:39 ` Santosh Sivaraj
  2020-04-06 11:41 ` Harish
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Suchanek @ 2020-04-03 21:05 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Michal Suchanek, jack

Hello,

this is a fix for github issue #41. I tested on system with vpmem with
ndctl 64.1 that the issue is fixed. master builds with the fix applied.

8<-------------------------------------------------------------------->8

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

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 0550580707e8..6f4a4b5b8883 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2128,9 +2128,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.23.0
_______________________________________________
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

* Re: [PATCH] ndctl/namespace: skip zero namespaces when processing
  2020-04-03 21:05 [PATCH] ndctl/namespace: skip zero namespaces when processing Michal Suchanek
@ 2020-04-06 11:39 ` Santosh Sivaraj
  2020-04-06 11:41 ` Harish
  1 sibling, 0 replies; 3+ messages in thread
From: Santosh Sivaraj @ 2020-04-06 11:39 UTC (permalink / raw)
  To: Michal Suchanek, linux-nvdimm; +Cc: Michal Suchanek, jack

Michal Suchanek <msuchanek@suse.de> writes:

> Hello,
>
> this is a fix for github issue #41. I tested on system with vpmem with
> ndctl 64.1 that the issue is fixed. master builds with the fix applied.
>
> 8<-------------------------------------------------------------------->8
>
> 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
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  ndctl/namespace.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)

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

Tested on a vpmem system with master branch, and I can see the issue got fixed.

# ./ndctl/ndctl enable-namespace all
error enabling namespaces: No such device or address
enabled 24 namespaces

After this patch

# ./ndctl/ndctl enable-namespace all 
enabled 24 namespaces

Thanks,
Santosh

>
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index 0550580707e8..6f4a4b5b8883 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -2128,9 +2128,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.23.0
_______________________________________________
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

* Re: [PATCH] ndctl/namespace: skip zero namespaces when processing
  2020-04-03 21:05 [PATCH] ndctl/namespace: skip zero namespaces when processing Michal Suchanek
  2020-04-06 11:39 ` Santosh Sivaraj
@ 2020-04-06 11:41 ` Harish
  1 sibling, 0 replies; 3+ messages in thread
From: Harish @ 2020-04-06 11:41 UTC (permalink / raw)
  To: Michal Suchanek, linux-nvdimm; +Cc: jack

Tested-by: Harish Sriram <harish@linux.ibm.com>


On 4/4/20 2:35 AM, Michal Suchanek wrote:
> Hello,
>
> this is a fix for github issue #41. I tested on system with vpmem with
> ndctl 64.1 that the issue is fixed. master builds with the fix applied.
>
> 8<-------------------------------------------------------------------->8
>
> 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
>
> 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 0550580707e8..6f4a4b5b8883 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -2128,9 +2128,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);
_______________________________________________
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-04-06 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 21:05 [PATCH] ndctl/namespace: skip zero namespaces when processing Michal Suchanek
2020-04-06 11:39 ` Santosh Sivaraj
2020-04-06 11:41 ` Harish

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.