Received: by 10.192.165.156 with SMTP id m28csp468482imm; Mon, 16 Apr 2018 03:30:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49aBcQ9pEsO83WsljUbP01P8SkcwGumMBubtAmCu6Wk4ZfyeNXgStMCWpqecMN2a7QjfPGC X-Received: by 10.99.110.6 with SMTP id j6mr12097011pgc.29.1523874658166; Mon, 16 Apr 2018 03:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523874658; cv=none; d=google.com; s=arc-20160816; b=vfb8tthNx0KQtgSIgzBSCn/JAPVvbZrNQ4I5DiTxDZz19geEY5K1ixPg10KPrZivp3 rThtrprrS9ypKLkj4N4q8bnRESw8bPbMAi08QB4rPb78Do/ZGtC06hzo3uoh58ZZpk5o gaJ+hbguSgBYQRqAgQsu6SEYdA4FM8jDzPTvIeXlW+vOo6abjj/dX2asSDenE7nlC3Hs NryiIEvL7je+GwYsE0u7JAewRYizrAQNqPvya8BSj6B8fYSiQpxHw/6P8Xz2vtgKjXhu 4Oi1Ndbl/KS78BeLAxbbOGA+bj64BtYhGWL9XBGCFT5JhQouf5FyLznD7FQMyEgNaTc9 NMhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=E5+tnqiU/rH3sIWSmBqvhMxJ9Pu3xOLsbpF30uGBJR4=; b=BcrjNXNtLMJZdcydzirlECpqiL9gsbHjh0cH4Fexyy3tSu+aekDXaEJhqSzdL4fvGJ uNWdFKjktJDXHgFWDi37M48MNFZGj4xo8il9jWwXk3szxlNCIrRsAjFIOFrGnYBkoSlS 0LFealndsMPo56TAd2G/UmTGOG+O1rlGOrg5bPBZNJ+AVXX4yN+eP8F6lKksf9fAIZWs Yi7+t6YoltOmSR3JHoa0BmhmnwY2FbYriK1OiNg0+twVeHaetazEw0Mf0e7vbZCYFBdg iP9V0hZSa93HFo3e9Mscod8CdU7kg24UnnQdYHL0fjcKHCASTt0Y3kiXtZ8dhCOUZc6D g2Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=YhW/LJ4q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h82si10590957pfd.288.2018.04.16.03.30.44; Mon, 16 Apr 2018 03:30:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=YhW/LJ4q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754829AbeDPK2I (ORCPT + 99 others); Mon, 16 Apr 2018 06:28:08 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36934 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbeDPKZo (ORCPT ); Mon, 16 Apr 2018 06:25:44 -0400 Received: by mail-wr0-f196.google.com with SMTP id l49so24435273wrl.4 for ; Mon, 16 Apr 2018 03:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=javigon-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E5+tnqiU/rH3sIWSmBqvhMxJ9Pu3xOLsbpF30uGBJR4=; b=YhW/LJ4qe2vNxXjXqkCBEzFybHSP7b/MqJ+tSFbg2SHMUjOiBA82wJEV0QOgVNRQkX +bifncRbc6q+MHqXCtJKiLQV4eqxnR2K3KU0w6SwikfEOAfUkFbA4tD7Neg3+7L/s/qz reLqkKecvovzwWcpywBR+2oRTr8os8i4o2FGV7KthkPlGeLHP0ETB1dgrIjbxDzmRhDu +etFfeX92H8Us3JzlwtOOKJwDkK/F8ZE2foBj6KoxfFxQH5z1TCW7vDY8oP0vHV8aZkl TT0sYH4q18wJupe0tOpk1l41pkBAxTg4Dga4F0QD4WGuRP9akZeAFmRNiROVa0VRBn0H b7kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E5+tnqiU/rH3sIWSmBqvhMxJ9Pu3xOLsbpF30uGBJR4=; b=QI7p16bq8vXCL8Mv5jBooQwhMBsFWcNq95v7SQgZbEXmfX0mW6bs6Wqrdg/c/3U37C cnT6s5Z9k1rp83FZ3kuVN4fSL9IF5YfeRBnmwBkCDPcPA/h7PD3Hy09rx0QP3OBspjek rmgJ7myD2p0odg+VJcYfe6jSSVQ9NKusSX6I31mFrd+0GmhbHShk9onpLgK8AE0yLY/c y318DXDtyAhRRybi4+cTn+JcOQTzOpbzr2A5QHkC2FpfSbqZ6fNEP+dDD9TaZ+2FR81v UHZppGwiD5qMXyS8A7M8JTs24djAKELILgCwa7jpoSlLD6jvjaFZ4aHFx9MmvNSQs161 Z19A== X-Gm-Message-State: ALQs6tDjFJxJn9IrHIghnQC3OLN6Clx4lt+YGAad5Hrg3Ih0kngoWBbh mErDbUFJp2fWJ2+h9mjPPwRaZhE0 X-Received: by 10.80.143.196 with SMTP id y62mr32383900edy.275.1523874343173; Mon, 16 Apr 2018 03:25:43 -0700 (PDT) Received: from uhalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id q11sm4250074edj.2.2018.04.16.03.25.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 03:25:42 -0700 (PDT) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 03/11] lightnvm: pblk: check read lba on gc path Date: Mon, 16 Apr 2018 12:25:24 +0200 Message-Id: <1523874332-6272-4-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523874332-6272-1-git-send-email-javier@cnexlabs.com> References: <1523874332-6272-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check that the lba stored in the LBA metadata is correct in the GC path too. This requires a new helper function to check random reads in the vector read. Signed-off-by: Javier González --- drivers/lightnvm/pblk-read.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c index 9eee10f69df0..0d45d4ffc370 100644 --- a/drivers/lightnvm/pblk-read.c +++ b/drivers/lightnvm/pblk-read.c @@ -113,15 +113,14 @@ static int pblk_submit_read_io(struct pblk *pblk, struct nvm_rq *rqd) return NVM_IO_OK; } -static void pblk_read_check(struct pblk *pblk, struct nvm_rq *rqd, - sector_t blba) +static void pblk_read_check_seq(struct pblk *pblk, void *meta_list, + sector_t blba, int nr_lbas) { - struct pblk_sec_meta *meta_list = rqd->meta_list; - int nr_lbas = rqd->nr_ppas; + struct pblk_sec_meta *meta_lba_list = meta_list; int i; for (i = 0; i < nr_lbas; i++) { - u64 lba = le64_to_cpu(meta_list[i].lba); + u64 lba = le64_to_cpu(meta_lba_list[i].lba); if (lba == ADDR_EMPTY) continue; @@ -130,6 +129,32 @@ static void pblk_read_check(struct pblk *pblk, struct nvm_rq *rqd, } } +/* + * There can be wholes in the lba list. + */ +static void pblk_read_check_rand(struct pblk *pblk, void *meta_list, + u64 *lba_list, int nr_lbas) +{ + struct pblk_sec_meta *meta_lba_list = meta_list; + int i, j; + + for (i = 0, j = 0; i < nr_lbas; i++) { + u64 lba = lba_list[i]; + u64 meta_lba; + + if (lba == ADDR_EMPTY) + continue; + + meta_lba = le64_to_cpu(meta_lba_list[j++].lba); + + if (lba != meta_lba) { + pr_err("pblk: corrupted read LBA (%llu/%llu)\n", + lba, meta_lba); + WARN_ON(1); + } + } +} + static void pblk_read_put_rqd_kref(struct pblk *pblk, struct nvm_rq *rqd) { struct ppa_addr *ppa_list; @@ -172,7 +197,7 @@ static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd, WARN_ONCE(bio->bi_status, "pblk: corrupted read error\n"); #endif - pblk_read_check(pblk, rqd, r_ctx->lba); + pblk_read_check_seq(pblk, rqd->meta_list, r_ctx->lba, rqd->nr_ppas); bio_put(bio); if (r_ctx->private) @@ -585,6 +610,8 @@ int pblk_submit_read_gc(struct pblk *pblk, struct pblk_gc_rq *gc_rq) goto err_free_bio; } + pblk_read_check_rand(pblk, rqd.meta_list, gc_rq->lba_list, rqd.nr_ppas); + atomic_dec(&pblk->inflight_io); if (rqd.error) { -- 2.7.4