diff options
author | Dan Williams <dan.j.williams@intel.com> | 2017-06-07 00:59:04 +0300 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2017-06-16 00:31:40 +0300 |
commit | 3934d8410cb837c5f6bff54e66574a4bbcef340a (patch) | |
tree | 0ddb31e5e956fcb7b0dd53de0bdef15e506f8193 /drivers/nvdimm | |
parent | 8f2bc2430e4ec53ea961997d760c3b35f729e444 (diff) | |
download | linux-3934d8410cb837c5f6bff54e66574a4bbcef340a.tar.xz |
libnvdimm, label: update 'nlabel' and 'position' handling for local namespaces
The v1.2 namespace label specification requires 'nlabel' and 'position'
to be valid for the first ("lowest dpa") label in the set. It also
requires all non-first labels to set those fields to 0xff.
Linux does not much care if these values are correct, because we can
just trust the count of labels with the matching uuid like the v1.1
case. However, we set them correctly in case other environments care.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm')
-rw-r--r-- | drivers/nvdimm/label.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c index ba0582fb0e21..d7f9916c6ed5 100644 --- a/drivers/nvdimm/label.c +++ b/drivers/nvdimm/label.c @@ -696,6 +696,7 @@ static int __blk_label_update(struct nd_region *nd_region, struct resource *res, **old_res_list; struct nd_label_id label_id; u8 uuid[NSLABEL_UUID_LEN]; + int min_dpa_idx = 0; LIST_HEAD(list); u32 nslot, slot; @@ -767,6 +768,18 @@ static int __blk_label_update(struct nd_region *nd_region, } } + /* + * Find the resource associated with the first label in the set + * per the v1.2 namespace specification. + */ + for (i = 0; i < nsblk->num_resources; i++) { + struct resource *min = nsblk->res[min_dpa_idx]; + + res = nsblk->res[i]; + if (res->start < min->start) + min_dpa_idx = i; + } + for (i = 0; i < nsblk->num_resources; i++) { size_t offset; @@ -785,18 +798,26 @@ static int __blk_label_update(struct nd_region *nd_region, memcpy(nd_label->name, nsblk->alt_name, NSLABEL_NAME_LEN); nd_label->flags = __cpu_to_le32(NSLABEL_FLAG_LOCAL); - nd_label->nlabel = __cpu_to_le16(0); /* N/A */ - nd_label->position = __cpu_to_le16(0); /* N/A */ /* * Use the presence of the type_guid as a flag to - * determine isetcookie usage for blk-aperture - * namespaces. + * determine isetcookie usage and nlabel + position + * policy for blk-aperture namespaces. */ - if (namespace_label_has(ndd, type_guid)) + if (namespace_label_has(ndd, type_guid)) { + if (i == min_dpa_idx) { + nd_label->nlabel = __cpu_to_le16(nsblk->num_resources); + nd_label->position = __cpu_to_le16(0); + } else { + nd_label->nlabel = __cpu_to_le16(0xffff); + nd_label->position = __cpu_to_le16(0xffff); + } nd_label->isetcookie = __cpu_to_le64(nd_set->cookie2); - else + } else { + nd_label->nlabel = __cpu_to_le16(0); /* N/A */ + nd_label->position = __cpu_to_le16(0); /* N/A */ nd_label->isetcookie = __cpu_to_le64(0); /* N/A */ + } nd_label->dpa = __cpu_to_le64(res->start); nd_label->rawsize = __cpu_to_le64(resource_size(res)); |