summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/region_devs.c
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2017-04-07 15:33:20 -0700
committerDan Williams <dan.j.williams@intel.com>2017-04-12 21:56:42 -0700
commit6a6bef90425e8cba7c53919d923240559b7f247c (patch)
tree4ba907c618208b79cb19296353edd1c4011de773 /drivers/nvdimm/region_devs.c
parent3c87f372695592bf86e9dab7b1ec7d439fda577b (diff)
downloadtalos-op-linux-6a6bef90425e8cba7c53919d923240559b7f247c.tar.gz
talos-op-linux-6a6bef90425e8cba7c53919d923240559b7f247c.zip
libnvdimm: add mechanism to publish badblocks at the region level
badblocks sysfs file will be export at region level. When nvdimm event notifier happens for NVDIMM_REVALIATE_POISON, the badblocks in the region will be updated. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/region_devs.c')
-rw-r--r--drivers/nvdimm/region_devs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index b7cb5066d961..3500fc84d939 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -448,6 +448,21 @@ static ssize_t read_only_store(struct device *dev,
}
static DEVICE_ATTR_RW(read_only);
+static ssize_t nd_badblocks_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct nd_region *nd_region = to_nd_region(dev);
+
+ return badblocks_show(&nd_region->bb, buf, 0);
+}
+static struct device_attribute dev_attr_nd_badblocks = {
+ .attr = {
+ .name = "badblocks",
+ .mode = S_IRUGO
+ },
+ .show = nd_badblocks_show,
+};
+
static struct attribute *nd_region_attributes[] = {
&dev_attr_size.attr,
&dev_attr_nstype.attr,
@@ -460,6 +475,7 @@ static struct attribute *nd_region_attributes[] = {
&dev_attr_available_size.attr,
&dev_attr_namespace_seed.attr,
&dev_attr_init_namespaces.attr,
+ &dev_attr_nd_badblocks.attr,
NULL,
};
@@ -476,6 +492,9 @@ static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n)
if (!is_nd_pmem(dev) && a == &dev_attr_dax_seed.attr)
return 0;
+ if (!is_nd_pmem(dev) && a == &dev_attr_nd_badblocks.attr)
+ return 0;
+
if (a != &dev_attr_set_cookie.attr
&& a != &dev_attr_available_size.attr)
return a->mode;
OpenPOWER on IntegriCloud