aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier González <javier@cnexlabs.com>2017-10-13 08:46:08 -0400
committerJens Axboe <axboe@kernel.dk>2017-10-13 10:34:57 -0400
commit0d880398cb6254ab3e110e2a8a659da65a56ffee (patch)
tree226aacdbbef55ec17523569a30bc4e3f426e4e5b
parentb84ae4a8b883b96b95fff0e3979ff2c65bbf96b0 (diff)
lightnvm: pblk: decouple read/erase mempools
Since read and erase paths offer different guarantees for inflight I/Os, separate the mempools to set the right min_nr for each on creation. Reported-by: Jens Axboe <axboe@kernel.dk> 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>
-rw-r--r--drivers/lightnvm/pblk-core.c8
-rw-r--r--drivers/lightnvm/pblk-init.c22
-rw-r--r--drivers/lightnvm/pblk.h5
3 files changed, 22 insertions, 13 deletions
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index b92532211866..0c22e5ccdfdd 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -64,7 +64,7 @@ static void pblk_end_io_erase(struct nvm_rq *rqd)
64 struct pblk *pblk = rqd->private; 64 struct pblk *pblk = rqd->private;
65 65
66 __pblk_end_io_erase(pblk, rqd); 66 __pblk_end_io_erase(pblk, rqd);
67 mempool_free(rqd, pblk->g_rq_pool); 67 mempool_free(rqd, pblk->e_rq_pool);
68} 68}
69 69
70void __pblk_map_invalidate(struct pblk *pblk, struct pblk_line *line, 70void __pblk_map_invalidate(struct pblk *pblk, struct pblk_line *line,
@@ -161,7 +161,7 @@ struct nvm_rq *pblk_alloc_rqd(struct pblk *pblk, int rw)
161 pool = pblk->w_rq_pool; 161 pool = pblk->w_rq_pool;
162 rq_size = pblk_w_rq_size; 162 rq_size = pblk_w_rq_size;
163 } else { 163 } else {
164 pool = pblk->g_rq_pool; 164 pool = pblk->r_rq_pool;
165 rq_size = pblk_g_rq_size; 165 rq_size = pblk_g_rq_size;
166 } 166 }
167 167
@@ -178,7 +178,7 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int rw)
178 if (rw == WRITE) 178 if (rw == WRITE)
179 pool = pblk->w_rq_pool; 179 pool = pblk->w_rq_pool;
180 else 180 else
181 pool = pblk->g_rq_pool; 181 pool = pblk->r_rq_pool;
182 182
183 mempool_free(rqd, pool); 183 mempool_free(rqd, pool);
184} 184}
@@ -1479,7 +1479,7 @@ int pblk_blk_erase_async(struct pblk *pblk, struct ppa_addr ppa)
1479 struct nvm_rq *rqd; 1479 struct nvm_rq *rqd;
1480 int err; 1480 int err;
1481 1481
1482 rqd = mempool_alloc(pblk->g_rq_pool, GFP_KERNEL); 1482 rqd = mempool_alloc(pblk->e_rq_pool, GFP_KERNEL);
1483 memset(rqd, 0, pblk_g_rq_size); 1483 memset(rqd, 0, pblk_g_rq_size);
1484 1484
1485 pblk_setup_e_rq(pblk, rqd, ppa); 1485 pblk_setup_e_rq(pblk, rqd, ppa);
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 340552253580..2f8d3f9ffbaf 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -261,15 +261,20 @@ static int pblk_core_init(struct pblk *pblk)
261 if (!pblk->rec_pool) 261 if (!pblk->rec_pool)
262 goto free_gen_ws_pool; 262 goto free_gen_ws_pool;
263 263
264 pblk->g_rq_pool = mempool_create_slab_pool(PBLK_READ_REQ_POOL_SIZE, 264 pblk->r_rq_pool = mempool_create_slab_pool(geo->nr_luns,
265 pblk_g_rq_cache); 265 pblk_g_rq_cache);
266 if (!pblk->g_rq_pool) 266 if (!pblk->r_rq_pool)
267 goto free_rec_pool; 267 goto free_rec_pool;
268 268
269 pblk->w_rq_pool = mempool_create_slab_pool(geo->nr_luns * 2, 269 pblk->e_rq_pool = mempool_create_slab_pool(geo->nr_luns,
270 pblk_g_rq_cache);
271 if (!pblk->e_rq_pool)
272 goto free_r_rq_pool;
273
274 pblk->w_rq_pool = mempool_create_slab_pool(geo->nr_luns,
270 pblk_w_rq_cache); 275 pblk_w_rq_cache);
271 if (!pblk->w_rq_pool) 276 if (!pblk->w_rq_pool)
272 goto free_g_rq_pool; 277 goto free_e_rq_pool;
273 278
274 pblk->line_meta_pool = 279 pblk->line_meta_pool =
275 mempool_create_slab_pool(PBLK_META_POOL_SIZE, 280 mempool_create_slab_pool(PBLK_META_POOL_SIZE,
@@ -304,8 +309,10 @@ free_line_meta_pool:
304 mempool_destroy(pblk->line_meta_pool); 309 mempool_destroy(pblk->line_meta_pool);
305free_w_rq_pool: 310free_w_rq_pool:
306 mempool_destroy(pblk->w_rq_pool); 311 mempool_destroy(pblk->w_rq_pool);
307free_g_rq_pool: 312free_e_rq_pool:
308 mempool_destroy(pblk->g_rq_pool); 313 mempool_destroy(pblk->e_rq_pool);
314free_r_rq_pool:
315 mempool_destroy(pblk->r_rq_pool);
309free_rec_pool: 316free_rec_pool:
310 mempool_destroy(pblk->rec_pool); 317 mempool_destroy(pblk->rec_pool);
311free_gen_ws_pool: 318free_gen_ws_pool:
@@ -326,7 +333,8 @@ static void pblk_core_free(struct pblk *pblk)
326 mempool_destroy(pblk->page_bio_pool); 333 mempool_destroy(pblk->page_bio_pool);
327 mempool_destroy(pblk->gen_ws_pool); 334 mempool_destroy(pblk->gen_ws_pool);
328 mempool_destroy(pblk->rec_pool); 335 mempool_destroy(pblk->rec_pool);
329 mempool_destroy(pblk->g_rq_pool); 336 mempool_destroy(pblk->r_rq_pool);
337 mempool_destroy(pblk->e_rq_pool);
330 mempool_destroy(pblk->w_rq_pool); 338 mempool_destroy(pblk->w_rq_pool);
331 mempool_destroy(pblk->line_meta_pool); 339 mempool_destroy(pblk->line_meta_pool);
332 340
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index efaa781abb06..419e1b7328e4 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -41,7 +41,6 @@
41#define PBLK_MAX_REQ_ADDRS_PW (6) 41#define PBLK_MAX_REQ_ADDRS_PW (6)
42 42
43#define PBLK_META_POOL_SIZE (128) 43#define PBLK_META_POOL_SIZE (128)
44#define PBLK_READ_REQ_POOL_SIZE (1024)
45 44
46#define PBLK_NR_CLOSE_JOBS (4) 45#define PBLK_NR_CLOSE_JOBS (4)
47 46
@@ -60,6 +59,7 @@
60 59
61#define ERASE 2 /* READ = 0, WRITE = 1 */ 60#define ERASE 2 /* READ = 0, WRITE = 1 */
62 61
62/* Static pool sizes */
63#define PBLK_GEN_WS_POOL_SIZE (2) 63#define PBLK_GEN_WS_POOL_SIZE (2)
64 64
65enum { 65enum {
@@ -624,8 +624,9 @@ struct pblk {
624 mempool_t *page_bio_pool; 624 mempool_t *page_bio_pool;
625 mempool_t *gen_ws_pool; 625 mempool_t *gen_ws_pool;
626 mempool_t *rec_pool; 626 mempool_t *rec_pool;
627 mempool_t *g_rq_pool; 627 mempool_t *r_rq_pool;
628 mempool_t *w_rq_pool; 628 mempool_t *w_rq_pool;
629 mempool_t *e_rq_pool;
629 mempool_t *line_meta_pool; 630 mempool_t *line_meta_pool;
630 631
631 struct workqueue_struct *close_wq; 632 struct workqueue_struct *close_wq;