Skip to content

Commit

Permalink
lightnvm: convert to bioset_init()/mempool_init()
Browse files Browse the repository at this point in the history
Convert lightnvm to embedded bio sets.

Reviewed-by: Javier González <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
koverstreet authored and axboe committed May 30, 2018
1 parent 64c4bc4 commit b906bbb
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
30 changes: 15 additions & 15 deletions drivers/lightnvm/pblk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void pblk_line_mark_bb(struct work_struct *work)
}

kfree(ppa);
mempool_free(line_ws, pblk->gen_ws_pool);
mempool_free(line_ws, &pblk->gen_ws_pool);
}

static void pblk_mark_bb(struct pblk *pblk, struct pblk_line *line,
Expand Down Expand Up @@ -102,7 +102,7 @@ static void pblk_end_io_erase(struct nvm_rq *rqd)
struct pblk *pblk = rqd->private;

__pblk_end_io_erase(pblk, rqd);
mempool_free(rqd, pblk->e_rq_pool);
mempool_free(rqd, &pblk->e_rq_pool);
}

/*
Expand Down Expand Up @@ -237,15 +237,15 @@ struct nvm_rq *pblk_alloc_rqd(struct pblk *pblk, int type)
switch (type) {
case PBLK_WRITE:
case PBLK_WRITE_INT:
pool = pblk->w_rq_pool;
pool = &pblk->w_rq_pool;
rq_size = pblk_w_rq_size;
break;
case PBLK_READ:
pool = pblk->r_rq_pool;
pool = &pblk->r_rq_pool;
rq_size = pblk_g_rq_size;
break;
default:
pool = pblk->e_rq_pool;
pool = &pblk->e_rq_pool;
rq_size = pblk_g_rq_size;
}

Expand All @@ -265,13 +265,13 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type)
case PBLK_WRITE:
kfree(((struct pblk_c_ctx *)nvm_rq_to_pdu(rqd))->lun_bitmap);
case PBLK_WRITE_INT:
pool = pblk->w_rq_pool;
pool = &pblk->w_rq_pool;
break;
case PBLK_READ:
pool = pblk->r_rq_pool;
pool = &pblk->r_rq_pool;
break;
case PBLK_ERASE:
pool = pblk->e_rq_pool;
pool = &pblk->e_rq_pool;
break;
default:
pr_err("pblk: trying to free unknown rqd type\n");
Expand All @@ -292,7 +292,7 @@ void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off,

for (i = off; i < nr_pages + off; i++) {
bv = bio->bi_io_vec[i];
mempool_free(bv.bv_page, pblk->page_bio_pool);
mempool_free(bv.bv_page, &pblk->page_bio_pool);
}
}

Expand All @@ -304,12 +304,12 @@ int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags,
int i, ret;

for (i = 0; i < nr_pages; i++) {
page = mempool_alloc(pblk->page_bio_pool, flags);
page = mempool_alloc(&pblk->page_bio_pool, flags);

ret = bio_add_pc_page(q, bio, page, PBLK_EXPOSED_PAGE_SIZE, 0);
if (ret != PBLK_EXPOSED_PAGE_SIZE) {
pr_err("pblk: could not add page to bio\n");
mempool_free(page, pblk->page_bio_pool);
mempool_free(page, &pblk->page_bio_pool);
goto err;
}
}
Expand Down Expand Up @@ -1593,7 +1593,7 @@ static void pblk_line_put_ws(struct work_struct *work)
struct pblk_line *line = line_put_ws->line;

__pblk_line_put(pblk, line);
mempool_free(line_put_ws, pblk->gen_ws_pool);
mempool_free(line_put_ws, &pblk->gen_ws_pool);
}

void pblk_line_put(struct kref *ref)
Expand All @@ -1610,7 +1610,7 @@ void pblk_line_put_wq(struct kref *ref)
struct pblk *pblk = line->pblk;
struct pblk_line_ws *line_put_ws;

line_put_ws = mempool_alloc(pblk->gen_ws_pool, GFP_ATOMIC);
line_put_ws = mempool_alloc(&pblk->gen_ws_pool, GFP_ATOMIC);
if (!line_put_ws)
return;

Expand Down Expand Up @@ -1752,7 +1752,7 @@ void pblk_line_close_ws(struct work_struct *work)
struct pblk_line *line = line_ws->line;

pblk_line_close(pblk, line);
mempool_free(line_ws, pblk->gen_ws_pool);
mempool_free(line_ws, &pblk->gen_ws_pool);
}

void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
Expand All @@ -1761,7 +1761,7 @@ void pblk_gen_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
{
struct pblk_line_ws *line_ws;

line_ws = mempool_alloc(pblk->gen_ws_pool, gfp_mask);
line_ws = mempool_alloc(&pblk->gen_ws_pool, gfp_mask);

line_ws->pblk = pblk;
line_ws->line = line;
Expand Down
72 changes: 36 additions & 36 deletions drivers/lightnvm/pblk-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
static struct kmem_cache *pblk_ws_cache, *pblk_rec_cache, *pblk_g_rq_cache,
*pblk_w_rq_cache;
static DECLARE_RWSEM(pblk_lock);
struct bio_set *pblk_bio_set;
struct bio_set pblk_bio_set;

static int pblk_rw_io(struct request_queue *q, struct pblk *pblk,
struct bio *bio)
Expand Down Expand Up @@ -341,7 +341,7 @@ static int pblk_core_init(struct pblk *pblk)
{
struct nvm_tgt_dev *dev = pblk->dev;
struct nvm_geo *geo = &dev->geo;
int max_write_ppas;
int ret, max_write_ppas;

atomic64_set(&pblk->user_wa, 0);
atomic64_set(&pblk->pad_wa, 0);
Expand Down Expand Up @@ -375,33 +375,33 @@ static int pblk_core_init(struct pblk *pblk)
goto fail_free_pad_dist;

/* Internal bios can be at most the sectors signaled by the device. */
pblk->page_bio_pool = mempool_create_page_pool(NVM_MAX_VLBA, 0);
if (!pblk->page_bio_pool)
ret = mempool_init_page_pool(&pblk->page_bio_pool, NVM_MAX_VLBA, 0);
if (ret)
goto free_global_caches;

