Skip to contentSkip to conversation

ndctl/list: display region caps for any of BTT, PFN, DAX

PATCH In review Donet Tom 5 participants 8 messages Feb 20, 2025 – Feb 27, 2025 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Donet Tom

author
#0 lore raw

PATCH v2 1/1 ndctl/list: display region caps for any of BTT, PFN, DAX

If any one of BTT, PFN, or DAX is not present, but the other two are, then the region capabilities are not displayed in the ndctl list -R -C command.

This is because util_region_capabilities_to_json() returns NULL if any one of BTT, PFN, or DAX is not present.

In this patch, we have changed the logic to display all the region capabilities that are present.

Test Results with CONFIG_BTT disabled
=====================================
Without this patch
------------------

 # ./ndctl list -R -C
 [
  {
    "dev":"region1",
    "size":12884901888,
    "align":16777216,
    "available_size":11257511936,
    "max_available_extent":9630121984,
    "type":"pmem",
    "iset_id":14748366918514061582,
    "persistence_domain":"unknown"
  },

With this patch
---------------

 # ./ndctl list -R -C
 [
  {
    "dev":"region1",
    "size":12884901888,
    "align":16777216,
    "available_size":11257511936,
    "max_available_extent":9630121984,
    "type":"pmem",
    "iset_id":14748366918514061582,
    "capabilities":[
      {
        "mode":"fsdax",
        "alignments":[
          65536,
          2097152,
          1073741824
        ]
      },
      {
        "mode":"devdax",
        "alignments":[
          65536,
          2097152,
          1073741824
        ]
      }
    ],
    "persistence_domain":"unknown"
  },

v1 -> v2:
Addressed the review comments from Jeff and Alison.

v1:
https://lore.kernel.org/all/[email protected]/

Fixes 965fa02e372f ("util: Distribute 'filter' and 'json' helpers to per-tool objects")
---
 ndctl/json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ndctl/json.c +1 -1
index 23bad7f..7646882 100644
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
 	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
 	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
 
-	if (!btt || !pfn || !dax)
+	if (!btt && !pfn && !dax)
 		return NULL;
 
 	jcaps = json_object_new_array();
Signature · 1 line
2.47.1
Reviewed-by on v2 1/1
#1 lore raw

ndctl/json.c struct json_object *util_region_capabilities_to_json(struct ndctl_region *region · line 387

Quoted 13 lines
ndctl/json.c +1 -1
index 23bad7f..7646882 100644
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
 	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
 	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
 
-	if (!btt || !pfn || !dax)
+	if (!btt && !pfn && !dax)
 		return NULL;
 
 	jcaps = json_object_new_array();
#2 lore raw
Quoted 8 lines · Jeff Moyer
Quoted 8 lines
ndctl/json.c +0 -0
index 23bad7f..7646882 100644
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
  	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
  	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
 
Quoted 7 lines

ndctl/json.c struct json_object *util_region_capabilities_to_json(struct ndctl_region *region · line 387

Quoted 5 lines
ndctl/json.c +1 -1
-	if (!btt || !pfn || !dax)
+	if (!btt && !pfn && !dax)
  		return NULL;
 
  	jcaps = json_object_new_array();

Thanks Jeff

Hi Alison

Should I send a v3 with Reviewed-by tag or will you take the patch with the tag?

Thanks
Donet

Quoted 1 line
#3 lore raw
Quoted 15 lines · Donet Tom
Quoted 4 lines · Jeff Moyer
Quoted 4 lines
ndctl/json.c +0 -0
index 23bad7f..7646882 100644
Quoted 9 lines

ndctl/json.c struct json_object *util_region_capabilities_to_json(struct ndctl_region *region · line 385

Quoted 7 lines
ndctl/json.c +1 -1
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
       struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
       struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
-    if (!btt || !pfn || !dax)
+    if (!btt && !pfn && !dax)
           return NULL;
       jcaps = json_object_new_array();
Quoted 6 lines

Thanks Jeff

Hi Alison

Should I send a v3 with Reviewed-by tag

Generally speaking, there is no need for you to do this.

A small tip might be helpful if you send a patch next time.

Quoted 6 lines
Quoted 6 lines

v1 -> v2:
Addressed the review comments from Jeff and Alison.

v1:
https://lore.kernel.org/all/[email protected]/

Commit messages that are not intended to appear in the upstream git tree should be placed after the '---' marker. [0]

[0] https://docs.kernel.org/process/submitting-patches.html#commentary

Thanks
Zhijian

Quoted 7 lines

or will you take the patch with the tag?

Thanks
Donet

Quoted 1 line
#4 lore raw
Quoted 26 lines · Zhijian Li (Fujitsu)
Quoted 14 lines · Donet Tom
Quoted 4 lines · Jeff Moyer
Quoted 4 lines
ndctl/json.c +0 -0
index 23bad7f..7646882 100644
Quoted 9 lines

ndctl/json.c struct json_object *util_region_capabilities_to_json(struct ndctl_region *region · line 385

Quoted 7 lines
ndctl/json.c +1 -1
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
       struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
       struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
-    if (!btt || !pfn || !dax)
+    if (!btt && !pfn && !dax)
           return NULL;
       jcaps = json_object_new_array();
Quoted 6 lines

Thanks Jeff

Hi Alison

Should I send a v3 with Reviewed-by tag

Generally speaking, there is no need for you to do this.

A small tip might be helpful if you send a patch next time.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

v1 -> v2:
Addressed the review comments from Jeff and Alison.

v1:
https://lore.kernel.org/all/[email protected]/

Commit messages that are not intended to appear in the upstream git tree should be placed after the '---' marker. [0]

Thanks Zhijian. I will take care of this from now on.

Thanks
Donet

Quoted 11 lines

[0] https://docs.kernel.org/process/submitting-patches.html#commentary

Thanks
Zhijian

Quoted 5 lines

or will you take the patch with the tag?

Thanks
Donet

maintainer
#5 lore raw
In reply to Donet Tom
Quoted 15 lines · Donet Tom
Quoted 4 lines · Jeff Moyer
Quoted 4 lines
ndctl/json.c +0 -0
index 23bad7f..7646882 100644
Quoted 9 lines

ndctl/json.c struct json_object *util_region_capabilities_to_json(struct ndctl_region *region · line 385

Quoted 7 lines
ndctl/json.c +1 -1
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
  	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
  	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
-	if (!btt || !pfn || !dax)
+	if (!btt && !pfn && !dax)
  		return NULL;
  	jcaps = json_object_new_array();
Quoted 7 lines

Thanks Jeff

Hi Alison

Should I send a v3 with Reviewed-by tag or will you take the patch with the tag?

No need. The tags with gather automagically upon applying. I'll also rm the text meant for below the --- like Zhijian noted.

Thanks for the patch!

Quoted 5 lines

Thanks
Donet

Quoted 1 line
#6 lore raw
Quoted 18 lines · Alison Schofield
Quoted 17 lines · Donet Tom
Quoted 4 lines · Jeff Moyer
Quoted 4 lines
ndctl/json.c +0 -0
index 23bad7f..7646882 100644
Quoted 9 lines

ndctl/json.c struct json_object *util_region_capabilities_to_json(struct ndctl_region *region · line 385

Quoted 7 lines
ndctl/json.c +1 -1
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
   	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
   	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
-	if (!btt || !pfn || !dax)
+	if (!btt && !pfn && !dax)
   		return NULL;
   	jcaps = json_object_new_array();

Thanks Jeff

Quoted 6 lines
Quoted 4 lines

Hi Alison

Should I send a v3 with Reviewed-by tag or will you take the patch with the tag?

No need. The tags with gather automagically upon applying. I'll also rm the text meant for below the --- like Zhijian noted.

Thank you.

Quoted 7 lines

Thanks for the patch!

Quoted 3 lines

Thanks
Donet

Reviewed-by Tested-by on v2 1/1
#7 lore raw
In reply to Donet Tom
Quoted 60 lines · Donet Tom

If any one of BTT, PFN, or DAX is not present, but the other two are, then the region capabilities are not displayed in the ndctl list -R -C command.

This is because util_region_capabilities_to_json() returns NULL if any one of BTT, PFN, or DAX is not present.

In this patch, we have changed the logic to display all the region capabilities that are present.

Test Results with CONFIG_BTT disabled
=====================================
Without this patch
------------------

  # ./ndctl list -R -C
  [
   {
     "dev":"region1",
     "size":12884901888,
     "align":16777216,
     "available_size":11257511936,
     "max_available_extent":9630121984,
     "type":"pmem",
     "iset_id":14748366918514061582,
     "persistence_domain":"unknown"
   },

With this patch
---------------

  # ./ndctl list -R -C
  [
   {
     "dev":"region1",
     "size":12884901888,
     "align":16777216,
     "available_size":11257511936,
     "max_available_extent":9630121984,
     "type":"pmem",
     "iset_id":14748366918514061582,
     "capabilities":[
       {
         "mode":"fsdax",
         "alignments":[
           65536,
           2097152,
           1073741824
         ]
       },
       {
         "mode":"devdax",
         "alignments":[
           65536,
           2097152,
           1073741824
         ]
       }
     ],
     "persistence_domain":"unknown"
   },
Quoted 8 lines

v1 -> v2:
Addressed the review comments from Jeff and Alison.

v1:
https://lore.kernel.org/all/[email protected]/

Fixes 965fa02e372f ("util: Distribute 'filter' and 'json' helpers to per-tool objects")
Quoted 17 lines
---
  ndctl/json.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
ndctl/json.c +1 -1
index 23bad7f..7646882 100644
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
  	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
  	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
 
-	if (!btt || !pfn || !dax)
+	if (!btt && !pfn && !dax)
  		return NULL;
 
  	jcaps = json_object_new_array();