From patchwork Mon May 28 08:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10430121 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 70CFE60249 for ; Mon, 28 May 2018 09:02:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6419228AD9 for ; Mon, 28 May 2018 09:02:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58BF728BDC; Mon, 28 May 2018 09:02:41 +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=unavailable 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 D395228AD9 for ; Mon, 28 May 2018 09:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754203AbeE1I7D (ORCPT ); Mon, 28 May 2018 04:59:03 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54136 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754160AbeE1I6y (ORCPT ); Mon, 28 May 2018 04:58:54 -0400 Received: by mail-wm0-f67.google.com with SMTP id a67-v6so30046658wmf.3 for ; Mon, 28 May 2018 01:58:53 -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=QeA96vCfhqwt3cDFjJRrCkFTX8UM4cKTHDehMwvzEwZve+EomXPtZTVIyNLpNNUAOQ ej8h27AcpVX3NwcFRSKFB2D/SasGjRUEHUHA4MNzy3SfYc2lKy2K1/gFXS1FnG2anOBQ 7ZqQ2HTdlcntu6c7VN/u2sTYsA7xRZ2MY2A10tv7ucOXR++aTpXXuCJWyf0xYBsWnvHJ rQMElfRBF1AY24/ZlEO2Z24VqmgtC7Vvl39+Y3Wr2NrtgJbb0m5/40YTjnGnwBKafN/n iqtrL6n1Baf6KSpgaU++iAlh8xE7+D69LykiPK9l0pYHN9LFtBONjj/7LkRQ3pZ1KB0W 7EEQ== 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=gDQng7eHvG51it9XeRUShA+gnlOXmP+M2uSi0V2LxR4XQ1pfpAOLGP9400qc9ZkjBg 1+KuK4R+chYpNWtm7LPHypezxnN3p9aXnt5ajZ/Q7SiMqXvZ705am7FLqtBJ4iAl0swB mymJOW9g2eYAKrAnEEghjmdHv9cWJbSXIJ0q1ALEv3Cxjfei9YUg5fMZt+vVASbMjSd9 BLp/knGzJgNedkP1G/w/V26rKRLWgWebVGORhCG6TM3Jh8vca7CYWKGqmkjUXxwlyh/4 v376IHiwAgmrYG91AuYPbWwPeMav3vGCPDWSl/i+FzZOwYaLoyEA+IjmrsZfQ88OyIR3 gINg== X-Gm-Message-State: ALKqPweQEiaJxAvZREzVSmpHKEUZaIS1nNZg8em+zCyU16PdTIM98XqB nP05i1C9bM+aQlHlgPOXueWfXvBQ X-Google-Smtp-Source: ADUXVKImEOy7IQUewPAps6Dog3kyoQvwbq4OX2RXqDdvvsyJxuLcJlAMatTwHyntEFStZe20OiWsZw== X-Received: by 2002:a2e:7310:: with SMTP id o16-v6mr7839550ljc.29.1527497933118; Mon, 28 May 2018 01:58:53 -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 u2-v6sm5777848lji.4.2018.05.28.01.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 01:58:52 -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, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 03/20] lightnvm: pblk: check read lba on gc path Date: Mon, 28 May 2018 10:58:24 +0200 Message-Id: <20180528085841.26684-4-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180528085841.26684-1-mb@lightnvm.io> References: <20180528085841.26684-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) {