pblk->gen_ws_pool = mempool_create_slab_pool(PBLK_GEN_WS_POOL_SIZE,
pblk_ws_cache);
if (!pblk->gen_ws_pool)
ret = mempool_init_slab_pool(&pblk->gen_ws_pool, PBLK_GEN_WS_POOL_SIZE,
pblk_ws_cache);
if (ret)
goto free_page_bio_pool;

pblk->rec_pool = mempool_create_slab_pool(geo->all_luns,
pblk_rec_cache);
if (!pblk->rec_pool)
ret = mempool_init_slab_pool(&pblk->rec_pool, geo->all_luns,
pblk_rec_cache);
if (ret)
goto free_gen_ws_pool;

pblk->r_rq_pool = mempool_create_slab_pool(geo->all_luns,
pblk_g_rq_cache);
if (!pblk->r_rq_pool)
ret = mempool_init_slab_pool(&pblk->r_rq_pool, geo->all_luns,
pblk_g_rq_cache);
if (ret)
goto free_rec_pool;

pblk->e_rq_pool = mempool_create_slab_pool(geo->all_luns,
pblk_g_rq_cache);
if (!pblk->e_rq_pool)
ret = mempool_init_slab_pool(&pblk->e_rq_pool, geo->all_luns,
pblk_g_rq_cache);
if (ret)
goto free_r_rq_pool;

pblk->w_rq_pool = mempool_create_slab_pool(geo->all_luns,
pblk_w_rq_cache);
if (!pblk->w_rq_pool)
ret = mempool_init_slab_pool(&pblk->w_rq_pool, geo->all_luns,
pblk_w_rq_cache);
if (ret)
goto free_e_rq_pool;

