@@ -166,6 +166,7 @@ struct ndctl_dimm {
* @dimm: backing dimm for the mapping
* @offset: dimm relative offset
* @length: span of the extent
+ * @position: interleave-order of the extent
*
* This data can be used to identify the dimm ranges contributing to a
* region / interleave-set and identify how regions alias each other.
@@ -174,6 +175,7 @@ struct ndctl_mapping {
struct ndctl_region *region;
struct ndctl_dimm *dimm;
unsigned long long offset, length;
+ int position;
struct list_node list;
};
@@ -2723,6 +2725,7 @@ static void mappings_init(struct ndctl_region *region)
unsigned long long offset, length;
struct ndctl_dimm *dimm;
unsigned int dimm_id;
+ int position, match;
sprintf(mapping_path, "%s/mapping%d", region->region_path, i);
if (sysfs_read_attr(ctx, mapping_path, buf) < 0) {
@@ -2731,8 +2734,11 @@ static void mappings_init(struct ndctl_region *region)
continue;
}
- if (sscanf(buf, "nmem%u,%llu,%llu", &dimm_id, &offset,
- &length) != 3) {
+ match = sscanf(buf, "nmem%u,%llu,%llu,%d", &dimm_id, &offset,
+ &length, &position);
+ if (match < 4)
+ position = -1;
+ if (match < 3) {
err(ctx, "bus%d mapping parse failure\n",
ndctl_bus_get_id(bus));
continue;
@@ -2756,6 +2762,7 @@ static void mappings_init(struct ndctl_region *region)
mapping->offset = offset;
mapping->length = length;
mapping->dimm = dimm;
+ mapping->position = position;
list_add(®ion->mappings, &mapping->list);
}
free(mapping_path);
@@ -2790,6 +2797,11 @@ NDCTL_EXPORT unsigned long long ndctl_mapping_get_length(struct ndctl_mapping *m
return mapping->length;
}
+NDCTL_EXPORT int ndctl_mapping_get_position(struct ndctl_mapping *mapping)
+{
+ return mapping->position;
+}
+
NDCTL_EXPORT struct ndctl_region *ndctl_mapping_get_region(
struct ndctl_mapping *mapping)
{
@@ -157,6 +157,7 @@ global:
ndctl_mapping_get_region;
ndctl_mapping_get_offset;
ndctl_mapping_get_length;
+ ndctl_mapping_get_position;
ndctl_namespace_get_first;
ndctl_namespace_get_next;
ndctl_namespace_get_ctx;
@@ -460,6 +460,7 @@ struct ndctl_bus *ndctl_mapping_get_bus(struct ndctl_mapping *mapping);
struct ndctl_region *ndctl_mapping_get_region(struct ndctl_mapping *mapping);
unsigned long long ndctl_mapping_get_offset(struct ndctl_mapping *mapping);
unsigned long long ndctl_mapping_get_length(struct ndctl_mapping *mapping);
+int ndctl_mapping_get_position(struct ndctl_mapping *mapping);
struct ndctl_namespace;
struct ndctl_namespace *ndctl_namespace_get_first(struct ndctl_region *region);
@@ -737,6 +737,7 @@ struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,
struct json_object *jmapping = json_object_new_object();
struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(mapping);
struct json_object *jobj;
+ int position;
if (!jmapping)
return NULL;
@@ -756,6 +757,14 @@ struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,
goto err;
json_object_object_add(jmapping, "length", jobj);
+ position = ndctl_mapping_get_position(mapping);
+ if (position >= 0) {
+ jobj = json_object_new_int(position);
+ if (!jobj)
+ goto err;
+ json_object_object_add(jmapping, "position", jobj);
+ }
+
return jmapping;
err:
json_object_put(jmapping);
If the kernel provides position data include it in the region mapping listing. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- ndctl/lib/libndctl.c | 16 ++++++++++++++-- ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h.in | 1 + util/json.c | 9 +++++++++ 4 files changed, 25 insertions(+), 2 deletions(-)