diff mbox

[ndctl,4/6] ndctl, list: emit device-dax 'chardev' by default

Message ID 150048919740.12895.4759356543014868451.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit fb05f9495c6b
Headers show

Commit Message

Dan Williams July 19, 2017, 6:33 p.m. UTC
Commit 10663a60d723 "ndctl, list: add '--device-dax' option" tried to
cleanup the default namespace output by putting the device-dax details
behind an extra option. This was done in anticipation of device-dax
sub-division support, but the kernel has since added support for
multiple-pmem namespaces per region and limiting device-dax instances to
one per parent namespace. With the limitation in place we can directly
associate a device-dax instance with a namespace and omit the dax-region
details in ndctl.

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 util/json.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Linda Knippers July 19, 2017, 8:13 p.m. UTC | #1
On 07/19/2017 02:33 PM, Dan Williams wrote:
> Commit 10663a60d723 "ndctl, list: add '--device-dax' option" tried to
> cleanup the default namespace output by putting the device-dax details
> behind an extra option. This was done in anticipation of device-dax
> sub-division support, but the kernel has since added support for
> multiple-pmem namespaces per region and limiting device-dax instances to
> one per parent namespace. With the limitation in place we can directly
> associate a device-dax instance with a namespace and omit the dax-region
> details in ndctl.

$ ndctl list
...
  {
    "dev":"namespace7.0",
    "mode":"dax",
    "size":8453619712,
    "uuid":"c57b18aa-0c6a-4775-aa3e-e25f2a7c0c2f",
    "chardev":"dax7.0",
    "numa_node":1
  },
...


Thanks!

-- ljk
> 
> Reported-by: Linda Knippers <linda.knippers@hpe.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  util/json.c |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/util/json.c b/util/json.c
> index 80512bdabeae..25188a61064f 100644
> --- a/util/json.c
> +++ b/util/json.c
> @@ -622,18 +622,28 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
>  	} else if (dax) {
>  		struct daxctl_region *dax_region;
>  
> +		dax_region = ndctl_dax_get_daxctl_region(dax);
>  		ndctl_dax_get_uuid(dax, uuid);
>  		uuid_unparse(uuid, buf);
>  		jobj = json_object_new_string(buf);
>  		if (!jobj)
>  			goto err;
>  		json_object_object_add(jndns, "uuid", jobj);
> -		if (flags & UTIL_JSON_DAX) {
> -			dax_region = ndctl_dax_get_daxctl_region(dax);
> +		if ((flags & UTIL_JSON_DAX) && dax_region) {
>  			jobj = util_daxctl_region_to_json(dax_region, NULL,
>  					flags);
>  			if (jobj)
>  				json_object_object_add(jndns, "daxregion", jobj);
> +		} else if (dax_region) {
> +			struct daxctl_dev *dev;
> +			const char *name;
> +
> +			dev = daxctl_dev_get_first(dax_region);
> +			name = daxctl_dev_get_devname(dev);
> +			jobj = json_object_new_string(name);
> +			if (!jobj)
> +				goto err;
> +			json_object_object_add(jndns, "chardev", jobj);
>  		}
>  	} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
>  		const char *name;
>
diff mbox

Patch

diff --git a/util/json.c b/util/json.c
index 80512bdabeae..25188a61064f 100644
--- a/util/json.c
+++ b/util/json.c
@@ -622,18 +622,28 @@  struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 	} else if (dax) {
 		struct daxctl_region *dax_region;
 
+		dax_region = ndctl_dax_get_daxctl_region(dax);
 		ndctl_dax_get_uuid(dax, uuid);
 		uuid_unparse(uuid, buf);
 		jobj = json_object_new_string(buf);
 		if (!jobj)
 			goto err;
 		json_object_object_add(jndns, "uuid", jobj);
-		if (flags & UTIL_JSON_DAX) {
-			dax_region = ndctl_dax_get_daxctl_region(dax);
+		if ((flags & UTIL_JSON_DAX) && dax_region) {
 			jobj = util_daxctl_region_to_json(dax_region, NULL,
 					flags);
 			if (jobj)
 				json_object_object_add(jndns, "daxregion", jobj);
+		} else if (dax_region) {
+			struct daxctl_dev *dev;
+			const char *name;
+
+			dev = daxctl_dev_get_first(dax_region);
+			name = daxctl_dev_get_devname(dev);
+			jobj = json_object_new_string(name);
+			if (!jobj)
+				goto err;
+			json_object_object_add(jndns, "chardev", jobj);
 		}
 	} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
 		const char *name;