diff mbox

lightnvm: pblk: fix error codes in pblk_submit_read_gc()

Message ID 20171018074246.nmi75jmrpuu5g74y@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Oct. 18, 2017, 7:42 a.m. UTC
There is a missing error code if pblk_bio_map_addr() fails.  This
function used to return NVM_IO_ERR on error and it still returns
NVM_IO_OK (which is zero) on success, but now it returns negative error
codes on failure.  I decided to use a standard error code and remove the
reference to NVM_IO_OK so that no one was confused.

Fixes: d340121eb770 ("lightnvm: pblk: simplify data validity check on GC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

=?UTF-8?q?Javier=20Gonz=C3=A1lez?= Oct. 18, 2017, 7:49 a.m. UTC | #1
> On 18 Oct 2017, at 09.42, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> There is a missing error code if pblk_bio_map_addr() fails.  This
> function used to return NVM_IO_ERR on error and it still returns
> NVM_IO_OK (which is zero) on success, but now it returns negative error
> codes on failure.

Good catch. Thanks Dan.

> I decided to use a standard error code and remove the
> reference to NVM_IO_OK so that no one was confused.

It's ok with me. We only use the internal codes NVM_IO_X on the user
data path to know if we need to complete the bio or not (e.g., in case
of a REQ_FLUSH). GC is better off with standard error codes.

> 
> Fixes: d340121eb770 ("lightnvm: pblk: simplify data validity check on GC")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c
> index ca79d8fb3e60..c26f527dbf86 100644
> --- a/drivers/lightnvm/pblk-read.c
> +++ b/drivers/lightnvm/pblk-read.c
> @@ -528,7 +528,7 @@ int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
> 	struct bio *bio;
> 	struct nvm_rq rqd;
> 	int data_len;
> -	int ret = NVM_IO_OK;
> +	int ret;
> 
> 	memset(&rqd, 0, sizeof(struct nvm_rq));
> 
> @@ -561,6 +561,7 @@ int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
> 						PBLK_VMALLOC_META, GFP_KERNEL);
> 	if (IS_ERR(bio)) {
> 		pr_err("pblk: could not allocate GC bio (%lu)\n", PTR_ERR(bio));
> +		ret = PTR_ERR(bio);
> 		goto err_free_dma;
> 	}
> 
> @@ -595,7 +596,7 @@ int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
> 
> out:
> 	nvm_dev_dma_free(dev->parent, rqd.meta_list, rqd.dma_meta_list);
> -	return ret;
> +	return 0;
> 
> err_free_bio:
> 	bio_put(bio);


Reviewed-by: Javier González <javier@cnexlabs.com>
diff mbox

Patch

diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c
index ca79d8fb3e60..c26f527dbf86 100644
--- a/drivers/lightnvm/pblk-read.c
+++ b/drivers/lightnvm/pblk-read.c
@@ -528,7 +528,7 @@  int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
 	struct bio *bio;
 	struct nvm_rq rqd;
 	int data_len;
-	int ret = NVM_IO_OK;
+	int ret;
 
 	memset(&rqd, 0, sizeof(struct nvm_rq));
 
@@ -561,6 +561,7 @@  int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
 						PBLK_VMALLOC_META, GFP_KERNEL);
 	if (IS_ERR(bio)) {
 		pr_err("pblk: could not allocate GC bio (%lu)\n", PTR_ERR(bio));
+		ret = PTR_ERR(bio);
 		goto err_free_dma;
 	}
 
@@ -595,7 +596,7 @@  int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
 
 out:
 	nvm_dev_dma_free(dev->parent, rqd.meta_list, rqd.dma_meta_list);
-	return ret;
+	return 0;
 
 err_free_bio:
 	bio_put(bio);