linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] PBLK Bugfixes and cleanups
@ 2018-11-05 12:26 Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Hans Holmberg
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

This series is a slew of bugfixes and cleanups for PBLK, mostly
fixing issues found during corner-case testing in QEMU.

Changes since v1:
	Messed up from:, now the patches apply with the correct author
	Pardon the mess.

Hans Holmberg (7):
  lightnvm: pblk: fix resubmission of overwritten write err lbas
  lightnvm: pblk: account for write error sectors in emeta
  lightnvm: pblk: stop writes gracefully when running out of lines
  lightnvm: pblk: set conservative threshold for user writes
  lightnvm: pblk: remove unused macro
  lightnvm: pblk: fix pblk_lines_init error handling path
  lightnvm: pblk: remove dead code in pblk_recov_l2p

 drivers/lightnvm/pblk-init.c     | 48 +++++++++++++++++-----------
 drivers/lightnvm/pblk-map.c      | 47 ++++++++++++++++-----------
 drivers/lightnvm/pblk-recovery.c |  1 -
 drivers/lightnvm/pblk-rl.c       |  5 ++-
 drivers/lightnvm/pblk-write.c    | 55 +++++++++++++++++++++++---------
 drivers/lightnvm/pblk.h          | 16 ++++++++--
 6 files changed, 114 insertions(+), 58 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 15:12   ` Sebastien Boisvert
  2018-11-05 12:26 ` [PATCH v2 2/7] lightnvm: pblk: account for write error sectors in emeta Hans Holmberg
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

Make sure we only look up valid lba addresses on the resubmission path.

If an lba is invalidated in the write buffer, that sector will be
submitted to disk(as it is already mapped to a ppa), and that write
might fail, resulting in a crash when trying to look up the lba in the
mapping table (as the lba is marked as invalid).

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-write.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index fa8726493b39..3ddd16f47106 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -148,9 +148,11 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry,
 		w_ctx = &entry->w_ctx;
 
 		/* Check if the lba has been overwritten */
-		ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
-		if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
-			w_ctx->lba = ADDR_EMPTY;
+		if (w_ctx->lba != ADDR_EMPTY) {
+			ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
+			if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
+				w_ctx->lba = ADDR_EMPTY;
+		}
 
 		/* Mark up the entry as submittable again */
 		flags = READ_ONCE(w_ctx->flags);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/7] lightnvm: pblk: account for write error sectors in emeta
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 3/7] lightnvm: pblk: stop writes gracefully when running out of lines Hans Holmberg
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

Lines inflicted with write errors lines might be recovered
if they have not been recycled after write error garbage collection.

Ensure that the emeta accounting of valid lbas is correct
for such lines to avoid recovery inconsistencies.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-write.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index 3ddd16f47106..750f04b8a227 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -105,14 +105,20 @@ static void pblk_complete_write(struct pblk *pblk, struct nvm_rq *rqd,
 }
 
 /* Map remaining sectors in chunk, starting from ppa */
-static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa)
+static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa,
+		int rqd_ppas)
 {
 	struct pblk_line *line;
 	struct ppa_addr map_ppa = *ppa;
+	__le64 addr_empty = cpu_to_le64(ADDR_EMPTY);
+	__le64 *lba_list;
 	u64 paddr;
 	int done = 0;
+	int n = 0;
 
 	line = pblk_ppa_to_line(pblk, *ppa);
+	lba_list = emeta_to_lbas(pblk, line->emeta->buf);
+
 	spin_lock(&line->lock);
 
 	while (!done)  {
@@ -121,10 +127,17 @@ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa)
 		if (!test_and_set_bit(paddr, line->map_bitmap))
 			line->left_msecs--;
 
+		if (n < rqd_ppas && lba_list[paddr] != addr_empty)
+			line->nr_valid_lbas--;
+
+		lba_list[paddr] = addr_empty;
+
 		if (!test_and_set_bit(paddr, line->invalid_bitmap))
 			le32_add_cpu(line->vsc, -1);
 
 		done = nvm_next_ppa_in_chk(pblk->dev, &map_ppa);
+
+		n++;
 	}
 
 	line->w_err_gc->has_write_err = 1;
@@ -202,7 +215,7 @@ static void pblk_submit_rec(struct work_struct *work)
 
 	pblk_log_write_err(pblk, rqd);
 
-	pblk_map_remaining(pblk, ppa_list);
+	pblk_map_remaining(pblk, ppa_list, rqd->nr_ppas);
 	pblk_queue_resubmit(pblk, c_ctx);
 
 	pblk_up_rq(pblk, c_ctx->lun_bitmap);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/7] lightnvm: pblk: stop writes gracefully when running out of lines
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 2/7] lightnvm: pblk: account for write error sectors in emeta Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes Hans Holmberg
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

If mapping fails (i.e. when running out of lines), handle the error
and stop writing.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-map.c   | 47 +++++++++++++++++++++--------------
 drivers/lightnvm/pblk-write.c | 30 ++++++++++++++--------
 drivers/lightnvm/pblk.h       |  4 +--
 3 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/drivers/lightnvm/pblk-map.c b/drivers/lightnvm/pblk-map.c
index 6dcbd44e3acb..5a3c28cce8ab 100644
--- a/drivers/lightnvm/pblk-map.c
+++ b/drivers/lightnvm/pblk-map.c
@@ -33,6 +33,9 @@ static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
 	int nr_secs = pblk->min_write_pgs;
 	int i;
 
+	if (!line)
+		return -ENOSPC;
+
 	if (pblk_line_is_full(line)) {
 		struct pblk_line *prev_line = line;
 
@@ -42,8 +45,11 @@ static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
 		line = pblk_line_replace_data(pblk);
 		pblk_line_close_meta(pblk, prev_line);
 
-		if (!line)
-			return -EINTR;
+		if (!line) {
+			pblk_pipeline_stop(pblk);
+			return -ENOSPC;
+		}
+
 	}
 
 	emeta = line->emeta;
@@ -84,7 +90,7 @@ static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry,
 	return 0;
 }
 
-void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
+int pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
 		 unsigned long *lun_bitmap, unsigned int valid_secs,
 		 unsigned int off)
 {
@@ -93,20 +99,22 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
 	unsigned int map_secs;
 	int min = pblk->min_write_pgs;
 	int i;
+	int ret;
 
 	for (i = off; i < rqd->nr_ppas; i += min) {
 		map_secs = (i + min > valid_secs) ? (valid_secs % min) : min;
-		if (pblk_map_page_data(pblk, sentry + i, &ppa_list[i],
-					lun_bitmap, &meta_list[i], map_secs)) {
-			bio_put(rqd->bio);
-			pblk_free_rqd(pblk, rqd, PBLK_WRITE);
-			pblk_pipeline_stop(pblk);
-		}
+
+		ret = pblk_map_page_data(pblk, sentry + i, &ppa_list[i],
+					lun_bitmap, &meta_list[i], map_secs);
+		if (ret)
+			return ret;
 	}
+
+	return 0;
 }
 
 /* only if erase_ppa is set, acquire erase semaphore */
