Skip to contentSkip to conversation

ndctl, list: display the 'map' location in listings

PATCH Superseded Vishal Verma 2 participants 4 messages May 25, 2018 – May 29, 2018 libnvdimm: non-volatile memory device

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 ndctl, list: display the 'map' location in listings

For 'fsdax' and 'devdax' namespaces, a 'map' location may be specified for page structures storage. This can be 'mem', for system RAM, or 'dev' for using pmem as the backing storage. Once set, there was no way of telling using ndctl, which of the two locations a namespace was configured for. Add this in util_namespace_to_json so that all namespace listings contain the map location.

---
 util/json.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
util/json.c +18 -0
index c606e1c..17dd90c 100644
@@ -667,11 +667,17 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 {
 	struct json_object *jndns = json_object_new_object();
 	struct json_object *jobj, *jbbs = NULL;
+	const char *locations[] = {
+		[NDCTL_PFN_LOC_NONE] = "none",
+		[NDCTL_PFN_LOC_RAM] = "mem",
+		[NDCTL_PFN_LOC_PMEM] = "dev",
+	};
 	unsigned long long size = ULLONG_MAX;
 	unsigned int sector_size = UINT_MAX;
 	enum ndctl_namespace_mode mode;
 	const char *bdev = NULL, *name;
 	unsigned int bb_count = 0;
+	enum ndctl_pfn_loc loc;
 	struct ndctl_btt *btt;
 	struct ndctl_pfn *pfn;
 	struct ndctl_dax *dax;
@@ -749,6 +755,12 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 		jobj = util_raw_uuid(ndns);
 		if (jobj)
 			json_object_object_add(jndns, "raw_uuid", jobj);
+		loc = ndctl_pfn_get_location(pfn);
+		jobj = json_object_new_string(locations[loc]);
+		if (!jobj)
+			goto err;
+		if (jobj)
+			json_object_object_add(jndns, "map", jobj);
 		bdev = ndctl_pfn_get_block_device(pfn);
 	} else if (dax) {
 		struct daxctl_region *dax_region;
@@ -763,6 +775,12 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 		jobj = util_raw_uuid(ndns);
 		if (jobj)
 			json_object_object_add(jndns, "raw_uuid", jobj);
+		loc = ndctl_dax_get_location(dax);
+		jobj = json_object_new_string(locations[loc]);
+		if (!jobj)
+			goto err;
+		if (jobj)
+			json_object_object_add(jndns, "map", jobj);
 		if ((flags & UTIL_JSON_DAX) && dax_region) {
 			jobj = util_daxctl_region_to_json(dax_region, NULL,
 					flags);
Signature · 6 lines
2.17.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 19 lines · Vishal Verma

For 'fsdax' and 'devdax' namespaces, a 'map' location may be specified for page structures storage. This can be 'mem', for system RAM, or 'dev' for using pmem as the backing storage. Once set, there was no way of telling using ndctl, which of the two locations a namespace was configured for. Add this in util_namespace_to_json so that all namespace listings contain the map location.

---
  util/json.c | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
util/json.c +0 -0
index c606e1c..17dd90c 100644
@@ -667,11 +667,17 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 18 lines
util/json.c +6 -0
  {
         struct json_object *jndns = json_object_new_object();
         struct json_object *jobj, *jbbs = NULL;
+       const char *locations[] = {
+               [NDCTL_PFN_LOC_NONE] = "none",
+               [NDCTL_PFN_LOC_RAM] = "mem",
+               [NDCTL_PFN_LOC_PMEM] = "dev",
+       };
         unsigned long long size = ULLONG_MAX;
         unsigned int sector_size = UINT_MAX;
         enum ndctl_namespace_mode mode;
         const char *bdev = NULL, *name;
         unsigned int bb_count = 0;
+       enum ndctl_pfn_loc loc;
         struct ndctl_btt *btt;
         struct ndctl_pfn *pfn;
         struct ndctl_dax *dax;
@@ -749,6 +755,12 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 13 lines
util/json.c +6 -0
                 jobj = util_raw_uuid(ndns);
                 if (jobj)
                         json_object_object_add(jndns, "raw_uuid", jobj);
+               loc = ndctl_pfn_get_location(pfn);
+               jobj = json_object_new_string(locations[loc]);
+               if (!jobj)
+                       goto err;
+               if (jobj)
+                       json_object_object_add(jndns, "map", jobj);
                 bdev = ndctl_pfn_get_block_device(pfn);
         } else if (dax) {
                 struct daxctl_region *dax_region;
@@ -763,6 +775,12 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,

Quoted 11 lines
util/json.c +6 -0
                 jobj = util_raw_uuid(ndns);
                 if (jobj)
                         json_object_object_add(jndns, "raw_uuid", jobj);
+               loc = ndctl_dax_get_location(dax);
+               jobj = json_object_new_string(locations[loc]);
+               if (!jobj)
+                       goto err;
+               if (jobj)
+                       json_object_object_add(jndns, "map", jobj);
                 if ((flags & UTIL_JSON_DAX) && dax_region) {
                         jobj = util_daxctl_region_to_json(dax_region,

NULL,

util/json.c struct json_object *util_namespace_to_json(struct · line 786

Quoted 1 line
util/json.c +0 -0
                                         flags);

There appears to be one case missing in this:

         case NDCTL_NS_MODE_MEMORY:
                 if (pfn) /* dynamic memory mode */
                         size = ndctl_pfn_get_size(pfn);
                 else /* native/static memory mode */
                         size = ndctl_namespace_get_size(ndns);
                 jobj = json_object_new_string("fsdax");
                 break;

In the "/* native/static memory mode */" configuration we should emit a 'map:"mem"' indication.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#2 lore raw
Quoted 85 lines · Dan Williams

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 18 lines · Vishal Verma

For 'fsdax' and 'devdax' namespaces, a 'map' location may be specified for page structures storage. This can be 'mem', for system RAM, or 'dev'
for using pmem as the backing storage. Once set, there was no way of telling using ndctl, which of the two locations a namespace was configured for. Add this in util_namespace_to_json so that all namespace listings contain the map location.

---
  util/json.c | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
util/json.c +0 -0
index c606e1c..17dd90c 100644
@@ -667,11 +667,17 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 18 lines
util/json.c +6 -0
  {
         struct json_object *jndns = json_object_new_object();
         struct json_object *jobj, *jbbs = NULL;
+       const char *locations[] = {
+               [NDCTL_PFN_LOC_NONE] = "none",
+               [NDCTL_PFN_LOC_RAM] = "mem",
+               [NDCTL_PFN_LOC_PMEM] = "dev",
+       };
         unsigned long long size = ULLONG_MAX;
         unsigned int sector_size = UINT_MAX;
         enum ndctl_namespace_mode mode;
         const char *bdev = NULL, *name;
         unsigned int bb_count = 0;
+       enum ndctl_pfn_loc loc;
         struct ndctl_btt *btt;
         struct ndctl_pfn *pfn;
         struct ndctl_dax *dax;
@@ -749,6 +755,12 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 14 lines
util/json.c +6 -0
                 jobj = util_raw_uuid(ndns);
                 if (jobj)
                         json_object_object_add(jndns, "raw_uuid",
 jobj);
+               loc = ndctl_pfn_get_location(pfn);
+               jobj = json_object_new_string(locations[loc]);
+               if (!jobj)
+                       goto err;
+               if (jobj)
+                       json_object_object_add(jndns, "map", jobj);
                 bdev = ndctl_pfn_get_block_device(pfn);
         } else if (dax) {
                 struct daxctl_region *dax_region;
util/json.c +0 -0
@@ -763,6 +775,12 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,

Quoted 12 lines
util/json.c +6 -0
                 jobj = util_raw_uuid(ndns);
                 if (jobj)
                         json_object_object_add(jndns, "raw_uuid",
 jobj);
+               loc = ndctl_dax_get_location(dax);
+               jobj = json_object_new_string(locations[loc]);
+               if (!jobj)
+                       goto err;
+               if (jobj)
+                       json_object_object_add(jndns, "map", jobj);
                 if ((flags & UTIL_JSON_DAX) && dax_region) {
                         jobj = util_daxctl_region_to_json(dax_region,

NULL,

Quoted 1 line
                                         flags);

There appears to be one case missing in this:

         case NDCTL_NS_MODE_MEMORY:
                 if (pfn) /* dynamic memory mode */
                         size = ndctl_pfn_get_size(pfn);
                 else /* native/static memory mode */
                         size = ndctl_namespace_get_size(ndns);
                 jobj = json_object_new_string("fsdax");
                 break;
Quoted 2 lines

In the "/* native/static memory mode */" configuration we should emit a 'map:"mem"' indication.

Ah good catch. Is this for legacy/labelless namespaces that have been configured into fsdax mode?

I'll fixup and send a new version.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw
Quoted 86 lines · Vishal L
Quoted 85 lines · Dan Williams

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 18 lines · Vishal Verma

For 'fsdax' and 'devdax' namespaces, a 'map' location may be specified for page structures storage. This can be 'mem', for system RAM, or 'dev'
for using pmem as the backing storage. Once set, there was no way of telling using ndctl, which of the two locations a namespace was configured for. Add this in util_namespace_to_json so that all namespace listings contain the map location.

---
  util/json.c | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
util/json.c +0 -0
index c606e1c..17dd90c 100644
@@ -667,11 +667,17 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 18 lines
util/json.c +6 -0
  {
         struct json_object *jndns = json_object_new_object();
         struct json_object *jobj, *jbbs = NULL;
+       const char *locations[] = {
+               [NDCTL_PFN_LOC_NONE] = "none",
+               [NDCTL_PFN_LOC_RAM] = "mem",
+               [NDCTL_PFN_LOC_PMEM] = "dev",
+       };
         unsigned long long size = ULLONG_MAX;
         unsigned int sector_size = UINT_MAX;
         enum ndctl_namespace_mode mode;
         const char *bdev = NULL, *name;
         unsigned int bb_count = 0;
+       enum ndctl_pfn_loc loc;
         struct ndctl_btt *btt;
         struct ndctl_pfn *pfn;
         struct ndctl_dax *dax;
@@ -749,6 +755,12 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct

Quoted 14 lines
util/json.c +6 -0
                 jobj = util_raw_uuid(ndns);
                 if (jobj)
                         json_object_object_add(jndns, "raw_uuid",
 jobj);
+               loc = ndctl_pfn_get_location(pfn);
+               jobj = json_object_new_string(locations[loc]);
+               if (!jobj)
+                       goto err;
+               if (jobj)
+                       json_object_object_add(jndns, "map", jobj);
                 bdev = ndctl_pfn_get_block_device(pfn);
         } else if (dax) {
                 struct daxctl_region *dax_region;
util/json.c +0 -0
@@ -763,6 +775,12 @@ struct json_object *util_namespace_to_json(struct

ndctl_namespace *ndns,

util/json.c struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,

Quoted 12 lines
util/json.c +6 -0
                 jobj = util_raw_uuid(ndns);
                 if (jobj)
                         json_object_object_add(jndns, "raw_uuid",
 jobj);
+               loc = ndctl_dax_get_location(dax);
+               jobj = json_object_new_string(locations[loc]);
+               if (!jobj)
+                       goto err;
+               if (jobj)
+                       json_object_object_add(jndns, "map", jobj);
                 if ((flags & UTIL_JSON_DAX) && dax_region) {
                         jobj = util_daxctl_region_to_json(dax_region,

NULL,

Quoted 1 line
                                         flags);

There appears to be one case missing in this:

         case NDCTL_NS_MODE_MEMORY:
                 if (pfn) /* dynamic memory mode */
                         size = ndctl_pfn_get_size(pfn);
                 else /* native/static memory mode */
                         size = ndctl_namespace_get_size(ndns);
                 jobj = json_object_new_string("fsdax");
                 break;
Quoted 5 lines
Quoted 2 lines

In the "/* native/static memory mode */" configuration we should emit a 'map:"mem"' indication.

Ah good catch. Is this for legacy/labelless namespaces that have been configured into fsdax mode?

This is strictly for memmap=ss!nn and legacy-e820 defined namespaces where the assumption is that they are small and never need to have the map allocated anywhere else but System RAM.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm