diff options
author | Javier González <jg@lightnvm.io> | 2017-06-26 11:57:27 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-06-27 00:27:39 +0200 |
commit | b20ba1bc749ce0cd7a74d24f23826a6462c3de53 (patch) | |
tree | 4a28d3558c007f5e7d27d4e24b7ed37723a16609 /drivers/lightnvm/pblk-rb.c | |
parent | lightnvm: pblk: add lock assertions on helpers (diff) | |
download | linux-b20ba1bc749ce0cd7a74d24f23826a6462c3de53.tar.xz linux-b20ba1bc749ce0cd7a74d24f23826a6462c3de53.zip |
lightnvm: pblk: redesign GC algorithm
At the moment, in order to get enough read parallelism, we have recycled
several lines at the same time. This approach has proven not to work
well when reaching capacity, since we end up mixing valid data from all
lines, thus not maintaining a sustainable free/recycled line ratio.
The new design, relies on a two level workqueue mechanism. In the first
level, we read the metadata for a number of lines based on the GC list
they reside on (this is governed by the number of valid sectors in each
line). In the second level, we recycle a single line at a time. Here, we
issue reads in parallel, while a single GC write thread places data in
the write buffer. This design allows to (i) only move data from one line
at a time, thus maintaining a sane free/recycled ration and (ii)
maintain the GC writer busy with recycled data.
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-rb.c')
-rw-r--r-- | drivers/lightnvm/pblk-rb.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c index d293af12aa7a..50886878568b 100644 --- a/drivers/lightnvm/pblk-rb.c +++ b/drivers/lightnvm/pblk-rb.c @@ -199,12 +199,22 @@ static int __pblk_rb_update_l2p(struct pblk_rb *rb, unsigned int *l2p_upd, struct pblk_line *line; struct pblk_rb_entry *entry; struct pblk_w_ctx *w_ctx; + unsigned int user_io = 0, gc_io = 0; unsigned int i; + int flags; for (i = 0; i < to_update; i++) { entry = &rb->entries[*l2p_upd]; w_ctx = &entry->w_ctx; + flags = READ_ONCE(entry->w_ctx.flags); + if (flags & PBLK_IOTYPE_USER) + user_io++; + else if (flags & PBLK_IOTYPE_GC) + gc_io++; + else + WARN(1, "pblk: unknown IO type\n"); + pblk_update_map_dev(pblk, w_ctx->lba, w_ctx->ppa, entry->cacheline); @@ -214,6 +224,8 @@ static int __pblk_rb_update_l2p(struct pblk_rb *rb, unsigned int *l2p_upd, *l2p_upd = (*l2p_upd + 1) & (rb->nr_entries - 1); } + pblk_rl_out(&pblk->rl, user_io, gc_io); + return 0; } @@ -531,7 +543,6 @@ unsigned int pblk_rb_read_to_bio(struct pblk_rb *rb, struct nvm_rq *rqd, struct pblk_rb_entry *entry; struct page *page; unsigned int pad = 0, to_read = nr_entries; - unsigned int user_io = 0, gc_io = 0; unsigned int i; int flags; @@ -555,13 +566,6 @@ try: if (!(flags & PBLK_WRITTEN_DATA)) goto try; - if (flags & PBLK_IOTYPE_USER) - user_io++; - else if (flags & PBLK_IOTYPE_GC) - gc_io++; - else - WARN(1, "pblk: unknown IO type\n"); - page = virt_to_page(entry->data); if (!page) { pr_err("pblk: could not allocate write bio page\n"); @@ -613,7 +617,6 @@ try: } } - pblk_rl_out(&pblk->rl, user_io, gc_io); #ifdef CONFIG_NVM_DEBUG atomic_long_add(pad, &((struct pblk *) (container_of(rb, struct pblk, rwb)))->padded_writes); |