From: Keith Busch <keith.busch@intel.com>
To: linux-nvdimm@lists.01.org,
Dan Williams <dan.j.williams@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCHv2 2/2] libnvdimm: Export max available extent
Date: Thu, 5 Jul 2018 14:17:26 -0600 [thread overview]
Message-ID: <20180705201726.512-2-keith.busch@intel.com> (raw)
In-Reply-To: <20180705201726.512-1-keith.busch@intel.com>
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 contiguous unallocated space that may
be allocated to create a new namespace.
Signed-off-by: Keith Busch <keith.busch@intel.com>
---
drivers/nvdimm/region_devs.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 8af483d7ef57..82aaf7d6488d 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -433,6 +433,21 @@ static ssize_t available_size_show(struct device *dev,
}
static DEVICE_ATTR_RO(available_size);
+static ssize_t max_available_extent_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nd_region *nd_region = to_nd_region(dev);
+ unsigned long long available = 0;
+
+ nvdimm_bus_lock(dev);
+ wait_nvdimm_bus_probe_idle(dev);
+ available = nd_region_contiguous_max(nd_region);
+ nvdimm_bus_unlock(dev);
+
+ return sprintf(buf, "%llu\n", available);
+}
+static DEVICE_ATTR_RO(max_available_extent);
+
static ssize_t init_namespaces_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -584,6 +599,7 @@ static struct attribute *nd_region_attributes[] = {
&dev_attr_read_only.attr,
&dev_attr_set_cookie.attr,
&dev_attr_available_size.attr,
+ &dev_attr_max_available_extent.attr,
&dev_attr_namespace_seed.attr,
&dev_attr_init_namespaces.attr,
&dev_attr_badblocks.attr,
--
2.14.3
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-07-05 20:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 20:17 [PATCHv2 1/2] libnvdimm: Use max contiguous area for namespace size Keith Busch
2018-07-05 20:17 ` Keith Busch
2018-07-05 20:17 ` Keith Busch [this message]
2018-07-05 21:13 ` [PATCHv2 2/2] libnvdimm: Export max available extent Dan Williams
2018-07-05 21:13 ` [PATCHv2 1/2] libnvdimm: Use max contiguous area for namespace size Dan Williams
2018-07-05 21:13 ` Dan Williams
2018-07-06 0:12 ` Dan Williams
2018-07-06 0:12 ` Dan Williams
2018-07-06 1:25 ` Dan Williams
2018-07-06 1:25 ` Dan Williams
2018-07-06 1:48 ` Dan Williams
2018-07-06 1:48 ` Dan Williams
2018-07-06 22:06 ` Keith Busch
2018-07-06 22:06 ` Keith Busch
2018-07-06 22:25 ` Dan Williams
2018-07-06 22:25 ` Dan Williams
2018-07-09 15:44 ` Keith Busch
2018-07-09 15:44 ` Keith Busch
2018-07-09 21:49 ` Dan Williams
2018-07-09 21:49 ` Dan Williams
2018-07-12 15:31 ` Keith Busch
2018-07-12 15:31 ` Keith Busch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180705201726.512-2-keith.busch@intel.com \
--to=keith.busch@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-nvdimm@lists.01.org \
--cc=ross.zwisler@linux.intel.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.