summaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk.h
diff options
context:
space:
mode:
authorJavier González <javier@javigon.com>2018-10-09 07:12:15 -0400
committerJens Axboe <axboe@kernel.dk>2018-10-09 10:25:08 -0400
commit766c8ceb16fce904d6b8985ca2c0a547e053d1d5 (patch)
tree36e7d365c27ed8c6173375b4ba59d5b6980dbdfa /drivers/lightnvm/pblk.h
parent8a57fc3823d08edb1661a06d9e0a8c2365ac561e (diff)
lightnvm: pblk: guarantee that backpointer is respected on writer stall
pblk's write buffer must guarantee that it respects the device's constrains for reads (i.e., mw_cunits). This is done by maintaining a backpointer that updates the L2P table as entries wrap up, making them point to the media instead of pointing to the write buffer. This mechanism can race in case that the write thread stalls, as the write pointer will protect the last written entry, thus disregarding the read constrains. This patch adds an extra check on wrap up, making sure that the threshold is respected at all times, preventing new entries to overwrite committed data, also in case of write thread stall. Reported-by: Heiner Litz <hlitz@ucsc.edu> Signed-off-by: Javier González <javier@cnexlabs.com> Reviewed-by: Heiner Litz <hlitz@ucsc.edu> Signed-off-by: Matias Bjørling <mb@lightnvm.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk.h')
-rw-r--r--drivers/lightnvm/pblk.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 0f98ea24ee59..02bb2e98f8a9 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -203,6 +203,11 @@ struct pblk_rb {
203 * will be 4KB 203 * will be 4KB
204 */ 204 */
205 205
206 unsigned int back_thres; /* Threshold that shall be maintained by
207 * the backpointer in order to respect
208 * geo->mw_cunits on a per chunk basis
209 */
210
206 struct list_head pages; /* List of data pages */ 211 struct list_head pages; /* List of data pages */
207 212
208 spinlock_t w_lock; /* Write lock */ 213 spinlock_t w_lock; /* Write lock */
@@ -734,7 +739,8 @@ struct pblk_line_ws {
734/* 739/*
735 * pblk ring buffer operations 740 * pblk ring buffer operations
736 */ 741 */
737int pblk_rb_init(struct pblk_rb *rb, unsigned int size, unsigned int seg_sz); 742int pblk_rb_init(struct pblk_rb *rb, unsigned int size, unsigned int threshold,
743 unsigned int seg_sz);
738int pblk_rb_may_write_user(struct pblk_rb *rb, struct bio *bio, 744int pblk_rb_may_write_user(struct pblk_rb *rb, struct bio *bio,
739 unsigned int nr_entries, unsigned int *pos); 745 unsigned int nr_entries, unsigned int *pos);
740int pblk_rb_may_write_gc(struct pblk_rb *rb, unsigned int nr_entries, 746int pblk_rb_may_write_gc(struct pblk_rb *rb, unsigned int nr_entries,