All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Hans Holmberg" <hans.holmberg@cnexlabs.com>,
	"Javier González" <javier@cnexlabs.com>,
	"Matias Bjørling" <m@bjorling.me>
Subject: [PATCH 12/25] lightnvm: pblk: refactor emeta consistency check
Date: Wed, 20 Dec 2017 18:21:52 +0100	[thread overview]
Message-ID: <20171220172205.26464-13-m@bjorling.me> (raw)
In-Reply-To: <20171220172205.26464-1-m@bjorling.me>

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

Currently pblk_recov_get_lba list does two separate things:
it checks the consistency of the emeta and extracts the lba list.

This patch separates the consistency check to make the code easier
to read and to prepare for version checks of the line emeta
persistent data format version.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/lightnvm/pblk-gc.c       |  9 ++++++++-
 drivers/lightnvm/pblk-recovery.c | 15 ++++++++++-----
 drivers/lightnvm/pblk.h          |  2 +-
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
index 00d5698..9e3f22b 100644
--- a/drivers/lightnvm/pblk-gc.c
+++ b/drivers/lightnvm/pblk-gc.c
@@ -169,7 +169,14 @@ static void pblk_gc_line_prepare_ws(struct work_struct *work)
 	 * the line untouched. TODO: Implement a recovery routine that scans and
 	 * moves all sectors on the line.
 	 */
-	lba_list = pblk_recov_get_lba_list(pblk, emeta_buf);
+
+	ret = pblk_recov_check_emeta(pblk, emeta_buf);
+	if (ret) {
+		pr_err("pblk: inconsistent emeta (line %d)\n", line->id);
+		goto fail_free_emeta;
+	}
+
+	lba_list = emeta_to_lbas(pblk, emeta_buf);
 	if (!lba_list) {
 		pr_err("pblk: could not interpret emeta (line %d)\n", line->id);
 		goto fail_free_emeta;
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c
index 1b272ae..39a2e19 100644
--- a/drivers/lightnvm/pblk-recovery.c
+++ b/drivers/lightnvm/pblk-recovery.c
@@ -111,18 +111,18 @@ int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx,
 	return 0;
 }
 
-__le64 *pblk_recov_get_lba_list(struct pblk *pblk, struct line_emeta *emeta_buf)
+int pblk_recov_check_emeta(struct pblk *pblk, struct line_emeta *emeta_buf)
 {
 	u32 crc;
 
 	crc = pblk_calc_emeta_crc(pblk, emeta_buf);
 	if (le32_to_cpu(emeta_buf->crc) != crc)
-		return NULL;
+		return 1;
 
 	if (le32_to_cpu(emeta_buf->header.identifier) != PBLK_MAGIC)
-		return NULL;
+		return 1;
 
-	return emeta_to_lbas(pblk, emeta_buf);
+	return 0;
 }
 
 static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line)
@@ -137,7 +137,7 @@ static int pblk_recov_l2p_from_emeta(struct pblk *pblk, struct pblk_line *line)
 	u64 nr_valid_lbas, nr_lbas = 0;
 	u64 i;
 
-	lba_list = pblk_recov_get_lba_list(pblk, emeta_buf);
+	lba_list = emeta_to_lbas(pblk, emeta_buf);
 	if (!lba_list)
 		return 1;
 
@@ -938,6 +938,11 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk)
 			goto next;
 		}
 
+		if (pblk_recov_check_emeta(pblk, line->emeta->buf)) {
+			pblk_recov_l2p_from_oob(pblk, line);
+			goto next;
+		}
+
 		if (pblk_recov_l2p_from_emeta(pblk, line))
 			pblk_recov_l2p_from_oob(pblk, line);
 
diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
index 7b09fb2..f324a7e 100644
--- a/drivers/lightnvm/pblk.h
+++ b/drivers/lightnvm/pblk.h
@@ -808,7 +808,7 @@ int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq);
 void pblk_submit_rec(struct work_struct *work);
 struct pblk_line *pblk_recov_l2p(struct pblk *pblk);
 int pblk_recov_pad(struct pblk *pblk);
