summaryrefslogtreecommitdiff
path: root/drivers/lightnvm/pblk-rb.c
diff options
context:
space:
mode:
authorHeiner Litz <hlitz@ucsc.edu>2019-02-11 15:25:09 +0300
committerJens Axboe <axboe@kernel.dk>2019-02-11 18:18:08 +0300
commit0586942f03b71bc95b0ee356ff6b09d53acbad06 (patch)
tree1bae68e44c9494ebe36106c7b8e8e0f65749222b /drivers/lightnvm/pblk-rb.c
parentb4cdc4260edf7e03d8b6fabb88aec2cdda95917e (diff)
downloadlinux-0586942f03b71bc95b0ee356ff6b09d53acbad06.tar.xz
lightnvm: pblk: fix race condition on GC
This patch fixes a race condition where a write is mapped to the last sectors of a line. The write is synced to the device but the L2P is not updated yet. When the line is garbage collected before the L2P update is performed, the sectors are ignored by the GC logic and the line is freed before all sectors are moved. When the L2P is finally updated, it contains a mapping to a freed line, subsequent reads of the corresponding LBAs fail. This patch introduces a per line counter specifying the number of sectors that are synced to the device but have not been updated in the L2P. Lines with a counter of greater than zero will not be selected for GC. Signed-off-by: Heiner Litz <hlitz@ucsc.edu> Reviewed-by: Hans Holmberg <hans.holmberg@cnexlabs.com> Reviewed-by: Javier González <javier@javigon.com> Signed-off-by: Matias Bjørling <mb@lightnvm.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-rb.c')
-rw-r--r--drivers/lightnvm/pblk-rb.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
index a6133b50ed9c..03c241b340ea 100644
--- a/drivers/lightnvm/pblk-rb.c
+++ b/drivers/lightnvm/pblk-rb.c
@@ -260,6 +260,7 @@ static int __pblk_rb_update_l2p(struct pblk_rb *rb, unsigned int to_update)
entry->cacheline);
line = pblk_ppa_to_line(pblk, w_ctx->ppa);
+ atomic_dec(&line->sec_to_update);
kref_put(&line->ref, pblk_line_put);
clean_wctx(w_ctx);
rb->l2p_update = pblk_rb_ptr_wrap(rb, rb->l2p_update, 1);