Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9156f360 authored by Hans Holmberg's avatar Hans Holmberg Committed by Jens Axboe
Browse files

lightnvm: pblk: don't recover unwritten lines



If the line has not been written to, we should not
try to recover any data from it, so check the state of the
chunks in the line before attempting to read smeta.

Signed-off-by: default avatarHans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <mb@lightnvm.io>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3b2a3ad1
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -864,6 +864,21 @@ static void pblk_recov_wa_counters(struct pblk *pblk,
	}
}

static int pblk_line_was_written(struct pblk_line *line,
			    struct pblk_line_meta *lm)
{

	int i;
	int state_mask = NVM_CHK_ST_OFFLINE | NVM_CHK_ST_FREE;

	for (i = 0; i < lm->blk_per_line; i++) {
		if (!(line->chks[i].state & state_mask))
			return 1;
	}

	return 0;
}

struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
{
	struct pblk_line_meta *lm = &pblk->lm;
@@ -900,6 +915,9 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
		line->lun_bitmap = ((void *)(smeta_buf)) +
						sizeof(struct line_smeta);

		if (!pblk_line_was_written(line, lm))
			continue;

		/* Lines that cannot be read are assumed as not written here */
		if (pblk_line_read_smeta(pblk, line))
			continue;