diff mbox

pmem: return EIO on read_pmem() failure

Message ID 20170105100546.11379-1-stefanha@redhat.com (mailing list archive)
State Accepted
Commit d47d1d2
Headers show

Commit Message

Stefan Hajnoczi Jan. 5, 2017, 10:05 a.m. UTC
The read_pmem() function uses memcpy_mcsafe() on x86 where an EFAULT
error code indicates a failed read.  Block I/O should use EIO to
indicate failure.  Other pmem code paths (like bad blocks) already use
EIO so let's be consistent.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 drivers/nvdimm/pmem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jeff Moyer Jan. 5, 2017, 3:11 p.m. UTC | #1
Stefan Hajnoczi <stefanha@redhat.com> writes:

> The read_pmem() function uses memcpy_mcsafe() on x86 where an EFAULT
> error code indicates a failed read.  Block I/O should use EIO to
> indicate failure.  Other pmem code paths (like bad blocks) already use
> EIO so let's be consistent.

I agree that it's the right thing to return, though right now it
probably doesn't matter.  As Dan said, all paths leading back to
userspace interpret any non-zero value as EIO.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  drivers/nvdimm/pmem.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 7282d74..5b536be 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -90,7 +90,9 @@ static int read_pmem(struct page *page, unsigned int off,
>  
>  	rc = memcpy_from_pmem(mem + off, pmem_addr, len);
>  	kunmap_atomic(mem);
> -	return rc;
> +	if (rc)
> +		return -EIO;
> +	return 0;
>  }
>  
>  static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
diff mbox

Patch

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 7282d74..5b536be 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -90,7 +90,9 @@  static int read_pmem(struct page *page, unsigned int off,
 
 	rc = memcpy_from_pmem(mem + off, pmem_addr, len);
 	kunmap_atomic(mem);
-	return rc;
+	if (rc)
+		return -EIO;
+	return 0;
 }
 
 static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,