diff options
author | Dan Williams <dan.j.williams@intel.com> | 2017-08-11 17:54:48 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2017-08-15 09:32:12 -0700 |
commit | f13d2b61e59cbdd813be7639eb85bfbf99593ac0 (patch) | |
tree | 416d7bf862f4d926e4f399811274fcd99b908f5c /drivers/nvdimm | |
parent | 1fdadbebc4f617c1ee4a1465ad173cc9e524089d (diff) | |
download | linux-stable-f13d2b61e59cbdd813be7639eb85bfbf99593ac0.tar.gz linux-stable-f13d2b61e59cbdd813be7639eb85bfbf99593ac0.tar.bz2 linux-stable-f13d2b61e59cbdd813be7639eb85bfbf99593ac0.zip |
libnvdimm, pfn, dax: limit namespace alignments to the supported set
Now that we properly advertise the supported pte, pmd, and pud sizes,
restrict the supported alignments that can be set on a namespace. This
assumes that userspace was not previously relying on the ability to set
odd alignments. At least ndctl only ever supported setting the namespace
alignment to 4K, 2M, or 1G.
Cc: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm')
-rw-r--r-- | drivers/nvdimm/pfn_devs.c | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index c500531ca23b..9576c444f0ab 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -134,26 +134,6 @@ static const unsigned long *nd_pfn_supported_alignments(void) return data; } -static ssize_t __align_store(struct nd_pfn *nd_pfn, const char *buf) -{ - unsigned long val; - int rc; - - rc = kstrtoul(buf, 0, &val); - if (rc) - return rc; - - if (!is_power_of_2(val) || val < PAGE_SIZE || val > SZ_1G) - return -EINVAL; - - if (nd_pfn->dev.driver) - return -EBUSY; - else - nd_pfn->align = val; - - return 0; -} - static ssize_t align_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { @@ -162,7 +142,8 @@ static ssize_t align_store(struct device *dev, device_lock(dev); nvdimm_bus_lock(dev); - rc = __align_store(nd_pfn, buf); + rc = nd_size_select_store(dev, buf, &nd_pfn->align, + nd_pfn_supported_alignments()); dev_dbg(dev, "%s: result: %zd wrote: %s%s", __func__, rc, buf, buf[len - 1] == '\n' ? "" : "\n"); nvdimm_bus_unlock(dev); |