Commit cf48dc15 authored by Wenwei Tao's avatar Wenwei Tao Committed by Greg Kroah-Hartman

lightnvm: fix bio submission issue

[ Upstream commit 3cd485b1 ]

Put bio when submission fails, since we get it
before submission. And return error when backend
device driver doesn't provide a submit_io method,
thus we can end IO properly.
Signed-off-by: default avatarWenwei Tao <ww.tao0320@gmail.com>
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent edf94590
...@@ -345,7 +345,7 @@ static void gennvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) ...@@ -345,7 +345,7 @@ static void gennvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd)
static int gennvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) static int gennvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
{ {
if (!dev->ops->submit_io) if (!dev->ops->submit_io)
return 0; return -ENODEV;
/* Convert address space */ /* Convert address space */
gennvm_generic_to_addr_mode(dev, rqd); gennvm_generic_to_addr_mode(dev, rqd);
......
...@@ -650,11 +650,12 @@ static int rrpc_end_io(struct nvm_rq *rqd, int error) ...@@ -650,11 +650,12 @@ static int rrpc_end_io(struct nvm_rq *rqd, int error)
if (bio_data_dir(rqd->bio) == WRITE) if (bio_data_dir(rqd->bio) == WRITE)
rrpc_end_io_write(rrpc, rrqd, laddr, npages); rrpc_end_io_write(rrpc, rrqd, laddr, npages);
bio_put(rqd->bio);
if (rrqd->flags & NVM_IOTYPE_GC) if (rrqd->flags & NVM_IOTYPE_GC)
return 0; return 0;
rrpc_unlock_rq(rrpc, rqd); rrpc_unlock_rq(rrpc, rqd);
bio_put(rqd->bio);
if (npages > 1) if (npages > 1)
nvm_dev_dma_free(rrpc->dev, rqd->ppa_list, rqd->dma_ppa_list); nvm_dev_dma_free(rrpc->dev, rqd->ppa_list, rqd->dma_ppa_list);
...@@ -841,6 +842,7 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, ...@@ -841,6 +842,7 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
err = nvm_submit_io(rrpc->dev, rqd); err = nvm_submit_io(rrpc->dev, rqd);
if (err) { if (err) {
pr_err("rrpc: I/O submission failed: %d\n", err); pr_err("rrpc: I/O submission failed: %d\n", err);
bio_put(bio);
return NVM_IO_ERR; return NVM_IO_ERR;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment