Message ID | 20200110082017.3485529-1-santosh@fossix.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [ndctl] ndctl/namespace: Fix enable-namespace error for seed namespaces | expand |
On Fri, Jan 10, 2020 at 12:21 AM Santosh Sivaraj <santosh@fossix.org> wrote: > > '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(+) > > diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c > index 6596f94..4839214 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 -1; Concept looks good to me, just resend with that -1 changed to a named error code (-ENXIO).
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 6596f94..4839214 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 -1; + rc = ndctl_bind(ctx, ndns->module, devname); /*
'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(+)