All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dev-dax: add support to display badblocks in sysfs for dev-dax
@ 2016-09-28 18:52 Dave Jiang
  2016-09-28 18:57 ` Verma, Vishal L
  2016-09-28 20:50 ` Dan Williams
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Jiang @ 2016-09-28 18:52 UTC (permalink / raw)
  To: dan.j.williams; +Cc: linux-nvdimm

Adding support to show badblocks in the pmem region that's provided
by the poison_list. This should show up in
/sys/class/dax/daxN.N/badblocks as read only.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/dax/dax.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index 29f600f..c73c494 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -18,6 +18,8 @@
 #include <linux/dax.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
+#include <linux/badblocks.h>
+#include "../nvdimm/nd.h"
 
 static int dax_major;
 static struct class *dax_class;
@@ -42,6 +44,7 @@ struct dax_region {
 	unsigned int align;
 	struct resource res;
 	unsigned long pfn_flags;
+	struct badblocks bb;
 };
 
 /**
@@ -97,6 +100,7 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
 		unsigned long pfn_flags)
 {
 	struct dax_region *dax_region;
+	struct nd_region *nd_region = to_nd_region(parent->parent);
 
 	dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL);
 
@@ -112,6 +116,10 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
 	dax_region->dev = parent;
 	dax_region->base = addr;
 
+	if (devm_init_badblocks(parent, &dax_region->bb))
+		return NULL;
+	nvdimm_badblocks_populate(nd_region, &dax_region->bb, res);
+
 	return dax_region;
 }
 EXPORT_SYMBOL_GPL(alloc_dax_region);
@@ -130,8 +138,20 @@ static ssize_t size_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(size);
 
+static ssize_t dax_dev_badblocks_show(struct device *dev,
+		struct device_attribute *attr, char *page)
+{
+	struct dax_dev *dax_dev = dev_get_drvdata(dev);
+	struct dax_region *dax_region = dax_dev->region;
+
+	return badblocks_show(&dax_region->bb, page, 0);
+}
+
+static DEVICE_ATTR(badblocks, S_IRUGO, dax_dev_badblocks_show, NULL);
+
 static struct attribute *dax_device_attributes[] = {
 	&dev_attr_size.attr,
+	&dev_attr_badblocks.attr,
 	NULL,
 };
 

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dev-dax: add support to display badblocks in sysfs for dev-dax
  2016-09-28 18:52 [PATCH] dev-dax: add support to display badblocks in sysfs for dev-dax Dave Jiang
@ 2016-09-28 18:57 ` Verma, Vishal L
  2016-09-28 20:50 ` Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Verma, Vishal L @ 2016-09-28 18:57 UTC (permalink / raw)
  To: Williams, Dan J, Jiang, Dave; +Cc: linux-nvdimm@lists.01.org

On Wed, 2016-09-28 at 11:52 -0700, Dave Jiang wrote:
> Adding support to show badblocks in the pmem region that's provided
> by the poison_list. This should show up in
> /sys/class/dax/daxN.N/badblocks as read only.

I think we can allow error injection by making this read/write. See
badblocks_store and how it is used in disk_badblocks_store, and that
will allow badblock injection for testing/debug purposes.

> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/dax/dax.c |   20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
> index 29f600f..c73c494 100644
> --- a/drivers/dax/dax.c
> +++ b/drivers/dax/dax.c
> @@ -18,6 +18,8 @@
>  #include <linux/dax.h>
>  #include <linux/fs.h>
>  #include <linux/mm.h>
> +#include <linux/badblocks.h>
> +#include "../nvdimm/nd.h"
>  
>  static int dax_major;
>  static struct class *dax_class;
> @@ -42,6 +44,7 @@ struct dax_region {
>  	unsigned int align;
>  	struct resource res;
>  	unsigned long pfn_flags;
> +	struct badblocks bb;
>  };
>  
>  /**
> @@ -97,6 +100,7 @@ struct dax_region *alloc_dax_region(struct device
> *parent, int region_id,
>  		unsigned long pfn_flags)
>  {
>  	struct dax_region *dax_region;
> +	struct nd_region *nd_region = to_nd_region(parent->parent);
>  
>  	dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL);
>  
> @@ -112,6 +116,10 @@ struct dax_region *alloc_dax_region(struct device
> *parent, int region_id,
>  	dax_region->dev = parent;
>  	dax_region->base = addr;
>  
> +	if (devm_init_badblocks(parent, &dax_region->bb))
> +		return NULL;
> +	nvdimm_badblocks_populate(nd_region, &dax_region->bb, res);
> +
>  	return dax_region;
>  }
>  EXPORT_SYMBOL_GPL(alloc_dax_region);
> @@ -130,8 +138,20 @@ static ssize_t size_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(size);
>  
> +static ssize_t dax_dev_badblocks_show(struct device *dev,
> +		struct device_attribute *attr, char *page)
> +{
> +	struct dax_dev *dax_dev = dev_get_drvdata(dev);
> +	struct dax_region *dax_region = dax_dev->region;
> +
> +	return badblocks_show(&dax_region->bb, page, 0);
> +}
> +
> +static DEVICE_ATTR(badblocks, S_IRUGO, dax_dev_badblocks_show, NULL);
> +
>  static struct attribute *dax_device_attributes[] = {
>  	&dev_attr_size.attr,
> +	&dev_attr_badblocks.attr,
>  	NULL,
>  };
>  
> 
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dev-dax: add support to display badblocks in sysfs for dev-dax
  2016-09-28 18:52 [PATCH] dev-dax: add support to display badblocks in sysfs for dev-dax Dave Jiang
  2016-09-28 18:57 ` Verma, Vishal L
@ 2016-09-28 20:50 ` Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2016-09-28 20:50 UTC (permalink / raw)
  To: Dave Jiang; +Cc: linux-nvdimm@lists.01.org

On Wed, Sep 28, 2016 at 11:52 AM, Dave Jiang <dave.jiang@intel.com> wrote:
> Adding support to show badblocks in the pmem region that's provided
> by the poison_list. This should show up in
> /sys/class/dax/daxN.N/badblocks as read only.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/dax/dax.c |   20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
> index 29f600f..c73c494 100644
> --- a/drivers/dax/dax.c
> +++ b/drivers/dax/dax.c
> @@ -18,6 +18,8 @@
>  #include <linux/dax.h>
>  #include <linux/fs.h>
>  #include <linux/mm.h>
> +#include <linux/badblocks.h>
> +#include "../nvdimm/nd.h"
>
>  static int dax_major;
>  static struct class *dax_class;
> @@ -42,6 +44,7 @@ struct dax_region {
>         unsigned int align;
>         struct resource res;
>         unsigned long pfn_flags;
> +       struct badblocks bb;
>  };
>
>  /**
> @@ -97,6 +100,7 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
>                 unsigned long pfn_flags)
>  {
>         struct dax_region *dax_region;
> +       struct nd_region *nd_region = to_nd_region(parent->parent);
>
>         dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL);
>
> @@ -112,6 +116,10 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
>         dax_region->dev = parent;
>         dax_region->base = addr;
>
> +       if (devm_init_badblocks(parent, &dax_region->bb))
> +               return NULL;
> +       nvdimm_badblocks_populate(nd_region, &dax_region->bb, res);
> +
>         return dax_region;
>  }
>  EXPORT_SYMBOL_GPL(alloc_dax_region);
> @@ -130,8 +138,20 @@ static ssize_t size_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(size);
>
> +static ssize_t dax_dev_badblocks_show(struct device *dev,
> +               struct device_attribute *attr, char *page)
> +{
> +       struct dax_dev *dax_dev = dev_get_drvdata(dev);
> +       struct dax_region *dax_region = dax_dev->region;
> +
> +       return badblocks_show(&dax_region->bb, page, 0);

This will show the badblocks for the entire region...

> +}
> +
> +static DEVICE_ATTR(badblocks, S_IRUGO, dax_dev_badblocks_show, NULL);
> +
>  static struct attribute *dax_device_attributes[] = {
>         &dev_attr_size.attr,
> +       &dev_attr_badblocks.attr,

...but we want it to be limited per-device.

So the errors in the region need to be reconciled into the individual
resources that get assigned to the device instance.  This becomes more
important when we allow carving a dax region into multiple devices.

devm_create_dax_dev() takes a lists of resources that make up the
given instance.  Those may be discontiguous and the per-device
badblocks instance would need to account for that.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-28 20:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-28 18:52 [PATCH] dev-dax: add support to display badblocks in sysfs for dev-dax Dave Jiang
2016-09-28 18:57 ` Verma, Vishal L
2016-09-28 20:50 ` Dan Williams

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.