]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
libnvdimm, pfn: add parent uuid validation
authorDan Williams <dan.j.williams@intel.com>
Sun, 13 Dec 2015 00:09:14 +0000 (16:09 -0800)
committerDan Duval <dan.duval@oracle.com>
Wed, 7 Dec 2016 17:25:30 +0000 (12:25 -0500)
Orabug: 22913653

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>
(cherry picked from commit a34d5e8a6ad1a31b186019c9c351777626698863)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
drivers/nvdimm/pfn_devs.c
drivers/nvdimm/pmem.c

index 95ecd7b0fab3a91145dd50c3d9d3fd128aa86ff0..f9b674bc49db291f27b8504e803d2f0a47aa0740 100644 (file)
@@ -273,10 +273,11 @@ struct device *nd_pfn_create(struct nd_region *nd_region)
 
 int nd_pfn_validate(struct nd_pfn *nd_pfn)
 {
-       struct nd_namespace_common *ndns = nd_pfn->ndns;
-       struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
-       struct nd_namespace_io *nsio;
        u64 checksum, offset;
+       struct nd_namespace_io *nsio;
+       struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
+       struct nd_namespace_common *ndns = nd_pfn->ndns;
+       const u8 *parent_uuid = nd_dev_to_uuid(&ndns->dev);
 
        if (!pfn_sb || !ndns)
                return -ENODEV;
@@ -296,6 +297,9 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn)
                return -ENODEV;
        pfn_sb->checksum = cpu_to_le64(checksum);
 
+       if (memcmp(pfn_sb->parent_uuid, parent_uuid, 16) != 0)
+               return -ENODEV;
+
        switch (le32_to_cpu(pfn_sb->mode)) {
        case PFN_MODE_RAM:
                break;
index 0249e401e436a5f6d27a1a52cac28612f9c39892..47c1cde7490540003eda117302bad227ccc9425b 100644 (file)
@@ -269,6 +269,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
        pfn_sb->npfns = cpu_to_le64(npfns);
        memcpy(pfn_sb->signature, PFN_SIG, PFN_SIG_LEN);
        memcpy(pfn_sb->uuid, nd_pfn->uuid, 16);
+       memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16);
        pfn_sb->version_major = cpu_to_le16(1);
        checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb);
        pfn_sb->checksum = cpu_to_le64(checksum);