aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-12-12 19:09:14 -0500
committerDan Williams <dan.j.williams@intel.com>2015-12-13 14:40:20 -0500
commita34d5e8a6ad1a31b186019c9c351777626698863 (patch)
tree8ca570f659c71e0118486dda5249d5cf7908bdc0
parent315c562536c42aa4da9b6c5a2135dd6715a5e0b5 (diff)
libnvdimm, pfn: add parent uuid validation
Track and check the uuid of the namespace hosting a pfn instance. This forces the pfn info block to be invalidated if the namespace is re-configured with a different uuid. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/nvdimm/pfn_devs.c10
-rw-r--r--drivers/nvdimm/pmem.c1
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 95ecd7b0fab3..f9b674bc49db 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -273,10 +273,11 @@ struct device *nd_pfn_create(struct nd_region *nd_region)
273 273
274int nd_pfn_validate(struct nd_pfn *nd_pfn) 274int nd_pfn_validate(struct nd_pfn *nd_pfn)
275{ 275{
276 struct nd_namespace_common *ndns = nd_pfn->ndns;
277 struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
278 struct nd_namespace_io *nsio;
279 u64 checksum, offset; 276 u64 checksum, offset;
277 struct nd_namespace_io *nsio;
278 struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
279 struct nd_namespace_common *ndns = nd_pfn->ndns;
280 const u8 *parent_uuid = nd_dev_to_uuid(&ndns->dev);
280 281
281 if (!pfn_sb || !ndns) 282 if (!pfn_sb || !ndns)
282 return -ENODEV; 283 return -ENODEV;
@@ -296,6 +297,9 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn)
296 return -ENODEV; 297 return -ENODEV;
297 pfn_sb->checksum = cpu_to_le64(checksum); 298 pfn_sb->checksum = cpu_to_le64(checksum);
298 299
300 if (memcmp(pfn_sb->parent_uuid, parent_uuid, 16) != 0)
301 return -ENODEV;
302
299 switch (le32_to_cpu(pfn_sb->mode)) { 303 switch (le32_to_cpu(pfn_sb->mode)) {
300 case PFN_MODE_RAM: 304 case PFN_MODE_RAM:
301 break; 305 break;
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 5ba351e4f26a..dc6866734f70 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -270,6 +270,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
270 pfn_sb->npfns = cpu_to_le64(npfns); 270 pfn_sb->npfns = cpu_to_le64(npfns);
271 memcpy(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN); 271 memcpy(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN);
272 memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); 272 memcpy(pfn_sb->uuid, nd_pfn->uuid, 16);
273 memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16);
273 pfn_sb->version_major = cpu_to_le16(1); 274 pfn_sb->version_major = cpu_to_le16(1);
274 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); 275 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb);
275 pfn_sb->checksum = cpu_to_le64(checksum); 276 pfn_sb->checksum = cpu_to_le64(checksum);