Received: by 10.192.165.156 with SMTP id m28csp1753476imm; Tue, 17 Apr 2018 05:06:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+yusy8Zm0HnrTAwLEHqcKJpepHq1ooJawKU/DQOruW96hzfqobhrdYXYXnpOG/7SrKAWX4 X-Received: by 2002:a17:902:8f96:: with SMTP id z22-v6mr1788307plo.200.1523966765793; Tue, 17 Apr 2018 05:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523966765; cv=none; d=google.com; s=arc-20160816; b=qOlo6TCJohcOaRsg1oU9cLn8qU+Wky5LegVojXOpL+3yZnm1X74twnpryeQr1aI9yW pYwGRkoOKst9cP1EVr8sMOYBH1FlMpgZZt7AzlbhtWKUE70JLUID7xE0gyrLo+a4c9Ij uzJ+KrrAifkhNqqhpq3ICa2+12oA7F4O4VF7p8J5uz5q04fZRFuWOJ+19PZh3dOOEda6 xYI67vEeojdjjTzso26pzMZc0oa2W+hiT/d18FHeEsbbhovtiJDX8oG4YXwjz33hkfzy 7JJQglv808qSF1/JI9yWYtrUBHaWsojudCyXhli3mxvLJpQDGHaBp/UPPovRzOFD32Ym ccSQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=HE/+bRFhzsrqxmG70cZa67ouhEdtaKWvHlU8pvxUBfc=; b=Pu2dEbSUxsqTAmFrcPL4PHBVP15rrSy5Zx7hrY338W5oqpKUYoaIrQz+pRa9OCR0yR kCk3gZfpnI9hzlIY2Gpx9Er3qZ+viYPcfZE3bZyQt4D7Z6dDoscYiTjfThD+zSN2Qmgd 9wvjJUelPP2dopwRC2lJ+O76/sPBhmRBTd17VEbBB0R3dAoyBD6/ezkO2VVaNv0VhOI8 FGCUmRz15JEtmHWTSd2A6DuE9qN7Hu2Oon1Yi8whBEa+DtQmnPviJu8NPiTikIkFt7tS Xm19QhiEm+5mL4ppZysILyxUQiyVT1LqWvY7lIUOSVCvJ5RKuiHvmWGJEDzh5KgRrA7C unuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=cRxPysjo; 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 a98-v6si2770999pla.239.2018.04.17.05.05.50; Tue, 17 Apr 2018 05:06:05 -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=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=cRxPysjo; 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 S1752999AbeDQMEO (ORCPT + 99 others); Tue, 17 Apr 2018 08:04:14 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:39219 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747AbeDQMEM (ORCPT ); Tue, 17 Apr 2018 08:04:12 -0400 Received: by mail-pg0-f67.google.com with SMTP id b9so5311545pgf.6 for ; Tue, 17 Apr 2018 05:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HE/+bRFhzsrqxmG70cZa67ouhEdtaKWvHlU8pvxUBfc=; b=cRxPysjoWNaOsXjOIFF5WcoTNXHi9f+sIj88FiwfFSDMHhTWL3Ibj/gTtKOQk3J/Re AD6iCPH4JJwG1TiwX+k3aSIj9k0H2+pql9atDGZMElArbEFft7zdQDRLXDFkTW9QlAsB ILBR7zSZyLKbdi4P2nKbO9VGzGJBB40FF+5ERY991botHWL7fbA0SVT3DQOAuSmi/5KJ uAldHjVnS/Z6y39p/FO4wEqnENOBNqgscUpyb1drzt2aOf4AgsoBluimx6eYSRPfU302 IkIrfGHjVyOYzW69Ge0PiorCVaqUmaXIuTfxVUtLatANuyQx+4d+YQ8qUtPhOH7TZjXG uMQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HE/+bRFhzsrqxmG70cZa67ouhEdtaKWvHlU8pvxUBfc=; b=H+orEcJpHCuHiFQA9f54IL/8/y/652ASeyOU5Nnn+hg4Gr6rsexXR/BtstA+WB0SwJ bhhi98AxFf+XUz2E4XPO0wr2aRwV54/Ia7mI4SPK545Cqu6MEdkmOXXvZO+pTCv7kU8w shTx+7jYNDi5vXV6TJGHdUcoHqlHNWA9Yhh/cjhBAY+/M9x+X0ckIZvE+SwZXbdBmjjb o8vB4X9lGpsCF5oKKOTHaXsldVS6J+5fjKxyR929yAEfqFUFgww505aZIwDJOMdu3DjJ 3FZk7tQdpk8KzVDPVKLI9tKrYa1Wd+pQj0QJUvzc+PwT0gVLfc5nAt92+7kUPx+3+q+1 ZCVA== X-Gm-Message-State: ALQs6tDY7K47eJSk5rvL606ZSwrjrzSM7dHkQj8uRaVKWaAhe8rcbuT7 LwaS0cXdibTz3w/JWH7KhZkZCg== X-Received: by 10.99.110.5 with SMTP id j5mr1608787pgc.246.1523966651822; Tue, 17 Apr 2018 05:04:11 -0700 (PDT) Received: from C02VV2HXHV2Q.local ([104.153.224.169]) by smtp.gmail.com with ESMTPSA id o88sm31029042pfk.91.2018.04.17.05.04.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 05:04:10 -0700 (PDT) Subject: Re: [PATCH 03/11] lightnvm: pblk: check read lba on gc path To: =?UTF-8?Q?Javier_Gonz=c3=a1lez?= Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Javier_Gonz=c3=a1lez?= References: <1523874332-6272-1-git-send-email-javier@cnexlabs.com> <1523874332-6272-4-git-send-email-javier@cnexlabs.com> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: Date: Tue, 17 Apr 2018 14:03:52 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1523874332-6272-4-git-send-email-javier@cnexlabs.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/16/18 12:25 PM, Javier González wrote: > 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. > + */ holes > +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); You can move the j++ into the for loop. Although, why not use just the i iterator? > + > + if (lba != meta_lba) { > + pr_err("pblk: corrupted read LBA (%llu/%llu)\n", > + lba, meta_lba); > + WARN_ON(1); I don't understand this, if a corrupted LBA is found here, how is it communicated back to pblk and the LBA can be recovered from elsewhere. If the data is wrong, this should have been communicated by the drive on the completion path. The drive is defect if this happens. > + } > + } > +} > + > 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) { >