diff mbox series

[v4,1/2] libnvdimm/pfn_dev: Don't clear device memmap area during generic namespace probe

Message ID 20191031105741.102793-1-aneesh.kumar@linux.ibm.com (mailing list archive)
State Superseded
Headers show
Series [v4,1/2] libnvdimm/pfn_dev: Don't clear device memmap area during generic namespace probe | expand

Commit Message

Aneesh Kumar K.V Oct. 31, 2019, 10:57 a.m. UTC
nvdimm core use nd_pfn_validate when looking for devdax or fsdax namespace. In this
case device resources are allocated against nd_namespace_io dev. In-order to
allow remap of range in nd_pfn_clear_memmap_error(), move the device memmap
area clearing while initializing pfn namespace. With this device
resource are allocated against nd_pfn and we can use nd_pfn->dev for remapping.

This also avoids calling nd_pfn_clear_mmap_errors twice. Once while probing the
namespace and second while initialzing a pfn namespace.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 drivers/nvdimm/pfn_devs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Dan Williams Oct. 31, 2019, 6:50 p.m. UTC | #1
On Thu, Oct 31, 2019 at 3:57 AM Aneesh Kumar K.V
<aneesh.kumar@linux.ibm.com> wrote:
>
> nvdimm core use nd_pfn_validate when looking for devdax or fsdax namespace. In this
> case device resources are allocated against nd_namespace_io dev. In-order to
> allow remap of range in nd_pfn_clear_memmap_error(), move the device memmap
> area clearing while initializing pfn namespace. With this device
> resource are allocated against nd_pfn and we can use nd_pfn->dev for remapping.
>
> This also avoids calling nd_pfn_clear_mmap_errors twice. Once while probing the
> namespace and second while initialzing a pfn namespace.

Nice find!

For the resend: s/initialzing/initializing/

>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>  drivers/nvdimm/pfn_devs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index 60d81fae06ee..fc2cd412861a 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -591,7 +591,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
>                 return -ENXIO;
>         }
>
> -       return nd_pfn_clear_memmap_errors(nd_pfn);
> +       return 0;
>  }
>  EXPORT_SYMBOL(nd_pfn_validate);
>
> @@ -730,7 +730,8 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
>
>         rc = nd_pfn_validate(nd_pfn, sig);
>         if (rc != -ENODEV)
> -               return rc;
> +               /* Clear the memap range of errors */

No need for this comment the following function name is descriptive enough.

> +               return nd_pfn_clear_memmap_errors(nd_pfn);

While this does allow for the errors to be cleared once on each
activation, it blocks validation errors from being reported up the
stack. It also does not address errors being cleared on create, but
that was also a problem shared with the current implementation.

I think you want something like this? This passes my testing, but
please review / test to make sure I'm not overlooking something, and
update the changelog to reflect that errors are now also cleared on
create.

diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 5a848a014d6d..c1eb99c0ca76 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -725,9 +725,10 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
                sig = PFN_SIG;

        rc = nd_pfn_validate(nd_pfn, sig);
-       if (rc != -ENODEV)
-               /* Clear the memap range of errors */
+       if (rc == 0)
                return nd_pfn_clear_memmap_errors(nd_pfn);
+       if (rc != -ENODEV)
+               return rc;

        /* no info block, do init */;
        memset(pfn_sb, 0, sizeof(*pfn_sb));
@@ -793,7 +794,10 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
        checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb);
        pfn_sb->checksum = cpu_to_le64(checksum);

-       return nvdimm_write_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0);
+       rc = nvdimm_write_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0);
+       if (rc)
+               return rc;
+       return nd_pfn_clear_memmap_errors(nd_pfn);
 }

 /*
diff mbox series

Patch

diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 60d81fae06ee..fc2cd412861a 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -591,7 +591,7 @@  int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
 		return -ENXIO;
 	}
 
-	return nd_pfn_clear_memmap_errors(nd_pfn);
+	return 0;
 }
 EXPORT_SYMBOL(nd_pfn_validate);
 
@@ -730,7 +730,8 @@  static int nd_pfn_init(struct nd_pfn *nd_pfn)
 
 	rc = nd_pfn_validate(nd_pfn, sig);
 	if (rc != -ENODEV)
-		return rc;
+		/* Clear the memap range of errors */
+		return nd_pfn_clear_memmap_errors(nd_pfn);
 
 	/* no info block, do init */;
 	memset(pfn_sb, 0, sizeof(*pfn_sb));