diff mbox series

ndctl: Avoid confusing error message when operating on all the namespaces

Message ID 20210708100104.168348-1-aneesh.kumar@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series ndctl: Avoid confusing error message when operating on all the namespaces | expand

Commit Message

Aneesh Kumar K.V July 8, 2021, 10:01 a.m. UTC
With only seed namespace present, ndctl results in confusing error messages as
below.

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

ndctl# ./ndctl/ndctl  disable-namespace all
disabled 3 namespaces

ndctl# ./ndctl/ndctl  destroy-namespace all -f
  Error: destroy namespace: namespace1.0 failed to enable for zeroing, continuing

  Error: destroy namespace: namespace1.1 failed to enable for zeroing, continuing

  Error: destroy namespace: namespace0.0 failed to enable for zeroing, continuing

destroyed 0 namespaces
ndctl#

With the patch we get
ndctl# ./ndctl/ndctl  disable-namespace all
disabled 0 namespaces

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

ndctl# ./ndctl/ndctl  destroy-namespace all -f
destroyed 0 namespaces
ndctl#

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 ndctl/namespace.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Yi Zhang July 13, 2021, 12:19 a.m. UTC | #1
Jeff had posted one patch to fix similar issue
https://lore.kernel.org/linux-nvdimm/x49r1lohpty.fsf@segfault.boston.devel.redhat.com/T/#u

Hi Dan/Visha
Could we make some progress on this issue?


