All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Javier González" <jg@lightnvm.io>
To: mb@lightnvm.io
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Hans Holmberg <hans.holmberg@cnexlabs.com>
Subject: [PATCH 1/5] lightnvm: pblk: handle bad sectors in the emeta area correctly
Date: Wed, 31 Jan 2018 03:06:47 +0100	[thread overview]
Message-ID: <1517364411-22386-1-git-send-email-javier@cnexlabs.com> (raw)

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

Unless we check if there are bad sectors in the entire emeta-area
we risk ending up with valid bitmap / available sector count inconsistency.
This results in lines with a bad chunk at the last LUN marked as bad,
so go through the whole emeta area and mark up the invalid sectors.

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

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 0487b9340c1d..9027cf2ed1d8 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -1021,6 +1021,7 @@ static int pblk_line_init_bb(struct pblk *pblk, struct pblk_line *line,
 	int nr_bb = 0;
 	u64 off;
 	int bit = -1;
+	int emeta_secs;
 
 	line->sec_in_line = lm->sec_per_line;
 
@@ -1055,18 +1056,18 @@ static int pblk_line_init_bb(struct pblk *pblk, struct pblk_line *line,
 	/* Mark emeta metadata sectors as bad sectors. We need to consider bad
 	 * blocks to make sure that there are enough sectors to store emeta
 	 */
-	off = lm->sec_per_line - lm->emeta_sec[0];
-	bitmap_set(line->invalid_bitmap, off, lm->emeta_sec[0]);
-	while (nr_bb) {
+	emeta_secs = lm->emeta_sec[0];
+	off = lm->sec_per_line;
+	while (emeta_secs) {
 		off -= geo->sec_per_pl;
 		if (!test_bit(off, line->invalid_bitmap)) {
 			bitmap_set(line->invalid_bitmap, off, geo->sec_per_pl);
-			nr_bb--;
+			emeta_secs -= geo->sec_per_pl;
 		}
 	}
 
-	line->sec_in_line -= lm->emeta_sec[0];
 	line->emeta_ssec = off;
+	line->sec_in_line -= lm->emeta_sec[0];
 	line->nr_valid_lbas = 0;
 	line->left_msecs = line->sec_in_line;
 	*line->vsc = cpu_to_le32(line->sec_in_line);
-- 
2.7.4

             reply	other threads:[~2018-01-31  2:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  2:06 Javier González [this message]
2018-01-31  2:06 ` [PATCH 2/5] lightnvm: pblk: check data lines version on recovery Javier González
2018-01-31  2:06 ` [PATCH 3/5] lightnvm: pblk: export write amplification counters to sysfs Javier González
2018-01-31  2:06 ` [PATCH 4/5] lightnvm: pblk: add padding distribution sysfs attribute Javier González
2018-01-31  8:44   ` Matias Bjørling
2018-02-06  9:27     ` Hans Holmberg
2018-02-06  9:27       ` Hans Holmberg
2018-02-06 10:50       ` Matias Bjørling
2018-02-06 11:28         ` Hans Holmberg
2018-02-06 11:28           ` Hans Holmberg
2018-01-31  2:06 ` [PATCH 5/5] lightnvm: pblk: refactor bad block identification Javier González
2018-01-31  8:51   ` Matias Bjørling
2018-01-31  9:13     ` Javier Gonzalez
2018-01-31  9:13       ` Javier Gonzalez
2018-01-31 18:24       ` Matias Bjørling
2018-02-04 10:37         ` Javier Gonzalez
2018-02-04 12:54           ` Matias Bjørling
2018-02-04 13:09             ` Javier Gonzalez
2018-02-04 13:09               ` Javier Gonzalez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517364411-22386-1-git-send-email-javier@cnexlabs.com \
    --to=jg@lightnvm.io \
    --cc=hans.holmberg@cnexlabs.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@lightnvm.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.