summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/label.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-06-06 20:39:30 +0200
committerDan Williams <dan.j.williams@intel.com>2017-06-15 23:31:40 +0200
commit8f2bc2430e4ec53ea961997d760c3b35f729e444 (patch)
treeb22d8530aca1b1c470c34f6ae46110f030bc4198 /drivers/nvdimm/label.c
parentlibnvdimm, label: populate the type_guid property for v1.2 namespaces (diff)
downloadlinux-8f2bc2430e4ec53ea961997d760c3b35f729e444.tar.xz
linux-8f2bc2430e4ec53ea961997d760c3b35f729e444.zip
libnvdimm, label: populate 'isetcookie' for blk-aperture namespaces
Starting with the v1.2 definition of namespace labels, the isetcookie field is populated and validated for blk-aperture namespaces. This adds some safety against inadvertent copying of namespace labels from one DIMM-device to another. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/label.c')
-rw-r--r--drivers/nvdimm/label.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index d8b87d3a0ebe..ba0582fb0e21 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -787,7 +787,17 @@ static int __blk_label_update(struct nd_region *nd_region,
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 */
- nd_label->isetcookie = __cpu_to_le64(0); /* N/A */
+
+ /*
+ * Use the presence of the type_guid as a flag to
+ * determine isetcookie usage for blk-aperture
+ * namespaces.
+ */
+ if (namespace_label_has(ndd, type_guid))
+ nd_label->isetcookie = __cpu_to_le64(nd_set->cookie2);
+ else
+ 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));
nd_label->lbasize = __cpu_to_le64(nsblk->lbasize);