On Thu, Jul 8, 2021 at 6:41 PM Aneesh Kumar K.V
<aneesh.kumar@linux.ibm.com> wrote:
>
> With only seed namespace present, ndctl results in confusing error messages as
> below.
>
> ndctl# ./ndctl/ndctl  enable-namespace all
> error enabling namespaces: No such device or address
> enabled 0 namespaces
>
> ndctl# ./ndctl/ndctl  disable-namespace all
> disabled 3 namespaces
>
> ndctl# ./ndctl/ndctl  destroy-namespace all -f
>   Error: destroy namespace: namespace1.0 failed to enable for zeroing, continuing
>
>   Error: destroy namespace: namespace1.1 failed to enable for zeroing, continuing
>
>   Error: destroy namespace: namespace0.0 failed to enable for zeroing, continuing
>
> destroyed 0 namespaces
> ndctl#
>
> With the patch we get
> ndctl# ./ndctl/ndctl  disable-namespace all
> disabled 0 namespaces
>
> ndctl# ./ndctl/ndctl  enable-namespace all
> enabled 0 namespaces
>
> ndctl# ./ndctl/ndctl  destroy-namespace all -f
> destroyed 0 namespaces
> ndctl#
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>  ndctl/namespace.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index 0c8df9fa8b47..c52daeae562a 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -2205,8 +2205,15 @@ static int do_xaction_namespace(const char *namespace,
>                                 return rc;
>                         }
>                         ndctl_namespace_foreach_safe(region, ndns, _n) {
> -                               ndns_name = ndctl_namespace_get_devname(ndns);
>
> +                               if (!strcmp(namespace, "all")
> +                                               && !ndctl_namespace_get_size(ndns)) {
> +                                       if (!*processed && rc)
> +                                               rc  = 0;
> +                                       continue;
> +                               }
> +
> +                               ndns_name = ndctl_namespace_get_devname(ndns);
>                                 if (strcmp(namespace, "all") != 0
>                                                 && strcmp(namespace, ndns_name) != 0)
>                                         continue;
> --
> 2.31.1
>
>
Aneesh Kumar K.V July 13, 2021, 4:14 a.m. UTC | #2
On 7/13/21 5:49 AM, Yi Zhang wrote:
> Jeff had posted one patch to fix similar issue
> https://lore.kernel.org/linux-nvdimm/x49r1lohpty.fsf@segfault.boston.devel.redhat.com/T/#u
> 

I missed that patch. I am wondering whether that would result in ndctl 
not reporting error when we use the seed namespace name directly with 
destroy-namespace command

> Hi Dan/Visha
> Could we make some progress on this issue?
> 
> 
> On Thu, Jul 8, 2021 at 6:41 PM Aneesh Kumar K.V
> <aneesh.kumar@linux.ibm.com> wrote:
>>
>> With only seed namespace present, ndctl results in confusing error messages as
>> below.
>>
>> ndctl# ./ndctl/ndctl  enable-namespace all
>> error enabling namespaces: No such device or address
>> enabled 0 namespaces
>>
>> ndctl# ./ndctl/ndctl  disable-namespace all
>> disabled 3 namespaces
>>
>> ndctl# ./ndctl/ndctl  destroy-namespace all -f
>>    Error: destroy namespace: namespace1.0 failed to enable for zeroing, continuing
>>
>>    Error: destroy namespace: namespace1.1 failed to enable for zeroing, continuing
>>
>>    Error: destroy namespace: namespace0.0 failed to enable for zeroing, continuing
>>
>> destroyed 0 namespaces
>> ndctl#
>>
>> With the patch we get
>> ndctl# ./ndctl/ndctl  disable-namespace all
>> disabled 0 namespaces
>>
>> ndctl# ./ndctl/ndctl  enable-namespace all
>> enabled 0 namespaces
>>
>> ndctl# ./ndctl/ndctl  destroy-namespace all -f
>> destroyed 0 namespaces
>> ndctl#
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>> ---
>>   ndctl/namespace.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
>> index 0c8df9fa8b47..c52daeae562a 100644
>> --- a/ndctl/namespace.c
>> +++ b/ndctl/namespace.c
>> @@ -2205,8 +2205,15 @@ static int do_xaction_namespace(const char *namespace,
>>                                  return rc;
>>                          }
>>                          ndctl_namespace_foreach_safe(region, ndns, _n) {
>> -                               ndns_name = ndctl_namespace_get_devname(ndns);
>>
>> +                               if (!strcmp(namespace, "all")
>> +                                               && !ndctl_namespace_get_size(ndns)) {
>> +                                       if (!*processed && rc)
>> +                                               rc  = 0;
>> +                                       continue;
>> +                               }
>> +
>> +                               ndns_name = ndctl_namespace_get_devname(ndns);
>>                                  if (strcmp(namespace, "all") != 0
>>                                                  && strcmp(namespace, ndns_name) != 0)
>>                                          continue;
>> --
>> 2.31.1
>>
>>
> 
>
Dan Williams July 13, 2021, 5:16 a.m. UTC | #3
On Mon, Jul 12, 2021 at 5:20 PM Yi Zhang <yi.zhang@redhat.com> wrote:
>
> Jeff had posted one patch to fix similar issue
> https://lore.kernel.org/linux-nvdimm/x49r1lohpty.fsf@segfault.boston.devel.redhat.com/T/#u
>
> Hi Dan/Visha
> Could we make some progress on this issue?

Apologies, we had some internal administrivia to address, but are
getting back to regular releases now and catching up on the backlog.
Yi Zhang July 15, 2021, 3:39 a.m. UTC | #4
On Tue, Jul 13, 2021 at 1:16 PM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Mon, Jul 12, 2021 at 5:20 PM Yi Zhang <yi.zhang@redhat.com> wrote:
> >
> > Jeff had posted one patch to fix similar issue
> > https://lore.kernel.org/linux-nvdimm/x49r1lohpty.fsf@segfault.boston.devel.redhat.com/T/#u
> >
> > Hi Dan/Visha
> > Could we make some progress on this issue?
>
> Apologies, we had some internal administrivia to address, but are
> getting back to regular releases now and catching up on the backlog.
>

No worries, thanks for the update :)
Aneesh Kumar K.V Sept. 13, 2021, 4:57 a.m. UTC | #5
Dan Williams <dan.j.williams@intel.com> writes:

> On Mon, Jul 12, 2021 at 5:20 PM Yi Zhang <yi.zhang@redhat.com> wrote:
>>
>> Jeff had posted one patch to fix similar issue
>> https://lore.kernel.org/linux-nvdimm/x49r1lohpty.fsf@segfault.boston.devel.redhat.com/T/#u
>>
>> Hi Dan/Visha
>> Could we make some progress on this issue?
>
> Apologies, we had some internal administrivia to address, but are
> getting back to regular releases now and catching up on the backlog.

Any update on this patch? Without this I get failures with 
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/memory/ndctl.py
because the return status is 1 for disable-namespace command with only
seed namespace.

-aneesh
diff mbox series

Patch

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 0c8df9fa8b47..c52daeae562a 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2205,8 +2205,15 @@  static int do_xaction_namespace(const char *namespace,
 				return rc;
 			}
 			ndctl_namespace_foreach_safe(region, ndns, _n) {
-				ndns_name = ndctl_namespace_get_devname(ndns);
 
+				if (!strcmp(namespace, "all")
+						&& !ndctl_namespace_get_size(ndns)) {
+					if (!*processed && rc)
+						rc  = 0;
+					continue;
+				}
+
+				ndns_name = ndctl_namespace_get_devname(ndns);
 				if (strcmp(namespace, "all") != 0
 						&& strcmp(namespace, ndns_name) != 0)
 					continue;