Re: [PATCH v5 2/4] mm/nvdimm: Add page size and struct page size to pfn superblock

Aneesh Kumar K.V
2019-08-10T04:24:12Z

"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:

case PFN_MODE_PMEM:
> @@ -475,6 +484,20 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
> align = 1UL << ilog2(offset);
> mode = le32_to_cpu(pfn_sb->mode);
>
> + if (le32_to_cpu(pfn_sb->page_size) != PAGE_SIZE) {
> + dev_err(&nd_pfn->dev,
> + "init failed, page size mismatch %d\n",
> + le32_to_cpu(pfn_sb->page_size));
> + return -EOPNOTSUPP;
> + }
> +
> + if (le16_to_cpu(pfn_sb->page_struct_size) < sizeof(struct page)) {
> + dev_err(&nd_pfn->dev,
> + "init failed, struct page size mismatch %d\n",
> + le16_to_cpu(pfn_sb->page_struct_size));
> + return -EOPNOTSUPP;
> + }
> +

We need this here?

>From 9885b2f9ed81a2438fc81507cfcdbdb1aeab756c Mon Sep 17 00:00:00 2001
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Date: Fri, 9 Aug 2019 22:10:08 +0530
Subject: [PATCH] nvdimm: check struct page size only if pfn node is PMEM

We should do the check only with PFN_MODE_PMEM. If we use
memory for backing vmemmap, we should be able to enable
the namespace even if struct page size change.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
drivers/nvdimm/pfn_devs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index f43d1baa6f33..f3e9a4b826da 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -509,7 +509,8 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -EOPNOTSUPP;
}

- if (le16_to_cpu(pfn_sb->page_struct_size) < sizeof(struct page)) {
+ if ((le16_to_cpu(pfn_sb->page_struct_size) < sizeof(struct page)) &&
+ (mode == PFN_MODE_PMEM)) {
dev_err(&nd_pfn->dev,
"init failed, struct page size mismatch %d\n",
le16_to_cpu(pfn_sb->page_struct_size));
--
2.21.0