|
|
@@ -361,6 +361,15 @@ struct device *nd_pfn_create(struct nd_region *nd_region)
|
|
|
return dev;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * nd_pfn_validate - read and validate info-block
|
|
|
+ * @nd_pfn: fsdax namespace runtime state / properties
|
|
|
+ * @sig: 'devdax' or 'fsdax' signature
|
|
|
+ *
|
|
|
+ * Upon return the info-block buffer contents (->pfn_sb) are
|
|
|
+ * indeterminate when validation fails, and a coherent info-block
|
|
|
+ * otherwise.
|
|
|
+ */
|
|
|
int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
|
|
|
{
|
|
|
u64 checksum, offset;
|
|
|
@@ -506,7 +515,7 @@ int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns)
|
|
|
nvdimm_bus_unlock(&ndns->dev);
|
|
|
if (!pfn_dev)
|
|
|
return -ENOMEM;
|
|
|
- pfn_sb = devm_kzalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
|
|
|
+ pfn_sb = devm_kmalloc(dev, sizeof(*pfn_sb), GFP_KERNEL);
|
|
|
nd_pfn = to_nd_pfn(pfn_dev);
|
|
|
nd_pfn->pfn_sb = pfn_sb;
|
|
|
rc = nd_pfn_validate(nd_pfn, PFN_SIG);
|
|
|
@@ -638,7 +647,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
|
|
|
u64 checksum;
|
|
|
int rc;
|
|
|
|
|
|
- pfn_sb = devm_kzalloc(&nd_pfn->dev, sizeof(*pfn_sb), GFP_KERNEL);
|
|
|
+ pfn_sb = devm_kmalloc(&nd_pfn->dev, sizeof(*pfn_sb), GFP_KERNEL);
|
|
|
if (!pfn_sb)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
@@ -647,11 +656,14 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
|
|
|
sig = DAX_SIG;
|
|
|
else
|
|
|
sig = PFN_SIG;
|
|
|
+
|
|
|
rc = nd_pfn_validate(nd_pfn, sig);
|
|
|
if (rc != -ENODEV)
|
|
|
return rc;
|
|
|
|
|
|
/* no info block, do init */;
|
|
|
+ memset(pfn_sb, 0, sizeof(*pfn_sb));
|
|
|
+
|
|
|
nd_region = to_nd_region(nd_pfn->dev.parent);
|
|
|
if (nd_region->ro) {
|
|
|
dev_info(&nd_pfn->dev,
|
|
|
@@ -705,7 +717,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
|
|
|
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);
|
|
|
- pfn_sb->version_minor = cpu_to_le16(2);
|
|
|
+ pfn_sb->version_minor = cpu_to_le16(3);
|
|
|
pfn_sb->start_pad = cpu_to_le32(start_pad);
|
|
|
pfn_sb->end_trunc = cpu_to_le32(end_trunc);
|
|
|
pfn_sb->align = cpu_to_le32(nd_pfn->align);
|