Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1403359
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/2] libnvdimm, dax: fix alignment validation |
| Date | 2016-05-19 01:50 +0200 |
| Message-ID | <rAjnX-mm-9@gated-at.bofh.it> (permalink) |
| References | <rAjnX-mm-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Testing the dax-device autodetect support revealed a probe failure with
the following result:
dax0.1: bad offset: 0x8200000 dax disabled
The original pfn-device implementation inferred the alignment from
ilog2(offset), now that the alignment is explicit the is_power_of_2()
needs replacing with a real sanity check against the recorded alignment.
Otherwise the alignment check is useless in the implicit case and only
the minimum size of the offset matters.
This self-consistency check is further validated by the probe path that
will re-check that the offset is large enough to contain all the
metadata required to enable the device.
Cc: <stable@vger.kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/pfn_devs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 816cd9828ca5..33c97076ddf0 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -416,6 +416,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -ENODEV;
}
+ nd_pfn->align = le32_to_cpu(pfn_sb->align);
if (nd_pfn->align > nvdimm_namespace_capacity(ndns)) {
dev_err(&nd_pfn->dev, "alignment: %lx exceeds capacity %llx\n",
nd_pfn->align, nvdimm_namespace_capacity(ndns));
@@ -436,8 +437,8 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
return -EBUSY;
}
- nd_pfn->align = le32_to_cpu(pfn_sb->align);
- if (!is_power_of_2(offset) || offset < PAGE_SIZE) {
+ if ((nd_pfn->align && !IS_ALIGNED(offset, nd_pfn->align))
+ || !IS_ALIGNED(offset, PAGE_SIZE)) {
dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n",
offset);
return -ENXIO;
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] libnvdimm, dax: autodetect fixes Dan Williams <dan.j.williams@intel.com> - 2016-05-19 01:50 +0200
[PATCH 2/2] libnvdimm, dax: fix alignment validation Dan Williams <dan.j.williams@intel.com> - 2016-05-19 01:50 +0200
Re: [PATCH 2/2] libnvdimm, dax: fix alignment validation Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-23 11:20 +0200
csiph-web