-__le64 *pblk_recov_get_lba_list(struct pblk *pblk, struct line_emeta *emeta);
+int pblk_recov_check_emeta(struct pblk *pblk, struct line_emeta *emeta);
 int pblk_recov_setup_rq(struct pblk *pblk, struct pblk_c_ctx *c_ctx,
 			struct pblk_rec_ctx *recovery, u64 *comp_bits,
 			unsigned int comp);
-- 
2.9.3

  parent reply	other threads:[~2017-12-20 17:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 17:21 [PATCH 00/25] Updates to lightnvm and pblk Matias Bjørling
2017-12-20 17:21 ` [PATCH 01/25] null_blk: remove lightnvm support Matias Bjørling
2017-12-20 17:21 ` [PATCH 02/25] lightnvm: remove rrpc Matias Bjørling
2017-12-20 17:21 ` [PATCH 03/25] lightnvm: use internal pblk methods Matias Bjørling
2017-12-20 17:21 ` [PATCH 04/25] lightnvm: remove hybrid ocssd 1.2 support Matias Bjørling
2017-12-20 17:21 ` [PATCH 05/25] lightnvm: remove unnecessary field from nvm_rq Matias Bjørling
2017-12-20 17:21 ` [PATCH 06/25] lightnvm: remove lower page tables Matias Bjørling
2017-12-20 17:21 ` [PATCH 07/25] lightnvm: make geometry structures 2.0 ready Matias Bjørling
2017-12-20 17:21 ` [PATCH 08/25] lightnvm: refactor target type lookup Matias Bjørling
2017-12-20 17:21 ` [PATCH 09/25] lightnvm: guarantee target unique name across devs Matias Bjørling
2017-12-20 17:21 ` [PATCH 10/25] lightnvm: pblk: compress and reorder helper functions Matias Bjørling
2017-12-20 17:21 ` [PATCH 11/25] lightnvm: pblk: remove pblk_for_each_lun helper Matias Bjørling
2017-12-20 17:21 ` Matias Bjørling [this message]
2017-12-20 17:21 ` [PATCH 13/25] lightnvm: pblk: rename sync_point to flush_point Matias Bjørling
2017-12-20 17:21 ` [PATCH 14/25] lightnvm: pblk: clear flush point on completed writes Matias Bjørling
2017-12-28 13:19   ` [PATCH v2] " Hans Holmberg
2017-12-20 17:21 ` [PATCH 15/25] lightnvm: pblk: prevent premature sync point resets Matias Bjørling
2017-12-20 17:21 ` [PATCH 16/25] lightnvm: pblk: remove pblk_gc_stop Matias Bjørling
2017-12-20 17:21 ` [PATCH 17/25] lightnvm: pblk: use exact free block counter in RL Matias Bjørling
2017-12-20 17:21 ` [PATCH 18/25] lightnvm: set target over-provision on create ioctl Matias Bjørling
2017-12-20 17:21 ` [PATCH 19/25] lightnvm: pblk: ignore high ecc errors on recovery Matias Bjørling
2017-12-20 17:22 ` [PATCH 20/25] lightnvm: pblk: do not log recovery read errors Matias Bjørling
2017-12-20 17:22 ` [PATCH 21/25] lightnvm: pblk: ensure kthread alloc. before kicking it Matias Bjørling
2017-12-20 17:22 ` [PATCH 22/25] lightnvm: pblk: free write buffer on init failure Matias Bjørling
2017-12-20 17:22 ` [PATCH 23/25] lightnvm: pblk: print instance name on instance info Matias Bjørling
2017-12-20 17:22 ` [PATCH 24/25] lightnvm: pblk: add iostat support Matias Bjørling
2017-12-20 17:22 ` [PATCH 25/25] lightnvm: pblk: refactor pblk_ppa_comp function Matias Bjørling

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=20171220172205.26464-13-m@bjorling.me \
    --to=m@bjorling.me \
    --cc=hans.holmberg@cnexlabs.com \
    --cc=javier@cnexlabs.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.