diff mbox

[ndctl] ndctl: support machines without numa

Message ID 148357532903.9100.4272827749663933501.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams Jan. 5, 2017, 12:15 a.m. UTC
From: Diego Dompe <dompe@hpe.com>

Currently when using ndctl in machines that do not have numa, the ndctl
command fails because it fails to find the numa_node attribute in
systems.

Just assume the default, zero, in these cases rather than fail.

Link: https://github.com/pmem/ndctl/pull/9
[djbw: minor style fixups]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---

Diego, if this reworked version looks good to you I'll add your
"Signed-off-by: Diego Dompe <dompe@hpe.com>" to the tags. Let me know.
Thanks for the fix!

 ndctl/lib/libndctl.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Jeff Moyer Jan. 5, 2017, 2:55 p.m. UTC | #1
Dan Williams <dan.j.williams@intel.com> writes:

> From: Diego Dompe <dompe@hpe.com>
>
> Currently when using ndctl in machines that do not have numa, the ndctl
> command fails because it fails to find the numa_node attribute in
> systems.

s/machines that do not have numa/kernels compiled with CONFIG_NUMA=n/

I don't know that this was the right decision for the kernel, but that
ship's sailed.

> Just assume the default, zero, in these cases rather than fail.

Looks fine to me.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

>
> Link: https://github.com/pmem/ndctl/pull/9
> [djbw: minor style fixups]
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>
> Diego, if this reworked version looks good to you I'll add your
> "Signed-off-by: Diego Dompe <dompe@hpe.com>" to the tags. Let me know.
> Thanks for the fix!
>
>  ndctl/lib/libndctl.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
> index ea3111eb6c93..8240235dff5c 100644
> --- a/ndctl/lib/libndctl.c
> +++ b/ndctl/lib/libndctl.c
> @@ -2780,9 +2780,8 @@ static void *add_namespace(void *parent, int id, const char *ndns_base)
>  	ndns->raw_mode = strtoul(buf, NULL, 0);
>  
>  	sprintf(path, "%s/numa_node", ndns_base);
> -	if (sysfs_read_attr(ctx, path, buf) < 0)
> -		goto err_read;
> -	ndns->numa_node = strtol(buf, NULL, 0);
> +	if (sysfs_read_attr(ctx, path, buf) == 0)
> +		ndns->numa_node = strtol(buf, NULL, 0);
>  
>  	switch (ndns->type) {
>  	case ND_DEVICE_NAMESPACE_BLK:
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
diff mbox

Patch

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index ea3111eb6c93..8240235dff5c 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -2780,9 +2780,8 @@  static void *add_namespace(void *parent, int id, const char *ndns_base)
 	ndns->raw_mode = strtoul(buf, NULL, 0);
 
 	sprintf(path, "%s/numa_node", ndns_base);
-	if (sysfs_read_attr(ctx, path, buf) < 0)
-		goto err_read;
-	ndns->numa_node = strtol(buf, NULL, 0);
+	if (sysfs_read_attr(ctx, path, buf) == 0)
+		ndns->numa_node = strtol(buf, NULL, 0);
 
 	switch (ndns->type) {
 	case ND_DEVICE_NAMESPACE_BLK: