diff mbox

[2/9] lightnvm: pblk: recover partially written lines correctly

Message ID 1507025113-13351-3-git-send-email-hans.ml.holmberg@owltronix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hans Holmberg Oct. 3, 2017, 10:05 a.m. UTC
From: Hans Holmberg <hans.holmberg@cnexlabs.com>

When recovering partially written lines, the valid sector
count must be decreased by the number of padded sectors
in the line.

Update line recovery to take all ADDR_EMPTY(padded) sectors
into account.

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

Comments

=?UTF-8?q?Javier=20Gonz=C3=A1lez?= Oct. 3, 2017, 10:28 a.m. UTC | #1
> On 3 Oct 2017, at 12.05, Hans Holmberg <hans.ml.holmberg@owltronix.com> wrote:
> 
> From: Hans Holmberg <hans.holmberg@cnexlabs.com>
> 
> When recovering partially written lines, the valid sector
> count must be decreased by the number of padded sectors
> in the line.
> 
> Update line recovery to take all ADDR_EMPTY(padded) sectors
> into account.
> 
> Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
> ---
> drivers/lightnvm/pblk-recovery.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
> index 1869eef..74b3b86 100644
> --- a/drivers/lightnvm/pblk-recovery.c
> +++ b/drivers/lightnvm/pblk-recovery.c
> @@ -133,8 +133,8 @@ static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line)
> 	struct pblk_emeta *emeta = line->emeta;
> 	struct line_emeta *emeta_buf = emeta->buf;
> 	__le64 *lba_list;
> -	int data_start;
> -	int nr_data_lbas, nr_valid_lbas, nr_lbas = 0;
> +	int data_start, data_end;
> +	int nr_valid_lbas, nr_lbas = 0;
> 	int i;
> 
> 	lba_list = pblk_recov_get_lba_list(pblk, emeta_buf);
> @@ -142,10 +142,10 @@ static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line)
> 		return 1;
> 
> 	data_start = pblk_line_smeta_start(pblk, line) + lm->smeta_sec;
> -	nr_data_lbas = lm->sec_per_line - lm->emeta_sec[0];
> +	data_end = lm->sec_per_line - lm->emeta_sec[0];
> 	nr_valid_lbas = le64_to_cpu(emeta_buf->nr_valid_lbas);
> 
> -	for (i = data_start; i < nr_data_lbas && nr_lbas < nr_valid_lbas; i++) {
> +	for (i = data_start; i < data_end; i++) {
> 		struct ppa_addr ppa;
> 		int pos;
> 
> --
> 2.7.4

LGTM.

Reviewed-by: Javier González <javier@cnexlabs.com>
diff mbox

Patch

diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index 1869eef..74b3b86 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -133,8 +133,8 @@  static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line)
 	struct pblk_emeta *emeta = line->emeta;
 	struct line_emeta *emeta_buf = emeta->buf;
 	__le64 *lba_list;
-	int data_start;
-	int nr_data_lbas, nr_valid_lbas, nr_lbas = 0;
+	int data_start, data_end;
+	int nr_valid_lbas, nr_lbas = 0;
 	int i;
 
 	lba_list = pblk_recov_get_lba_list(pblk, emeta_buf);
@@ -142,10 +142,10 @@  static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line)
 		return 1;
 
 	data_start = pblk_line_smeta_start(pblk, line) + lm->smeta_sec;
-	nr_data_lbas = lm->sec_per_line - lm->emeta_sec[0];
+	data_end = lm->sec_per_line - lm->emeta_sec[0];
 	nr_valid_lbas = le64_to_cpu(emeta_buf->nr_valid_lbas);
 
-	for (i = data_start; i < nr_data_lbas && nr_lbas < nr_valid_lbas; i++) {
+	for (i = data_start; i < data_end; i++) {
 		struct ppa_addr ppa;
 		int pos;