Adds two new sysfs attributes for pfn (and dax) devices: supported_alignements and default_alignment. These advertise to userspace what alignments this kernel supports, and provides a nominal default alignment to use.
Signed-off-by: Oliver O'Halloran <[email protected]> --- I'm not sure it makes sense to provide these for pfn devices. In the dax case we have hard restrictions because of how fault handling works, but I'm not convinced this makes sense for the pfn case since it's going to be used with fs-dax. --- drivers/nvdimm/pfn_devs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 6c033c9a2f06..5157e7d89f0b 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -260,6 +260,30 @@ static ssize_t size_show(struct device *dev, } static DEVICE_ATTR_RO(size); +static ssize_t supported_alignments_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + /* Fun fact: These aren't always constants! */ + unsigned long supported_alignments[] = { + PAGE_SIZE, + HPAGE_PMD_SIZE, +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD + HPAGE_PUD_SIZE, +#endif + 0, + }; + + return nd_sector_size_show(0, supported_alignments, buf); +} +DEVICE_ATTR_RO(supported_alignments); + +static ssize_t default_alignment_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%ld\n", HPAGE_PMD_SIZE); +} +DEVICE_ATTR_RO(default_alignment); + static struct attribute *nd_pfn_attributes[] = { &dev_attr_mode.attr, &dev_attr_namespace.attr, @@ -267,6 +291,8 @@ static struct attribute *nd_pfn_attributes[] = { &dev_attr_align.attr, &dev_attr_resource.attr, &dev_attr_size.attr, + &dev_attr_supported_alignments.attr, + &dev_attr_default_alignment.attr, NULL, }; -- 2.9.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
