diff options
-rw-r--r-- | drivers/nvdimm/pfn.h | 4 | ||||
-rw-r--r-- | drivers/nvdimm/pfn_devs.c | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h index 8e343a3ca873..9d2704c83fa7 100644 --- a/drivers/nvdimm/pfn.h +++ b/drivers/nvdimm/pfn.h | |||
@@ -33,7 +33,9 @@ struct nd_pfn_sb { | |||
33 | /* minor-version-1 additions for section alignment */ | 33 | /* minor-version-1 additions for section alignment */ |
34 | __le32 start_pad; | 34 | __le32 start_pad; |
35 | __le32 end_trunc; | 35 | __le32 end_trunc; |
36 | u8 padding[4004]; | 36 | /* minor-version-2 record the base alignment of the mapping */ |
37 | __le32 align; | ||
38 | u8 padding[4000]; | ||
37 | __le64 checksum; | 39 | __le64 checksum; |
38 | }; | 40 | }; |
39 | 41 | ||
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index ca396c8f2cd5..58740d7ce81b 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c | |||
@@ -394,6 +394,9 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn) | |||
394 | pfn_sb->end_trunc = 0; | 394 | pfn_sb->end_trunc = 0; |
395 | } | 395 | } |
396 | 396 | ||
397 | if (__le16_to_cpu(pfn_sb->version_minor) < 2) | ||
398 | pfn_sb->align = 0; | ||
399 | |||
397 | switch (le32_to_cpu(pfn_sb->mode)) { | 400 | switch (le32_to_cpu(pfn_sb->mode)) { |
398 | case PFN_MODE_RAM: | 401 | case PFN_MODE_RAM: |
399 | case PFN_MODE_PMEM: | 402 | case PFN_MODE_PMEM: |
@@ -433,7 +436,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn) | |||
433 | return -EBUSY; | 436 | return -EBUSY; |
434 | } | 437 | } |
435 | 438 | ||
436 | nd_pfn->align = 1UL << ilog2(offset); | 439 | nd_pfn->align = le32_to_cpu(pfn_sb->align); |
437 | if (!is_power_of_2(offset) || offset < PAGE_SIZE) { | 440 | if (!is_power_of_2(offset) || offset < PAGE_SIZE) { |
438 | dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n", | 441 | dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n", |
439 | offset); | 442 | offset); |
@@ -629,9 +632,10 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) | |||
629 | memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); | 632 | memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); |
630 | memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); | 633 | memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); |
631 | pfn_sb->version_major = cpu_to_le16(1); | 634 | pfn_sb->version_major = cpu_to_le16(1); |
632 | pfn_sb->version_minor = cpu_to_le16(1); | 635 | pfn_sb->version_minor = cpu_to_le16(2); |
633 | pfn_sb->start_pad = cpu_to_le32(start_pad); | 636 | pfn_sb->start_pad = cpu_to_le32(start_pad); |
634 | pfn_sb->end_trunc = cpu_to_le32(end_trunc); | 637 | pfn_sb->end_trunc = cpu_to_le32(end_trunc); |
638 | pfn_sb->align = cpu_to_le32(nd_pfn->align); | ||
635 | checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); | 639 | checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); |
636 | pfn_sb->checksum = cpu_to_le64(checksum); | 640 | pfn_sb->checksum = cpu_to_le64(checksum); |
637 | 641 | ||