-void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
+int pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
 		       unsigned int sentry, unsigned long *lun_bitmap,
 		       unsigned int valid_secs, struct ppa_addr *erase_ppa)
 {
@@ -119,15 +127,16 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
 	unsigned int map_secs;
 	int min = pblk->min_write_pgs;
 	int i, erase_lun;
+	int ret;
+
 
 	for (i = 0; i < rqd->nr_ppas; i += min) {
 		map_secs = (i + min > valid_secs) ? (valid_secs % min) : min;
-		if (pblk_map_page_data(pblk, sentry + i, &ppa_list[i],
-					lun_bitmap, &meta_list[i], map_secs)) {
-			bio_put(rqd->bio);
-			pblk_free_rqd(pblk, rqd, PBLK_WRITE);
-			pblk_pipeline_stop(pblk);
-		}
+
+		ret = pblk_map_page_data(pblk, sentry + i, &ppa_list[i],
+					lun_bitmap, &meta_list[i], map_secs);
+		if (ret)
+			return ret;
 
 		erase_lun = pblk_ppa_to_pos(geo, ppa_list[i]);
 
@@ -163,7 +172,7 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
 	 */
 	e_line = pblk_line_get_erase(pblk);
 	if (!e_line)
-		return;
+		return -ENOSPC;
 
 	/* Erase blocks that are bad in this line but might not be in next */
 	if (unlikely(pblk_ppa_empty(*erase_ppa)) &&
@@ -174,7 +183,7 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
 		bit = find_next_bit(d_line->blk_bitmap,
 						lm->blk_per_line, bit + 1);
 		if (bit >= lm->blk_per_line)
-			return;
+			return 0;
 
 		spin_lock(&e_line->lock);
 		if (test_bit(bit, e_line->erase_bitmap)) {
@@ -188,4 +197,6 @@ void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
 		*erase_ppa = pblk->luns[bit].bppa; /* set ch and lun */
 		erase_ppa->a.blk = e_line->id;
 	}
+
+	return 0;
 }
diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index 750f04b8a227..2bf78f81862d 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -334,12 +334,13 @@ static int pblk_setup_w_rq(struct pblk *pblk, struct nvm_rq *rqd,
 	}
 
 	if (likely(!e_line || !atomic_read(&e_line->left_eblks)))
-		pblk_map_rq(pblk, rqd, c_ctx->sentry, lun_bitmap, valid, 0);
+		ret = pblk_map_rq(pblk, rqd, c_ctx->sentry, lun_bitmap,
+							valid, 0);
 	else
-		pblk_map_erase_rq(pblk, rqd, c_ctx->sentry, lun_bitmap,
+		ret = pblk_map_erase_rq(pblk, rqd, c_ctx->sentry, lun_bitmap,
 							valid, erase_ppa);
 
-	return 0;
+	return ret;
 }
 
 static int pblk_calc_secs_to_sync(struct pblk *pblk, unsigned int secs_avail,
@@ -563,7 +564,7 @@ static void pblk_free_write_rqd(struct pblk *pblk, struct nvm_rq *rqd)
 							c_ctx->nr_padded);
 }
 
-static int pblk_submit_write(struct pblk *pblk)
+static int pblk_submit_write(struct pblk *pblk, int *secs_left)
 {
 	struct bio *bio;
 	struct nvm_rq *rqd;
@@ -572,6 +573,8 @@ static int pblk_submit_write(struct pblk *pblk)
 	unsigned long pos;
 	unsigned int resubmit;
 
+	*secs_left = 0;
+
 	spin_lock(&pblk->resubmit_lock);
 	resubmit = !list_empty(&pblk->resubmit_list);
 	spin_unlock(&pblk->resubmit_lock);
@@ -601,17 +604,17 @@ static int pblk_submit_write(struct pblk *pblk)
 		 */
 		secs_avail = pblk_rb_read_count(&pblk->rwb);
 		if (!secs_avail)
-			return 1;
+			return 0;
 
 		secs_to_flush = pblk_rb_flush_point_count(&pblk->rwb);
 		if (!secs_to_flush && secs_avail < pblk->min_write_pgs)
-			return 1;
+			return 0;
 
 		secs_to_sync = pblk_calc_secs_to_sync(pblk, secs_avail,
 					secs_to_flush);
 		if (secs_to_sync > pblk->max_write_pgs) {
 			pblk_err(pblk, "bad buffer sync calculation\n");
-			return 1;
+			return 0;
 		}
 
 		secs_to_com = (secs_to_sync > secs_avail) ?
@@ -640,6 +643,7 @@ static int pblk_submit_write(struct pblk *pblk)
 	atomic_long_add(secs_to_sync, &pblk->sub_writes);
 #endif
 
+	*secs_left = 1;
 	return 0;
 
 fail_free_bio:
@@ -648,16 +652,22 @@ static int pblk_submit_write(struct pblk *pblk)
 	bio_put(bio);
 	pblk_free_rqd(pblk, rqd, PBLK_WRITE);
 
-	return 1;
+	return -EINTR;
 }
 
 int pblk_write_ts(void *data)
 {
 	struct pblk *pblk = data;
+	int secs_left;
+	int write_failure = 0;
 
 	while (!kthread_should_stop()) {
-		if (!pblk_submit_write(pblk))
-			continue;
+		if (!write_failure) {
+			write_failure = pblk_submit_write(pblk, &secs_left);
+
+			if (secs_left)
+				continue;
+		}
 		set_current_state(TASK_INTERRUPTIBLE);
 		io_schedule();
 	}
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 02bb2e98f8a9..f415aae600c8 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -871,10 +871,10 @@ int pblk_write_gc_to_cache(struct pblk *pblk, struct pblk_gc_rq *gc_rq);
 /*
  * pblk map
  */
-void pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
+int pblk_map_erase_rq(struct pblk *pblk, struct nvm_rq *rqd,
 		       unsigned int sentry, unsigned long *lun_bitmap,
 		       unsigned int valid_secs, struct ppa_addr *erase_ppa);
-void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
+int pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry,
 		 unsigned long *lun_bitmap, unsigned int valid_secs,
 		 unsigned int off);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
                   ` (2 preceding siblings ...)
  2018-11-05 12:26 ` [PATCH v2 3/7] lightnvm: pblk: stop writes gracefully when running out of lines Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 21:15   ` kbuild test robot
  2018-11-05 23:09   ` kbuild test robot
  2018-11-05 12:26 ` [PATCH v2 5/7] lightnvm: pblk: remove unused macro Hans Holmberg
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

In a worst-case scenario (random writes), OP% of sectors
in each line will be invalid, and we will then need
to move data out of 100/OP% lines to free a single line.

So, to prevent the possibility of running out of lines,
temporarily block user writes when there is less than
100/OP% free lines.

Also ensure that pblk creation does not produce instances
with insufficient over provisioning.

Insufficient over-provising is not a problem on real hardware,
but often an issue when running QEMU simulations (with few lines).
100 lines is enough to create a sane instance with the standard
(11%) over provisioning.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-init.c | 43 ++++++++++++++++++++++++------------
 drivers/lightnvm/pblk-rl.c   |  5 ++---
 drivers/lightnvm/pblk.h      | 12 +++++++++-
 3 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 13822594647c..8b89bb26b0f1 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -635,13 +635,13 @@ static unsigned int calc_emeta_len(struct pblk *pblk)
 	return (lm->emeta_len[1] + lm->emeta_len[2] + lm->emeta_len[3]);
 }
 
-static void pblk_set_provision(struct pblk *pblk, long nr_free_blks)
+static int pblk_set_provision(struct pblk *pblk, long nr_free_chks)
 {
 	struct nvm_tgt_dev *dev = pblk->dev;
 	struct pblk_line_mgmt *l_mg = &pblk->l_mg;
 	struct pblk_line_meta *lm = &pblk->lm;
 	struct nvm_geo *geo = &dev->geo;
-	sector_t provisioned;
+	sector_t provisioned, minimum;
 	int sec_meta, blk_meta;
 
 	if (geo->op == NVM_TARGET_DEFAULT_OP)
@@ -649,17 +649,34 @@ static void pblk_set_provision(struct pblk *pblk, long nr_free_blks)
 	else
 		pblk->op = geo->op;
 
-	provisioned = nr_free_blks;
+	minimum = pblk_get_min_chks(pblk);
+	provisioned = nr_free_chks;
 	provisioned *= (100 - pblk->op);
 	sector_div(provisioned, 100);
 
-	pblk->op_blks = nr_free_blks - provisioned;
+	if ((nr_free_chks - provisioned) < minimum) {
+		if (geo->op != NVM_TARGET_DEFAULT_OP) {
+			pblk_err(pblk, "OP too small to create a sane instance\n");
+			return -EINTR;
+		}
+
+		/* If the user did not specify an OP value, and PBLK_DEFAULT_OP
+		 * is not enough, calculate and set sane value
+		 */
+
+		provisioned = nr_free_chks - minimum;
+		pblk->op =  (100 * minimum) / nr_free_chks;
+		pblk_info(pblk, "Default OP insufficient, adjusting OP to %d\n",
+				pblk->op);
+	}
+
+	pblk->op_blks = nr_free_chks - provisioned;
 
 	/* Internally pblk manages all free blocks, but all calculations based
 	 * on user capacity consider only provisioned blocks
 	 */
-	pblk->rl.total_blocks = nr_free_blks;
-	pblk->rl.nr_secs = nr_free_blks * geo->clba;
+	pblk->rl.total_blocks = nr_free_chks;
+	pblk->rl.nr_secs = nr_free_chks * geo->clba;
 
 	/* Consider sectors used for metadata */
 	sec_meta = (lm->smeta_sec + lm->emeta_sec[0]) * l_mg->nr_free_lines;
@@ -667,8 +684,10 @@ static void pblk_set_provision(struct pblk *pblk, long nr_free_blks)
 
 	pblk->capacity = (provisioned - blk_meta) * geo->clba;
 
-	atomic_set(&pblk->rl.free_blocks, nr_free_blks);
-	atomic_set(&pblk->rl.free_user_blocks, nr_free_blks);
+	atomic_set(&pblk->rl.free_blocks, nr_free_chks);
+	atomic_set(&pblk->rl.free_user_blocks, nr_free_chks);
+
+	return 0;
 }
 
 static int pblk_setup_line_meta_chk(struct pblk *pblk, struct pblk_line *line,
@@ -1025,13 +1044,9 @@ static int pblk_lines_init(struct pblk *pblk)
 								line->state);
 	}
 
-	if (!nr_free_chks) {
-		pblk_err(pblk, "too many bad blocks prevent for sane instance\n");
-		ret = -EINTR;
+	ret = pblk_set_provision(pblk, nr_free_chks);
+	if (ret)
 		goto fail_free_lines;
-	}
-
-	pblk_set_provision(pblk, nr_free_chks);
 
 	vfree(chunk_meta);
 	return 0;
diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c
index db55a1c89997..76116d5f78e4 100644
--- a/drivers/lightnvm/pblk-rl.c
+++ b/drivers/lightnvm/pblk-rl.c
@@ -214,11 +214,10 @@ void pblk_rl_init(struct pblk_rl *rl, int budget)
 	struct nvm_geo *geo = &dev->geo;
 	struct pblk_line_mgmt *l_mg = &pblk->l_mg;
 	struct pblk_line_meta *lm = &pblk->lm;
-	int min_blocks = lm->blk_per_line * PBLK_GC_RSV_LINE;
 	int sec_meta, blk_meta;
-
 	unsigned int rb_windows;
 
+
 	/* Consider sectors used for metadata */
 	sec_meta = (lm->smeta_sec + lm->emeta_sec[0]) * l_mg->nr_free_lines;
 	blk_meta = DIV_ROUND_UP(sec_meta, geo->clba);
@@ -226,7 +225,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget)
 	rl->high = pblk->op_blks - blk_meta - lm->blk_per_line;
 	rl->high_pw = get_count_order(rl->high);
 
-	rl->rsv_blocks = min_blocks;
+	rl->rsv_blocks = pblk_get_min_chks(pblk);
 
 	/* This will always be a power-of-2 */
 	rb_windows = budget / NVM_MAX_VLBA;
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index f415aae600c8..e5b88a25d4d6 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -905,7 +905,6 @@ int pblk_recov_check_emeta(struct pblk *pblk, struct line_emeta *emeta);
 #define PBLK_GC_MAX_READERS 8	/* Max number of outstanding GC reader jobs */
 #define PBLK_GC_RQ_QD 128	/* Queue depth for inflight GC requests */
 #define PBLK_GC_L_QD 4		/* Queue depth for inflight GC lines */
-#define PBLK_GC_RSV_LINE 1	/* Reserved lines for GC */
 
 int pblk_gc_init(struct pblk *pblk);
 void pblk_gc_exit(struct pblk *pblk, bool graceful);
@@ -1370,4 +1369,15 @@ static inline char *pblk_disk_name(struct pblk *pblk)
 
 	return disk->disk_name;
 }
+
+static inline unsigned int pblk_get_min_chks(struct pblk *pblk)
+{
+	struct pblk_line_meta *lm = &pblk->lm;
+	/* In a worst-case scenario every line will have OP invalid sectors.
+	 * We will then need a minimum of 1/OP lines to free up a single line
+	 */
+
+	return DIV_ROUND_UP(100, pblk->op) * lm->blk_per_line;
+
+}
 #endif /* PBLK_H_ */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 5/7] lightnvm: pblk: remove unused macro
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
                   ` (3 preceding siblings ...)
  2018-11-05 12:26 ` [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 6/7] lightnvm: pblk: fix pblk_lines_init error handling path Hans Holmberg
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

ADDR_POOL_SIZE is not used anymore, so remove the define.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-init.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 8b89bb26b0f1..33c1e83327c3 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -207,9 +207,6 @@ static int pblk_rwb_init(struct pblk *pblk)
 	return pblk_rb_init(&pblk->rwb, buffer_size, threshold, geo->csecs);
 }
 
-/* Minimum pages needed within a lun */
-#define ADDR_POOL_SIZE 64
-
 static int pblk_set_addrf_12(struct pblk *pblk, struct nvm_geo *geo,
 			     struct nvm_addrf_12 *dst)
 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 6/7] lightnvm: pblk: fix pblk_lines_init error handling path
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
                   ` (4 preceding siblings ...)
  2018-11-05 12:26 ` [PATCH v2 5/7] lightnvm: pblk: remove unused macro Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 12:26 ` [PATCH v2 7/7] lightnvm: pblk: remove dead code in pblk_recov_l2p Hans Holmberg
  2018-11-06  9:18 ` [PATCH v2 0/7] PBLK Bugfixes and cleanups Javier Gonzalez
  7 siblings, 0 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

The chunk metadata is allocated with vmalloc, so we need to use
vfree to free it.

Fixes: 090ee26fd512 ("lightnvm: use internal allocation for chunk log page")

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 33c1e83327c3..ae9686b5d521 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -1053,7 +1053,7 @@ static int pblk_lines_init(struct pblk *pblk)
 		pblk_line_meta_free(l_mg, &pblk->lines[i]);
 	kfree(pblk->lines);
 fail_free_chunk_meta:
-	kfree(chunk_meta);
+	vfree(chunk_meta);
 fail_free_luns:
 	kfree(pblk->luns);
 fail_free_meta:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 7/7] lightnvm: pblk: remove dead code in pblk_recov_l2p
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
                   ` (5 preceding siblings ...)
  2018-11-05 12:26 ` [PATCH v2 6/7] lightnvm: pblk: fix pblk_lines_init error handling path Hans Holmberg
@ 2018-11-05 12:26 ` Hans Holmberg
  2018-11-05 15:31   ` Sebastien Boisvert
  2018-11-06  9:18 ` [PATCH v2 0/7] PBLK Bugfixes and cleanups Javier Gonzalez
  7 siblings, 1 reply; 14+ messages in thread
From: Hans Holmberg @ 2018-11-05 12:26 UTC (permalink / raw)
  To: Matias Bjorling; +Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg

From: Hans Holmberg <hans.holmberg@cnexlabs.com>

Remove the call to pblk_line_replace_data as it returns
directly as we have not set l_mg->data_next yet.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
 drivers/lightnvm/pblk-recovery.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index 0fbd30e0a587..416d9840544b 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -805,7 +805,6 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
 		WARN_ON_ONCE(!test_and_clear_bit(meta_line,
 							&l_mg->meta_bitmap));
 		spin_unlock(&l_mg->free_lock);
-		pblk_line_replace_data(pblk);
 	} else {
 		spin_lock(&l_mg->free_lock);
 		/* Allocate next line for preparation */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas
  2018-11-05 12:26 ` [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Hans Holmberg
@ 2018-11-05 15:12   ` Sebastien Boisvert
  2018-11-06 11:52     ` Hans Holmberg
  0 siblings, 1 reply; 14+ messages in thread
From: Sebastien Boisvert @ 2018-11-05 15:12 UTC (permalink / raw)
  To: Hans Holmberg, Matias Bjorling
  Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg



On 2018-11-05 7:26 a.m., Hans Holmberg wrote:
> From: Hans Holmberg <hans.holmberg@cnexlabs.com>
> 
> Make sure we only look up valid lba addresses on the resubmission path.
> 
> If an lba is invalidated in the write buffer, that sector will be
> submitted to disk(as it is already mapped to a ppa), and that write

submitted to disk(as it is already mapped to a ppa), and that write
                 ^
                 add a space

> might fail, resulting in a crash when trying to look up the lba in the
> mapping table (as the lba is marked as invalid).
> 
> Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
> ---
>  drivers/lightnvm/pblk-write.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
> index fa8726493b39..3ddd16f47106 100644
> --- a/drivers/lightnvm/pblk-write.c
> +++ b/drivers/lightnvm/pblk-write.c
> @@ -148,9 +148,11 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry,
>  		w_ctx = &entry->w_ctx;
>  
>  		/* Check if the lba has been overwritten */
> -		ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
> -		if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
> -			w_ctx->lba = ADDR_EMPTY;
> +		if (w_ctx->lba != ADDR_EMPTY) {
> +			ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
> +			if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
> +				w_ctx->lba = ADDR_EMPTY;
> +		}

Was w_ctx->lba set to ADDR_EMPTY in the same kernel I/O thread ?

I wonder if w_ctx->lba could become ADDR_EMPTY after 

		if (w_ctx->lba != ADDR_EMPTY) {

but before

			ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);


>  
>  		/* Mark up the entry as submittable again */
>  		flags = READ_ONCE(w_ctx->flags);
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 7/7] lightnvm: pblk: remove dead code in pblk_recov_l2p
  2018-11-05 12:26 ` [PATCH v2 7/7] lightnvm: pblk: remove dead code in pblk_recov_l2p Hans Holmberg
@ 2018-11-05 15:31   ` Sebastien Boisvert
  0 siblings, 0 replies; 14+ messages in thread
From: Sebastien Boisvert @ 2018-11-05 15:31 UTC (permalink / raw)
  To: Hans Holmberg, Matias Bjorling
  Cc: Javier Gonzales, linux-block, linux-kernel, Hans Holmberg



On 2018-11-05 7:26 a.m., Hans Holmberg wrote:
> From: Hans Holmberg <hans.holmberg@cnexlabs.com>
> 
> Remove the call to pblk_line_replace_data as it returns
> directly as we have not set l_mg->data_next yet.

You have the word "as" twice. Replace the second with "because".

> 
> Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
> ---
>  drivers/lightnvm/pblk-recovery.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
> index 0fbd30e0a587..416d9840544b 100644
> --- a/drivers/lightnvm/pblk-recovery.c
> +++ b/drivers/lightnvm/pblk-recovery.c
> @@ -805,7 +805,6 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
>  		WARN_ON_ONCE(!test_and_clear_bit(meta_line,
>  							&l_mg->meta_bitmap));
>  		spin_unlock(&l_mg->free_lock);
> -		pblk_line_replace_data(pblk);
>  	} else {
>  		spin_lock(&l_mg->free_lock);
>  		/* Allocate next line for preparation */
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes
  2018-11-05 12:26 ` [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes Hans Holmberg
@ 2018-11-05 21:15   ` kbuild test robot
  2018-11-05 23:09   ` kbuild test robot
  1 sibling, 0 replies; 14+ messages in thread
From: kbuild test robot @ 2018-11-05 21:15 UTC (permalink / raw)
  To: Hans Holmberg
  Cc: kbuild-all, Matias Bjorling, Javier Gonzales, linux-block,
	linux-kernel, Hans Holmberg

[-- Attachment #1: Type: text/plain, Size: 2905 bytes --]

Hi Hans,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc1 next-20181105]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Hans-Holmberg/PBLK-Bugfixes-and-cleanups/20181106-022237
config: i386-randconfig-sb0-11060349 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/lightnvm/pblk-init.o: In function `pblk_set_provision':
>> drivers/lightnvm/pblk-init.c:668: undefined reference to `__udivdi3'

vim +668 drivers/lightnvm/pblk-init.c

   637	
   638	static int pblk_set_provision(struct pblk *pblk, long nr_free_chks)
   639	{
   640		struct nvm_tgt_dev *dev = pblk->dev;
   641		struct pblk_line_mgmt *l_mg = &pblk->l_mg;
   642		struct pblk_line_meta *lm = &pblk->lm;
   643		struct nvm_geo *geo = &dev->geo;
   644		sector_t provisioned, minimum;
   645		int sec_meta, blk_meta;
   646	
   647		if (geo->op == NVM_TARGET_DEFAULT_OP)
   648			pblk->op = PBLK_DEFAULT_OP;
   649		else
   650			pblk->op = geo->op;
   651	
   652		minimum = pblk_get_min_chks(pblk);
   653		provisioned = nr_free_chks;
   654		provisioned *= (100 - pblk->op);
   655		sector_div(provisioned, 100);
   656	
   657		if ((nr_free_chks - provisioned) < minimum) {
   658			if (geo->op != NVM_TARGET_DEFAULT_OP) {
   659				pblk_err(pblk, "OP too small to create a sane instance\n");
   660				return -EINTR;
   661			}
   662	
   663			/* If the user did not specify an OP value, and PBLK_DEFAULT_OP
   664			 * is not enough, calculate and set sane value
   665			 */
   666	
   667			provisioned = nr_free_chks - minimum;
 > 668			pblk->op =  (100 * minimum) / nr_free_chks;
   669			pblk_info(pblk, "Default OP insufficient, adjusting OP to %d\n",
   670					pblk->op);
   671		}
   672	
   673		pblk->op_blks = nr_free_chks - provisioned;
   674	
   675		/* Internally pblk manages all free blocks, but all calculations based
   676		 * on user capacity consider only provisioned blocks
   677		 */
   678		pblk->rl.total_blocks = nr_free_chks;
   679		pblk->rl.nr_secs = nr_free_chks * geo->clba;
   680	
   681		/* Consider sectors used for metadata */
   682		sec_meta = (lm->smeta_sec + lm->emeta_sec[0]) * l_mg->nr_free_lines;
   683		blk_meta = DIV_ROUND_UP(sec_meta, geo->clba);
   684	
   685		pblk->capacity = (provisioned - blk_meta) * geo->clba;
   686	
   687		atomic_set(&pblk->rl.free_blocks, nr_free_chks);
   688		atomic_set(&pblk->rl.free_user_blocks, nr_free_chks);
   689	
   690		return 0;
   691	}
   692	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29233 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes
  2018-11-05 12:26 ` [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes Hans Holmberg
  2018-11-05 21:15   ` kbuild test robot
@ 2018-11-05 23:09   ` kbuild test robot
  1 sibling, 0 replies; 14+ messages in thread
From: kbuild test robot @ 2018-11-05 23:09 UTC (permalink / raw)
  To: Hans Holmberg
  Cc: kbuild-all, Matias Bjorling, Javier Gonzales, linux-block,
	linux-kernel, Hans Holmberg

[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]

Hi Hans,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc1 next-20181105]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Hans-Holmberg/PBLK-Bugfixes-and-cleanups/20181106-022237
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/lightnvm/pblk-init.o: In function `pblk_lines_init':
>> pblk-init.c:(.text+0x1c94): undefined reference to `__aeabi_uldivmod'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 67216 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 0/7] PBLK Bugfixes and cleanups
  2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
                   ` (6 preceding siblings ...)
  2018-11-05 12:26 ` [PATCH v2 7/7] lightnvm: pblk: remove dead code in pblk_recov_l2p Hans Holmberg
@ 2018-11-06  9:18 ` Javier Gonzalez
  7 siblings, 0 replies; 14+ messages in thread
From: Javier Gonzalez @ 2018-11-06  9:18 UTC (permalink / raw)
  To: Hans Holmberg
  Cc: Matias Bjørling, linux-block, linux-kernel, Hans Holmberg

[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]

> On 5 Nov 2018, at 13.26, Hans Holmberg <hans.ml.holmberg@owltronix.com> wrote:
> 
> From: Hans Holmberg <hans.holmberg@cnexlabs.com>
> 
> This series is a slew of bugfixes and cleanups for PBLK, mostly
> fixing issues found during corner-case testing in QEMU.
> 
> Changes since v1:
> 	Messed up from:, now the patches apply with the correct author
> 	Pardon the mess.
> 
> Hans Holmberg (7):
>  lightnvm: pblk: fix resubmission of overwritten write err lbas
>  lightnvm: pblk: account for write error sectors in emeta
>  lightnvm: pblk: stop writes gracefully when running out of lines
>  lightnvm: pblk: set conservative threshold for user writes
>  lightnvm: pblk: remove unused macro
>  lightnvm: pblk: fix pblk_lines_init error handling path
>  lightnvm: pblk: remove dead code in pblk_recov_l2p
> 
> drivers/lightnvm/pblk-init.c     | 48 +++++++++++++++++-----------
> drivers/lightnvm/pblk-map.c      | 47 ++++++++++++++++-----------
> drivers/lightnvm/pblk-recovery.c |  1 -
> drivers/lightnvm/pblk-rl.c       |  5 ++-
> drivers/lightnvm/pblk-write.c    | 55 +++++++++++++++++++++++---------
> drivers/lightnvm/pblk.h          | 16 ++++++++--
> 6 files changed, 114 insertions(+), 58 deletions(-)
> 
> --
> 2.17.1


Apart from the nipticks pointed out in V2, the series look good to me.

Reviewed-by: Javier González <javier@javigon.com>


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas
  2018-11-05 15:12   ` Sebastien Boisvert
@ 2018-11-06 11:52     ` Hans Holmberg
  0 siblings, 0 replies; 14+ messages in thread
From: Hans Holmberg @ 2018-11-06 11:52 UTC (permalink / raw)
  To: sboisvert
  Cc: Matias Bjorling, Javier Gonzalez, linux-block,
	Linux Kernel Mailing List, Hans Holmberg

On Mon, Nov 5, 2018 at 4:12 PM Sebastien Boisvert <sboisvert@gydle.com> wrote:
>
>
>
> On 2018-11-05 7:26 a.m., Hans Holmberg wrote:
> > From: Hans Holmberg <hans.holmberg@cnexlabs.com>
> >
> > Make sure we only look up valid lba addresses on the resubmission path.
> >
> > If an lba is invalidated in the write buffer, that sector will be
> > submitted to disk(as it is already mapped to a ppa), and that write
>
> submitted to disk(as it is already mapped to a ppa), and that write
>                  ^
>                  add a space
>
> > might fail, resulting in a crash when trying to look up the lba in the
> > mapping table (as the lba is marked as invalid).
> >
> > Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
> > ---
> >  drivers/lightnvm/pblk-write.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
> > index fa8726493b39..3ddd16f47106 100644
> > --- a/drivers/lightnvm/pblk-write.c
> > +++ b/drivers/lightnvm/pblk-write.c
> > @@ -148,9 +148,11 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry,
> >               w_ctx = &entry->w_ctx;
> >
> >               /* Check if the lba has been overwritten */
> > -             ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
> > -             if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
> > -                     w_ctx->lba = ADDR_EMPTY;
> > +             if (w_ctx->lba != ADDR_EMPTY) {
> > +                     ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);
> > +                     if (!pblk_ppa_comp(ppa_l2p, entry->cacheline))
> > +                             w_ctx->lba = ADDR_EMPTY;
> > +             }
>
> Was w_ctx->lba set to ADDR_EMPTY in the same kernel I/O thread ?
>
> I wonder if w_ctx->lba could become ADDR_EMPTY after
>
>                 if (w_ctx->lba != ADDR_EMPTY) {
>
> but before
>
>                         ppa_l2p = pblk_trans_map_get(pblk, w_ctx->lba);

It can't, the lba adress can only be changed on the write error
handling path, and we'll have to resubmit the write before that can
happen.
Thanks for the review.

/ Hans
>
>
> >
> >               /* Mark up the entry as submittable again */
> >               flags = READ_ONCE(w_ctx->flags);
> >

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-11-06 11:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05 12:26 [PATCH v2 0/7] PBLK Bugfixes and cleanups Hans Holmberg
2018-11-05 12:26 ` [PATCH v2 1/7] lightnvm: pblk: fix resubmission of overwritten write err lbas Hans Holmberg
2018-11-05 15:12   ` Sebastien Boisvert
2018-11-06 11:52     ` Hans Holmberg
2018-11-05 12:26 ` [PATCH v2 2/7] lightnvm: pblk: account for write error sectors in emeta Hans Holmberg
2018-11-05 12:26 ` [PATCH v2 3/7] lightnvm: pblk: stop writes gracefully when running out of lines Hans Holmberg
2018-11-05 12:26 ` [PATCH v2 4/7] lightnvm: pblk: set conservative threshold for user writes Hans Holmberg
2018-11-05 21:15   ` kbuild test robot
2018-11-05 23:09   ` kbuild test robot
2018-11-05 12:26 ` [PATCH v2 5/7] lightnvm: pblk: remove unused macro Hans Holmberg
2018-11-05 12:26 ` [PATCH v2 6/7] lightnvm: pblk: fix pblk_lines_init error handling path Hans Holmberg
2018-11-05 12:26 ` [PATCH v2 7/7] lightnvm: pblk: remove dead code in pblk_recov_l2p Hans Holmberg
2018-11-05 15:31   ` Sebastien Boisvert
2018-11-06  9:18 ` [PATCH v2 0/7] PBLK Bugfixes and cleanups Javier Gonzalez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).