Received: by 10.192.165.148 with SMTP id m20csp3556316imm; Mon, 30 Apr 2018 02:14:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+z0S1HC1AEXU78YqbB2EA7AtuusTMoMh2lgkQUjzZYFTEBNEPoX3g+UBLc8dXSgNKt7KD X-Received: by 2002:a17:902:7d09:: with SMTP id z9-v6mr11875315pll.4.1525079665764; Mon, 30 Apr 2018 02:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079665; cv=none; d=google.com; s=arc-20160816; b=A190ixJlOYUzaopjCaEdd+j+Co5sLteAkj9Kw0MyZ77auej7Kj2Iao4Bko/lo5Uvqv UG2QteReoW8kC9+HEJDAZad4aBzQtZYbbAr4/pVnKRsRw1xmw2IW0K43kFFpaWe/Gf/I obqMW0F+6QH5HyaY7WLdzAlhFyxPBXDU+1Fca1N2sbmi7ANhTDdQqVPL0ai7DVm+EGnP ywnjHET1DKqDvjv9GfK8DBhHOCG0P++tgs/k/bCvmaAYDB89Y3snT8l50zjYzmhQbvki ulzZaxodobmES5B9VJRt9V/7dLRdnT3yFf/4q3ljN754sHdjzhkt82rEwwb1Y9SZMrBC Yu4w== 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=tQfHYBJQixXQVUp0e+tGdxGyMYnhFS72rUP0+za03bY=; b=tFGSgHFTNDtYz8UPd4O9Tu5/hAIQEtGDvtXXS3lGlm7lbDjW4Y4CXzQpFKZXvQ3+tL 3nI/RatBSLyK3Lgx71Wek62FB9fsaf10oQys8qQbZJbW/ISdqNH2CzgVVAUsO2w67f/q GVxQu5+Lua9Jk/EcSYplkKFca5HZZKt7OxWaUQwoyCWH1XfEX5YyH1IXilaR/Sg6uB+l kXApvpUiZAuqzfwDug/ZQhD4TK8XLkvBbhmcgVtbsZW3a5XXX2lP3U/PsJk+mwtcXHXB SPeYecO55GJXyiFflBTyrHGMbfZPH+3rDFXDwob0yIEHkHGpOs971Dj+SXdLX2P7ADaH LX4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=ato8hN64; 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 e16-v6si5837223pgq.322.2018.04.30.02.14.06; Mon, 30 Apr 2018 02:14:25 -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=ato8hN64; 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 S1753621AbeD3JNa (ORCPT + 99 others); Mon, 30 Apr 2018 05:13:30 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54149 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753624AbeD3JKU (ORCPT ); Mon, 30 Apr 2018 05:10:20 -0400 Received: by mail-wm0-f65.google.com with SMTP id a67so4328461wmf.3 for ; Mon, 30 Apr 2018 02:10:19 -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=tQfHYBJQixXQVUp0e+tGdxGyMYnhFS72rUP0+za03bY=; b=ato8hN64ctGw2yl1RHFBjKb3qI6//h2oQcJoPl+dYA7x/g4AeI3ltdgq+ap88tlZ4B 3O6LMf94X1En/ILVikG25pbLoTAW02lmMtQtSs0TI+nzFmH4zjJEmzw0B2kA/W+Lzmlj hMCQmTvq+be+uT/+8px6kkrsQlJiSDDMGJz2b8T98QGAk8gc59m2hahcwr9JA66XBdC0 syCx9cxStfyequ+4EldZRQ0fAFzvgyI7fmAHjVVA8c8457PjRmXqvK9Il9cPQC09n3MF eaDjJPDUvxK1RSs+P1H2ZqmnEC42PXlzsCLAnTGHaHYUsuTkEMEbMepUJX/Ep5ZipVvl FK5Q== 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=tQfHYBJQixXQVUp0e+tGdxGyMYnhFS72rUP0+za03bY=; b=bB4tFkejbd0TdUUl+XwaICp532cbKTpmzQ8+JnDZ8NkQ5FBQvjdNvum+sRh6iET7Fp sJPbiG9mzlv/VStZG6vlLfDlAHepO3I0EPA7HqCwEzLGkw/Z27/GqtsqCHKmh3zBCrQc GsCm2yLwSAwZedC9UYJPyD2SK4BThQGfRT6vboi+Ejmzaxjv3taUzpoRdEa6phRZVeEW PM9NIRB8Yq9sCebrEvqUEYbdQMMEVuINRBKzvWrTpNX+PeWpNJjnHQyBVglkL5/hmvAY MvcweJMyELEt4UXG7WhjFwdZa7Ih57tpbrB4Lqx5Yh328JryY+ZJKezr3f50dbxHgKGJ 5ykg== X-Gm-Message-State: ALQs6tDbmqr1Plg7DrmuiNRkUN+JpGs4bs6epeNmAeyntojQRQY+adJB KKaVgfVNGSsRowU2ROMC/H1RVA== X-Received: by 2002:a50:92a6:: with SMTP id k35-v6mr15599789eda.110.1525079419017; Mon, 30 Apr 2018 02:10:19 -0700 (PDT) Received: from uhalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id b56-v6sm2108638edd.85.2018.04.30.02.10.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Apr 2018 02:10:18 -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, 30 Apr 2018 11:10:01 +0200 Message-Id: <1525079409-6588-4-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525079409-6588-1-git-send-email-javier@cnexlabs.com> References: <1525079409-6588-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..1f699c09e0ea 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 holes 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