pblk->close_wq = alloc_workqueue("pblk-close-wq",
Expand Down Expand Up @@ -433,17 +433,17 @@ static int pblk_core_init(struct pblk *pblk)
free_close_wq:
destroy_workqueue(pblk->close_wq);
free_w_rq_pool:
mempool_destroy(pblk->w_rq_pool);
mempool_exit(&pblk->w_rq_pool);
free_e_rq_pool:
mempool_destroy(pblk->e_rq_pool);
mempool_exit(&pblk->e_rq_pool);
free_r_rq_pool:
mempool_destroy(pblk->r_rq_pool);
mempool_exit(&pblk->r_rq_pool);
free_rec_pool:
mempool_destroy(pblk->rec_pool);
mempool_exit(&pblk->rec_pool);
free_gen_ws_pool:
mempool_destroy(pblk->gen_ws_pool);
mempool_exit(&pblk->gen_ws_pool);
free_page_bio_pool:
mempool_destroy(pblk->page_bio_pool);
mempool_exit(&pblk->page_bio_pool);
free_global_caches:
pblk_free_global_caches(pblk);
fail_free_pad_dist:
Expand All @@ -462,12 +462,12 @@ static void pblk_core_free(struct pblk *pblk)
if (pblk->bb_wq)
destroy_workqueue(pblk->bb_wq);

mempool_destroy(pblk->page_bio_pool);
mempool_destroy(pblk->gen_ws_pool);
mempool_destroy(pblk->rec_pool);
mempool_destroy(pblk->r_rq_pool);
mempool_destroy(pblk->e_rq_pool);
mempool_destroy(pblk->w_rq_pool);
mempool_exit(&pblk->page_bio_pool);
mempool_exit(&pblk->gen_ws_pool);
mempool_exit(&pblk->rec_pool);
mempool_exit(&pblk->r_rq_pool);
mempool_exit(&pblk->e_rq_pool);
mempool_exit(&pblk->w_rq_pool);

pblk_free_global_caches(pblk);
kfree(pblk->pad_dist);
Expand Down Expand Up @@ -1297,18 +1297,18 @@ static int __init pblk_module_init(void)
{
int ret;

pblk_bio_set = bioset_create(BIO_POOL_SIZE, 0, 0);
if (!pblk_bio_set)
return -ENOMEM;
ret = bioset_init(&pblk_bio_set, BIO_POOL_SIZE, 0, 0);
if (ret)
return ret;
ret = nvm_register_tgt_type(&tt_pblk);
if (ret)
bioset_free(pblk_bio_set);
bioset_exit(&pblk_bio_set);
return ret;
}

static void pblk_module_exit(void)
{
bioset_free(pblk_bio_set);
bioset_exit(&pblk_bio_set);
nvm_unregister_tgt_type(&tt_pblk);
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/lightnvm/pblk-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd,
kunmap_atomic(src_p);
kunmap_atomic(dst_p);

mempool_free(src_bv.bv_page, pblk->page_bio_pool);
mempool_free(src_bv.bv_page, &pblk->page_bio_pool);

hole = find_next_zero_bit(read_bitmap, nr_secs, hole + 1);
} while (hole < nr_secs);
Expand Down Expand Up @@ -429,7 +429,7 @@ int pblk_submit_read(struct pblk *pblk, struct bio *bio)
struct bio *int_bio = NULL;

/* Clone read bio to deal with read errors internally */
int_bio = bio_clone_fast(bio, GFP_KERNEL, pblk_bio_set);
int_bio = bio_clone_fast(bio, GFP_KERNEL, &pblk_bio_set);
if (!int_bio) {
pr_err("pblk: could not clone read bio\n");
goto fail_end_io;
Expand Down
2 changes: 1 addition & 1 deletion drivers/lightnvm/pblk-recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void pblk_submit_rec(struct work_struct *work)
goto err;
}

mempool_free(recovery, pblk->rec_pool);
mempool_free(recovery, &pblk->rec_pool);
return;

err:
Expand Down
8 changes: 4 additions & 4 deletions drivers/lightnvm/pblk-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
if (unlikely(nr_ppas == 1))
ppa_list = &rqd->ppa_addr;

recovery = mempool_alloc(pblk->rec_pool, GFP_ATOMIC);
recovery = mempool_alloc(&pblk->rec_pool, GFP_ATOMIC);

INIT_LIST_HEAD(&recovery->failed);

Expand All @@ -134,15 +134,15 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
/* Logic error */
if (bit > c_ctx->nr_valid) {
WARN_ONCE(1, "pblk: corrupted write request\n");
mempool_free(recovery, pblk->rec_pool);
mempool_free(recovery, &pblk->rec_pool);
goto out;
}

ppa = ppa_list[bit];
entry = pblk_rb_sync_scan_entry(&pblk->rwb, &ppa);
if (!entry) {
pr_err("pblk: could not scan entry on write failure\n");
mempool_free(recovery, pblk->rec_pool);
mempool_free(recovery, &pblk->rec_pool);
goto out;
}

Expand All @@ -156,7 +156,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
ret = pblk_recov_setup_rq(pblk, c_ctx, recovery, comp_bits, c_entries);
if (ret) {
pr_err("pblk: could not recover from write failure\n");
mempool_free(recovery, pblk->rec_pool);
mempool_free(recovery, &pblk->rec_pool);
goto out;
}

Expand Down
14 changes: 7 additions & 7 deletions drivers/lightnvm/pblk.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,12 @@ struct pblk {

struct list_head compl_list;

mempool_t *page_bio_pool;
mempool_t *gen_ws_pool;
mempool_t *rec_pool;
mempool_t *r_rq_pool;
mempool_t *w_rq_pool;
mempool_t *e_rq_pool;
mempool_t page_bio_pool;
mempool_t gen_ws_pool;
mempool_t rec_pool;
mempool_t r_rq_pool;
mempool_t w_rq_pool;
mempool_t e_rq_pool;

struct workqueue_struct *close_wq;
struct workqueue_struct *bb_wq;
Expand Down Expand Up @@ -841,7 +841,7 @@ void pblk_write_should_kick(struct pblk *pblk);
/*
* pblk read path
*/
extern struct bio_set *pblk_bio_set;
extern struct bio_set pblk_bio_set;
int pblk_submit_read(struct pblk *pblk, struct bio *bio);
int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq);
/*
Expand Down

0 comments on commit b906bbb

Please sign in to comment.