Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1678988 > unrolled thread

Re: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks

Started byDan Williams <dan.j.williams@intel.com>
First post2017-06-30 18:50 +0200
Last post2017-07-01 02:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks Dan Williams <dan.j.williams@intel.com> - 2017-06-30 18:50 +0200
    RE: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks "Kani, Toshimitsu" <toshi.kani@hpe.com> - 2017-07-01 02:50 +0200

#1678988 — Re: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks

FromDan Williams <dan.j.williams@intel.com>
Date2017-06-30 18:50 +0200
SubjectRe: [PATCH v2] libnvdimm, pmem: Add sysfs notifications to badblocks
Message-ID<tY7hf-7Sv-9@gated-at.bofh.it>
On Mon, Jun 12, 2017 at 3:25 PM, Toshi Kani <toshi.kani@hpe.com> wrote:
> Sysfs "badblocks" information may be updated during run-time that:
>  - MCE, SCI, and sysfs "scrub" may add new bad blocks
>  - Writes and ioctl() may clear bad blocks
>
> Add support to send sysfs notifications to sysfs "badblocks" file
> under region and pmem directories when their badblocks information
> is re-evaluated (but is not necessarily changed) during run-time.
>
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Linda Knippers <linda.knippers@hpe.com>
> ---
> v2: Send notifications for the clearing case
> ---
>  drivers/nvdimm/bus.c    |    3 +++
>  drivers/nvdimm/nd.h     |    1 +
>  drivers/nvdimm/pmem.c   |   14 ++++++++++++++
>  drivers/nvdimm/pmem.h   |    1 +
>  drivers/nvdimm/region.c |   12 ++++++++++--
>  5 files changed, 29 insertions(+), 2 deletions(-)
>
[..]
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index c544d46..6c14c72 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
[..]
> @@ -377,6 +379,13 @@ static int pmem_attach_disk(struct device *dev,
>
>         revalidate_disk(disk);
>
> +       pmem->bb_state = sysfs_get_dirent(disk_to_dev(disk)->kobj.sd,
> +                                         "badblocks");
> +       if (pmem->bb_state)
> +               sysfs_put(pmem->bb_state);

Sorry I missed this on the first review, but this looks broken. We
need to hold the reference for as long as we might trigger
notifications, so the sysfs_put() should wait until
pmem_release_disk().

[..]
> diff --git a/drivers/nvdimm/region.c b/drivers/nvdimm/region.c
> index 869a886..ca94029 100644
> --- a/drivers/nvdimm/region.c
> +++ b/drivers/nvdimm/region.c
> @@ -58,10 +58,16 @@ static int nd_region_probe(struct device *dev)
>
>                 if (devm_init_badblocks(dev, &nd_region->bb))
>                         return -ENODEV;
> +               nd_region->bb_state = sysfs_get_dirent(nd_region->dev.kobj.sd,
> +                                                      "badblocks");
> +               if (nd_region->bb_state)
> +                       sysfs_put(nd_region->bb_state);

...same here. This should wait until we tear down the region.

I'll take a look at an incremental fix patch.

[toc] | [next] | [standalone]


#1679226

From"Kani, Toshimitsu" <toshi.kani@hpe.com>
Date2017-07-01 02:50 +0200
Message-ID<tYeLM-47C-17@gated-at.bofh.it>
In reply to#1678988
> > Sysfs "badblocks" information may be updated during run-time that:
> >  - MCE, SCI, and sysfs "scrub" may add new bad blocks
> >  - Writes and ioctl() may clear bad blocks
> >
> > Add support to send sysfs notifications to sysfs "badblocks" file
> > under region and pmem directories when their badblocks information
> > is re-evaluated (but is not necessarily changed) during run-time.
> >
> > Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Vishal Verma <vishal.l.verma@intel.com>
> > Cc: Linda Knippers <linda.knippers@hpe.com>
> > ---
> > v2: Send notifications for the clearing case
> > ---
> >  drivers/nvdimm/bus.c    |    3 +++
> >  drivers/nvdimm/nd.h     |    1 +
> >  drivers/nvdimm/pmem.c   |   14 ++++++++++++++
> >  drivers/nvdimm/pmem.h   |    1 +
> >  drivers/nvdimm/region.c |   12 ++++++++++--
> >  5 files changed, 29 insertions(+), 2 deletions(-)
> >
> [..]
> > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> > index c544d46..6c14c72 100644
> > --- a/drivers/nvdimm/pmem.c
> > +++ b/drivers/nvdimm/pmem.c
> [..]
> > @@ -377,6 +379,13 @@ static int pmem_attach_disk(struct device *dev,
> >
> >         revalidate_disk(disk);
> >
> > +       pmem->bb_state = sysfs_get_dirent(disk_to_dev(disk)->kobj.sd,
> > +                                         "badblocks");
> > +       if (pmem->bb_state)
> > +               sysfs_put(pmem->bb_state);
> 
> Sorry I missed this on the first review, but this looks broken. We
> need to hold the reference for as long as we might trigger
> notifications, so the sysfs_put() should wait until
> pmem_release_disk().

I see.
 
> [..]
> > diff --git a/drivers/nvdimm/region.c b/drivers/nvdimm/region.c
> > index 869a886..ca94029 100644
> > --- a/drivers/nvdimm/region.c
> > +++ b/drivers/nvdimm/region.c
> > @@ -58,10 +58,16 @@ static int nd_region_probe(struct device *dev)
> >
> >                 if (devm_init_badblocks(dev, &nd_region->bb))
> >                         return -ENODEV;
> > +               nd_region->bb_state = sysfs_get_dirent(nd_region->dev.kobj.sd,
> > +                                                      "badblocks");
> > +               if (nd_region->bb_state)
> > +                       sysfs_put(nd_region->bb_state);
> 
> ...same here. This should wait until we tear down the region.
> 
> I'll take a look at an incremental fix patch.

Thanks Dan!
-Toshi

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web