diff mbox series

[v2,ndctl] ndctl/namespace: Fix enable-namespace error for seed namespaces

Message ID 20200113042453.3579711-1-santosh@fossix.org (mailing list archive)
State Accepted
Commit b9cb03f6d5a8654bf53e6538b60d4b63beb761d4
Headers show
Series [v2,ndctl] ndctl/namespace: Fix enable-namespace error for seed namespaces | expand

Commit Message

Santosh Sivaraj Jan. 13, 2020, 4:24 a.m. UTC
'ndctl enable-namespace all' tries to enable seed namespaces too, which results
in a error like

libndctl: ndctl_namespace_enable: namespace1.0: failed to enable

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 ndctl/lib/libndctl.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Santosh Sivaraj Feb. 20, 2020, 3:53 a.m. UTC | #1
Santosh Sivaraj <santosh@fossix.org> writes:

> 'ndctl enable-namespace all' tries to enable seed namespaces too, which results
> in a error like
>
> libndctl: ndctl_namespace_enable: namespace1.0: failed to enable

Dan/Vishal,

Will this patch be taken in the next ndctl release?

Thanks,
Santosh

>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
>  ndctl/lib/libndctl.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
> index 6596f94..9c6ccb8 100644
> --- a/ndctl/lib/libndctl.c
> +++ b/ndctl/lib/libndctl.c
> @@ -4010,11 +4010,16 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
>  	const char *devname = ndctl_namespace_get_devname(ndns);
>  	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
>  	struct ndctl_region *region = ndns->region;
> +	unsigned long long size = ndctl_namespace_get_size(ndns);
>  	int rc;
>  
>  	if (ndctl_namespace_is_enabled(ndns))
>  		return 0;
>  
> +	/* Don't try to enable idle namespace (no capacity allocated) */
> +	if (size == 0)
> +		return -ENXIO;
> +
>  	rc = ndctl_bind(ctx, ndns->module, devname);
>  
>  	/*
> -- 
> 2.24.1
Dan Williams Feb. 20, 2020, 4:08 a.m. UTC | #2
On Wed, Feb 19, 2020 at 7:53 PM Santosh Sivaraj <santosh@fossix.org> wrote:
>
> Santosh Sivaraj <santosh@fossix.org> writes:
>
> > 'ndctl enable-namespace all' tries to enable seed namespaces too, which results
> > in a error like
> >
> > libndctl: ndctl_namespace_enable: namespace1.0: failed to enable
>
> Dan/Vishal,
>
> Will this patch be taken in the next ndctl release?

Thanks for the reminder. I've picked this up.
diff mbox series

Patch

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 6596f94..9c6ccb8 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -4010,11 +4010,16 @@  NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
 	struct ndctl_region *region = ndns->region;
+	unsigned long long size = ndctl_namespace_get_size(ndns);
 	int rc;
 
 	if (ndctl_namespace_is_enabled(ndns))
 		return 0;
 
+	/* Don't try to enable idle namespace (no capacity allocated) */
+	if (size == 0)
+		return -ENXIO;
+
 	rc = ndctl_bind(ctx, ndns->module, devname);
 
 	/*