The namespaceX.Y/resource attribute returns -1 while the namespace does not have capacity allocated. While it is valid after setting the size the library has already cached the error value. Teach ndctl_namespace_set_size() to refresh ->resource.
Signed-off-by: Dan Williams <[email protected]> --- ndctl/lib/libndctl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index a996bff66fb2..ee737cbbfe3e 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -4484,6 +4484,24 @@ static int namespace_set_size(struct ndctl_namespace *ndns, return rc; ndns->size = size; + + /* + * A size change event invalidates / establishes 'resource', try + * to refresh it. + */ + if (snprintf(path, len, "%s/resource", ndns->ndns_path) >= len) { + err(ctx, "%s: buffer too small!\n", + ndctl_namespace_get_devname(ndns)); + ndns->resource = ULLONG_MAX; + return 0; + } + + if (sysfs_read_attr(ctx, path, buf) < 0) { + ndns->resource = ULLONG_MAX; + return 0; + } + + ndns->resource = strtoull(buf, NULL, 0); return 0; } _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
