From patchwork Wed Feb 21 08:22:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10231437 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 CDE8260385 for ; Wed, 21 Feb 2018 08:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7FB1289A3 for ; Wed, 21 Feb 2018 08:23:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9BB628A69; Wed, 21 Feb 2018 08:23:00 +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=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 34CDB289A3 for ; Wed, 21 Feb 2018 08:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752324AbeBUIW7 (ORCPT ); Wed, 21 Feb 2018 03:22:59 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:40005 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752280AbeBUIW6 (ORCPT ); Wed, 21 Feb 2018 03:22:58 -0500 Received: by mail-lf0-f66.google.com with SMTP id 37so1133874lfs.7 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=uc6qMfs4f628X6WbCTwMVj4n2TgG7cF0RZWRgoK7Nf679MrUSC2BxFLzN94+Ec0OVe sUtAjJ2+3SjYxRJNCupyvFf7LQVvGe0D51gseIILFvF70pQOvzs1LoLt7ADWe31YAl3o qKmQmur21mlBiIKdLo95R4Sf3IYTj2IXs6tjOtOV1w+KohJj1+5eMuyHyK/AjLG4ZoqE 0nAjIJClOvsIpTnP8Ma41m2WbT7uy+N6SCzmzeXhC+V1hgTt3gGS9i9BYFQf5UAwx4rO PhDp7VYYs1t+TR81vpA4d4Up/F+8HmrhlEVK5OjD6FNMNt+pnJCumjMbVHQLtPe+KtmJ NUzQ== X-Gm-Message-State: APf1xPDalUHaiYEydZ2MVhEyuVPOJO8jWksRvL72BstkQzyIbTV37id6 zNM76CMhXI6ua7NJiYcoCefKFA== X-Google-Smtp-Source: AH8x226m8pwkO9tMaB0DFQttqiRIigyNlGyQuXcOEGLzcPVnBYXtggZLHoRyqa2W24h2UfSkroKyDA== 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 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 --- 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;