Received: by 10.223.185.116 with SMTP id b49csp608333wrg; Wed, 21 Feb 2018 04:04:54 -0800 (PST) X-Google-Smtp-Source: AH8x226vhEF8566aBeDIC/ddva6rlsungZMblid4dK1ulIfOUJ1pU9C+VFT9+7iJsvniG3c2r5+V X-Received: by 10.99.117.10 with SMTP id q10mr2532631pgc.423.1519214694319; Wed, 21 Feb 2018 04:04:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519214694; cv=none; d=google.com; s=arc-20160816; b=lOrhCQZSaYosmPL2kjIYZXKHa9lU3vmtk9qHKy7X96zTcptlpIh0BodhqWAVqi3Ri4 Wf443ri9HIuxlF5pOWTIC1Cp2Y82Kno2K+2D12C4hIkYTUtCxdALIuZ/7Ez3icYdBE3F bbjEYZhKz+YZvUbqyLSkWg8A/oI6OB+sENcQP/R+Ki5kmf+L76fo0o7TOVhb5zdlfvdh NvkXlmIDlqvYzpCsYP0xb73RxnzUtSvqutrShNuOwpO0uKbHbvXZ2QvFtlINSgam/WF2 gSklD+JPGqW2vUvWCFNUiFacuIBgF5ucefU9ZWUtcNylZeE4p0q527OFeuneWwIRjPvu mwPw== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=9GCLp+GAQ7g+vogivdv81a+16RLHNF4/9QXdR2hBMUY=; b=MdTfoeuAsyPubAJr+QngMOiMHimWEvc2f3BX7q9sImnrTzhz3+GTo51zxKeS5ogQzR AD4cRcCzL4wPstCpUM4E993gFOqX4FWPa0p59nG7qb9IFm/jVlbIZKXogH2SnMtgDkVP au0GgG36m3eP+x3h+F38r5oGxfTpKSo6yzrijan5/AvbyWDffy98vO+qkhUCTQOLSnXS BcsYrOUDXSug6JFIAdpUvJ2DCmzLjYDj66AmMUUfOwnnTe3+FTeLy7SWpE+9NvzEeFa6 8Vjjv5JX+VC0CrZZIxd+4AbNpOIMDK5adkNGdh00b8KbbYDzXkFIQ6UHh+JdCQhiiJJ4 GKmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=EmL/io1T; 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 w27si1285762pfl.142.2018.02.21.04.04.39; Wed, 21 Feb 2018 04:04:54 -0800 (PST) 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=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=EmL/io1T; 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 S1752372AbeBUIXA (ORCPT + 99 others); Wed, 21 Feb 2018 03:23:00 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:46042 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293AbeBUIW6 (ORCPT ); Wed, 21 Feb 2018 03:22:58 -0500 Received: by mail-lf0-f67.google.com with SMTP id x196so1124761lfd.12 for ; Wed, 21 Feb 2018 00:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9GCLp+GAQ7g+vogivdv81a+16RLHNF4/9QXdR2hBMUY=; b=EmL/io1T5MI/qlmOPOY5ye2tm6sukVAzU4tHylFkyRWAa7hK8nisDs7MUPFC4mamms H1p9n5CfNJb+3vE3GPaMfEJl3EnYZpao3b2ZuPoe0QEHEObkIVR1/Dvegmvua8WpOtY0 oWpBw0/58eIixB3DlUGQCSC2TgP3VulyQbYo7k776VZnk9DEOJOCFidmo2HrkZdSYKeF a7hJWlJAzLa5gSIUtTDgPzJMA6h10RvRtepULgdaEuTczMsrsDIOXKKvo6tHt2MH98qx y/gd7yCIQlaWUeNEspjpl1PrqaTnFRQwoJMJzVoHIfLThLt3t24mM3k/q1C4SHlRn18Z un1g== 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:mime-version :content-transfer-encoding; bh=9GCLp+GAQ7g+vogivdv81a+16RLHNF4/9QXdR2hBMUY=; b=BqjkIZG/O/7glACiEBt+Iwz71mcquo7WKvIp0FgFA86NVJClcE6JCX9UZXmkCTewub 2OTC8O0JhudU2jBnFQrjqCx0h3Ojov3ZvwGLffBOD83RjnSC328pPBLKErYjzAHiBPlX P4GYzPufQ0PZoUBvb6zsdZjeimSY6J5wQyAi+oUwLNUnFgVjPf2cQR01cLUqLJXNgHxB 1DTlzTSksjWlSCIYGWpNlnMYbUqd8uZTJStC5G6PRmFw6Y4s2Kzfddc0R92m6Ub66BkI Tz5jAgoz4hrbXpMs8vYpIpnveLGCzKpEgCASXGcuoBkQODXGhHO3Wo6EPChKKh7Hhbhg MZ8w== X-Gm-Message-State: APf1xPCzMEtSMo6PHxcBJId/9aYKBt/8ttWRlmwnUtS1rImHN5mFX5Di jsrrt6NToKLwXBJmn4AIrdo7ag== X-Received: by 10.46.109.18 with SMTP id i18mr1668780ljc.19.1519201377315; Wed, 21 Feb 2018 00:22:57 -0800 (PST) Received: from titan.bredbandsbolaget.se (c-b9b6e655.03-91-6d6c6d4.cust.bredbandsbolaget.se. [85.230.182.185]) by smtp.gmail.com with ESMTPSA id v2sm5788732ljv.11.2018.02.21.00.22.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 00:22:56 -0800 (PST) From: hans.ml.holmberg@owltronix.com To: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Cc: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH] lightnvm: pblk: don't recover unwritten lines Date: Wed, 21 Feb 2018 09:22:32 +0100 Message-Id: <1519201352-15806-1-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 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 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 --- NOTE: This patch applies on top of the 2.0 patches since it depends on chunk data structures to be in place. 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 1574dbb..24ad021 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; -- 2.7.4