lightnvm: pblk: put bio on bio completion
authorJavier González <javier@cnexlabs.com>
Fri, 13 Oct 2017 12:46:16 +0000 (14:46 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Oct 2017 14:34:57 +0000 (08:34 -0600)
Simplify put bio by doing it on bio end_io instead of manually putting
it on the completion path.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/pblk-core.c
drivers/lightnvm/pblk-read.c
drivers/lightnvm/pblk-recovery.c
drivers/lightnvm/pblk-write.c

index 6dd4866e579c0d967a2a5f3270f955708a3a2efd..3d27d24baa0b256a8f353ed2cca459119f0d7453 100644 (file)
@@ -417,6 +417,11 @@ int pblk_submit_io(struct pblk *pblk, struct nvm_rq *rqd)
        return nvm_submit_io(dev, rqd);
 }
 
+static void pblk_bio_map_addr_endio(struct bio *bio)
+{
+       bio_put(bio);
+}
+
 struct bio *pblk_bio_map_addr(struct pblk *pblk, void *data,
                              unsigned int nr_secs, unsigned int len,
                              int alloc_type, gfp_t gfp_mask)
@@ -453,6 +458,8 @@ struct bio *pblk_bio_map_addr(struct pblk *pblk, void *data,
 
                kaddr += PAGE_SIZE;
        }
+
+       bio->bi_end_io = pblk_bio_map_addr_endio;
 out:
        return bio;
 }
@@ -671,9 +678,6 @@ next_rq:
        atomic_dec(&pblk->inflight_io);
        reinit_completion(&wait);
 
-       if (likely(pblk->l_mg.emeta_alloc_type == PBLK_VMALLOC_META))
-               bio_put(bio);
-
        if (rqd.error) {
                if (dir == WRITE)
                        pblk_log_write_err(pblk, &rqd);
index c28d6509312e2ecd6e4dfd5928e230061e5434f1..e7141b1aaded41565b14bc29597a30670b869d1a 100644 (file)
@@ -531,7 +531,6 @@ int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq)
        atomic_long_sub(gc_rq->secs_to_gc, &pblk->inflight_reads);
 #endif
 
-       bio_put(bio);
 out:
        nvm_dev_dma_free(dev->parent, rqd.meta_list, rqd.dma_meta_list);
        return ret;
index 6b6b4183b41e7f353ba43b71cc1202eb1d877a6d..e59270e60b58ee50b1f58a210a18fc981399f9ed 100644 (file)
@@ -333,7 +333,6 @@ static void pblk_end_io_recov(struct nvm_rq *rqd)
 
        pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas);
 
-       bio_put(rqd->bio);
        nvm_dev_dma_free(dev->parent, rqd->meta_list, rqd->dma_meta_list);
        pblk_free_rqd(pblk, rqd, WRITE);
 
index 0fb8f26a6311ab39afb066dd8622e378f21d55a1..0c0481cf9f5d2832ca01e8ac731a748375f116b4 100644 (file)
@@ -188,17 +188,12 @@ static void pblk_end_io_write_meta(struct nvm_rq *rqd)
                pblk_log_write_err(pblk, rqd);
                pr_err("pblk: metadata I/O failed. Line %d\n", line->id);
        }
-#ifdef CONFIG_NVM_DEBUG
-       else
-               WARN_ONCE(rqd->bio->bi_status, "pblk: corrupted write error\n");
-#endif
 
        sync = atomic_add_return(rqd->nr_ppas, &emeta->sync);
        if (sync == emeta->nr_entries)
                pblk_gen_run_ws(pblk, line, NULL, pblk_line_close_ws,
                                                GFP_ATOMIC, pblk->close_wq);
 
-       bio_put(rqd->bio);
        nvm_dev_dma_free(dev->parent, rqd->meta_list, rqd->dma_meta_list);
        pblk_free_rqd(pblk, rqd, READ);
 
@@ -427,8 +422,7 @@ fail_rollback:
 
        nvm_dev_dma_free(dev->parent, rqd->meta_list, rqd->dma_meta_list);
 fail_free_bio:
-       if (likely(l_mg->emeta_alloc_type == PBLK_VMALLOC_META))
-               bio_put(bio);
+       bio_put(bio);
 fail_free_rqd:
        pblk_free_rqd(pblk, rqd, READ);
        return ret;