diff options
author | Keith Busch <keith.busch@intel.com> | 2018-07-24 17:07:58 -0400 |
---|---|---|
committer | Dave Jiang <dave.jiang@intel.com> | 2018-07-25 17:11:43 -0400 |
commit | 1e687220ef2d95a582e13d8de79932bfe32fdfa8 (patch) | |
tree | f3e15d37cff8ebc26e86a679938f4a4f276b47cb | |
parent | 12e3129e29b406c41bc89231092a20d79dbf802c (diff) |
libnvdimm: Export max available extent
The 'available_size' attribute showing the combined total of all
unallocated space isn't always useful to know how large of a namespace
a user may be able to allocate if the region is fragmented. This patch
will export the largest extent of unallocated space that may be allocated
to create a new namespace.
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
-rw-r--r-- | drivers/nvdimm/region_devs.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index c30d5af02cc2..fa37afcd43ff 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c | |||
@@ -434,6 +434,21 @@ static ssize_t available_size_show(struct device *dev, | |||
434 | } | 434 | } |
435 | static DEVICE_ATTR_RO(available_size); | 435 | static DEVICE_ATTR_RO(available_size); |
436 | 436 | ||
437 | static ssize_t max_available_extent_show(struct device *dev, | ||
438 | struct device_attribute *attr, char *buf) | ||
439 | { | ||
440 | struct nd_region *nd_region = to_nd_region(dev); | ||
441 | unsigned long long available = 0; | ||
442 | |||
443 | nvdimm_bus_lock(dev); | ||
444 | wait_nvdimm_bus_probe_idle(dev); | ||
445 | available = nd_region_allocatable_dpa(nd_region); | ||
446 | nvdimm_bus_unlock(dev); | ||
447 | |||
448 | return sprintf(buf, "%llu\n", available); | ||
449 | } | ||
450 | static DEVICE_ATTR_RO(max_available_extent); | ||
451 | |||
437 | static ssize_t init_namespaces_show(struct device *dev, | 452 | static ssize_t init_namespaces_show(struct device *dev, |
438 | struct device_attribute *attr, char *buf) | 453 | struct device_attribute *attr, char *buf) |
439 | { | 454 | { |
@@ -585,6 +600,7 @@ static struct attribute *nd_region_attributes[] = { | |||
585 | &dev_attr_read_only.attr, | 600 | &dev_attr_read_only.attr, |
586 | &dev_attr_set_cookie.attr, | 601 | &dev_attr_set_cookie.attr, |
587 | &dev_attr_available_size.attr, | 602 | &dev_attr_available_size.attr, |
603 | &dev_attr_max_available_extent.attr, | ||
588 | &dev_attr_namespace_seed.attr, | 604 | &dev_attr_namespace_seed.attr, |
589 | &dev_attr_init_namespaces.attr, | 605 | &dev_attr_init_namespaces.attr, |
590 | &dev_attr_badblocks.attr, | 606 | &dev_attr_badblocks.attr, |