From patchwork Thu Mar 29 22:05:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10316487 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 5ECAD60383 for ; Thu, 29 Mar 2018 22:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A9602A4C2 for ; Thu, 29 Mar 2018 22:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F8482A534; Thu, 29 Mar 2018 22:08:14 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 CB89C2A4C2 for ; Thu, 29 Mar 2018 22:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752643AbeC2WHp (ORCPT ); Thu, 29 Mar 2018 18:07:45 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:41363 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752785AbeC2WHn (ORCPT ); Thu, 29 Mar 2018 18:07:43 -0400 Received: by mail-lf0-f68.google.com with SMTP id o102-v6so10325236lfg.8 for ; Thu, 29 Mar 2018 15:07:43 -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=70D6ItBMDqjRHr87Vs4xZQbwhPzQhrSqf0xA/H+t7lY=; b=rCHOUMWZTKa9jBYyLZVnrrh6cBzaWjFHOJ+wIUIleuA0+CSaZG3FYxTHGqmohZ9Tt8 WZGsiuD4p/I/g29tLDjFdkTb6D2zGiCU8pAycxHRmp873EffdZLCa0Vb33K5zUBXGdsp y2cxCJPjaajvtF3V/ZDWpNzAE64rIAr1Zf7j9NRNPrtQnAQtFw2KhRsRyRss25XY8Qe1 DVAV9B4Z9a9pSpKg56DO5CowCpeazxG/iREj/R2WF65Om2E3pzNq51LHCuRXH+0W2ZNb MMIh8AshEGzNr6/tkoR87gpqN3++dIYK/urIKJLC2MZTFavjbtkWQ/dU+wddZVRpDugP AApA== 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=70D6ItBMDqjRHr87Vs4xZQbwhPzQhrSqf0xA/H+t7lY=; b=tOLnP8JHXsCfUcqey9BjqGVy0PRvgG2j1P1vSHk0epdSZVH4JtPaecUsjY+wj1SC2x ZEHHCieP7bgBudtohs2Agix/GXPVfs94jkEgnNGiBZlKf9a4qzZF281ZSl9Bln/WHzml kfBiLLARZiH72S1p1mjDVVA12rKHcx01qRKeOWT5rDFEUTzWoEvAjNfOEYeqjHo2s/xK +jS7oEh65+UnE6GQWH6tOVLdRVVmEXWDcQRyl14zQjWh3IT0spMCQByt4dNMjgcnMYg0 tJUHNSQfsEkBdY8mfDxpQG2/24+eFg8Yg5vou6YZjvSjAU3SNWfMSsmXhHBh47So/dvR xnBw== X-Gm-Message-State: AElRT7FWYq8GeO+iuMkkhH9F1S92Sx4JLehI0vrqV6+R0RM5CvoMeeg9 mGtx1hlv/KtCdvkN0PG1y0DKeQ== X-Google-Smtp-Source: AIpwx49NX3YJe3vRn3Ug75tkLXMNzwUZXTCz5jLzUW/myRBbV7XFv0+32EhWDSOXcwS+Df27frzZdw== X-Received: by 10.46.23.70 with SMTP id l67mr6306814lje.132.1522361257498; Thu, 29 Mar 2018 15:07:37 -0700 (PDT) Received: from Macroninja.cnexlabs.com (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.gmail.com with ESMTPSA id i89-v6sm1365508lfk.12.2018.03.29.15.07.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 15:07:36 -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, keith.busch@intel.com, javier@cnexlabs.com, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 35/37] lightnvm: pblk: don't recover unwritten lines Date: Fri, 30 Mar 2018 00:05:22 +0200 Message-Id: <20180329220524.30363-36-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180329220524.30363-1-mb@lightnvm.io> References: <20180329220524.30363-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: Hans Holmberg If the line has not been written to, we should not try to recover any data from it, so check the state of the chunks in the line before attempting to read smeta. Signed-off-by: Hans Holmberg Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-recovery.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 26356429dc72..3e079c2afa6e 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -864,6 +864,21 @@ static void pblk_recov_wa_counters(struct pblk *pblk, } } +static int pblk_line_was_written(struct pblk_line *line, + struct pblk_line_meta *lm) +{ + + int i; + int state_mask = NVM_CHK_ST_OFFLINE | NVM_CHK_ST_FREE; + + for (i = 0; i < lm->blk_per_line; i++) { + if (!(line->chks[i].state & state_mask)) + return 1; + } + + return 0; +} + struct pblk_line *pblk_recov_l2p(struct pblk *pblk) { struct pblk_line_meta *lm = &pblk->lm; @@ -900,6 +915,9 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk) line->lun_bitmap = ((void *)(smeta_buf)) + sizeof(struct line_smeta); + if (!pblk_line_was_written(line, lm)) + continue; + /* Lines that cannot be read are assumed as not written here */ if (pblk_line_read_smeta(pblk, line)) continue;