From patchwork Fri Jun 1 13:04:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10443307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F3386601D3 for ; Fri, 1 Jun 2018 13:04:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4EE3289AE for ; Fri, 1 Jun 2018 13:04:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D937428D7B; Fri, 1 Jun 2018 13:04:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A8AE289AE for ; Fri, 1 Jun 2018 13:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752019AbeFANEw (ORCPT ); Fri, 1 Jun 2018 09:04:52 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37011 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750850AbeFANEs (ORCPT ); Fri, 1 Jun 2018 09:04:48 -0400 Received: by mail-lf0-f67.google.com with SMTP id r2-v6so14721651lff.4 for ; Fri, 01 Jun 2018 06:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aPRIwDLwkCc0KXhs0lNV0+qKnXkCRtGpLe3RK/ohic4=; b=IDUUZXVznBt5TNveQw9fzcuaxhSjiasxcZyqaazx6SUNeXTCHM2+lGKurdWWmizDRu 1mPwUMxA69P4JM24soYYZUvaFcjjOvQGLWaXze21BS/KY8cyB04eg0tuTWSQy+aK9nwY H+GHbao0Uv+WlCW1pLBT5nbj8HI7oB2IcL7xlF6jPz0dflQYvQGHnfUB/4EwNRMfsufK DwaIjUZ04jM+LQ+Pm6ZehHPu/nKUoQBDDY+NjWWRc9FCpVtRp2aRtLd+ydZLvlKGaOR9 6i4Y4VpbGYQqFrcjaM4qDX70TnMGRlihzJpnI3OZ6eY7iFbX4picDkE3BJgJFJ6Vx9+4 2PnA== 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=aPRIwDLwkCc0KXhs0lNV0+qKnXkCRtGpLe3RK/ohic4=; b=lXl/ntfj6eYrR/qZ53lAM4/7TpLUpEeP4K19cDIXniEhC/mOrjaKiE2DF51ca/2cPs qz8JxSL5zgLN4ldMW1BOHNIkLPdiV/IkXH89hk8Y+c5X8McKMQwszWRumcJztTKk6+Bs 4BvTk8dZGallaoIbTK3LEO7nzRuCUsrguTArqI9K1bF5WNMdXiLUv04pMXvqs+EdPy2O swC7AfL7Fae1yJx0blj0Tp4httFjpiP/q3QVVLfl6Ncj//zsMmKPyUODv8cUN54q/KCh pB+QzoDWbrhDYoLhCKx3jCLn8ezGO1VNDXErAOuHb+LrwzvvJNimAu3WBqlJosOpd3bA qLog== X-Gm-Message-State: ALKqPwdE2AqzouVWVZwpkFEtpuzvZdh5j48jLE7zQZpfS/PJThLzgeQp R1hSzN3JTRCfUj2dWDyrmf3FDw== X-Google-Smtp-Source: ADUXVKJxiQV/rO8HXd6tzHpCczQBB+adARi1IZtdNdfwzJQEhEAH5PDxYJVBRHcJCPfiZeJ2q3wF5Q== X-Received: by 2002:a2e:934f:: with SMTP id m15-v6mr4907409ljh.39.1527858286900; Fri, 01 Jun 2018 06:04:46 -0700 (PDT) Received: from Macroninja.cnexlabs.com (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id g5-v6sm303161lje.21.2018.06.01.06.04.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 06:04:46 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, javier@cnexlabs.com, igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 03/18] lightnvm: pblk: check read lba on gc path Date: Fri, 1 Jun 2018 15:04:17 +0200 Message-Id: <20180601130432.30866-4-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180601130432.30866-1-mb@lightnvm.io> References: <20180601130432.30866-1-mb@lightnvm.io> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier González 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 Signed-off-by: Matias Bjørling --- 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) {