From patchwork Mon Apr 16 16:46:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10343481 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 5E9F4601D7 for ; Mon, 16 Apr 2018 16:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50E74286C2 for ; Mon, 16 Apr 2018 16:47:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 453E8286F7; Mon, 16 Apr 2018 16:47:44 +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 C3694286F3 for ; Mon, 16 Apr 2018 16:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753025AbeDPQrm (ORCPT ); Mon, 16 Apr 2018 12:47:42 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:46908 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752308AbeDPQqu (ORCPT ); Mon, 16 Apr 2018 12:46:50 -0400 Received: by mail-lf0-f65.google.com with SMTP id j68-v6so23077319lfg.13 for ; Mon, 16 Apr 2018 09:46:49 -0700 (PDT) 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:in-reply-to:references; bh=LG90FDD/qhyAhiYQF/ZJlhTKccgHRWbxOeG5RfkLIh8=; b=HI8zAPk19RqpQlYxbINfH02cKO+2Gm+8eo81nr274hldw4mptgtN+z0YOvxyCFtAvC u8J8wgVawBzsaUzoZv5qSSS/4ygpkrvcgrll6V0DhumdvNiCds/mDX1JycU887/PQLCe Rdr6kKTUjypOqm6MXWg6tDaVh8BYa0y1RSl/MUXehHz73r8PP8brrbOcEc11R0kE9SZ6 avUiR7rLZxP4nl/OdoWK1YTxKFEwgJbpf6AKfvJjKk4L34grST263XpSQm1hbA0/6Rtw QzLOmMc0TErVUrPhTN4Arazt+BPh2l0HCmafi2YGJkrzvZqH/O2dJJZN1pNk+g9FLNAL q93w== 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; bh=LG90FDD/qhyAhiYQF/ZJlhTKccgHRWbxOeG5RfkLIh8=; b=s7+9ATlbAmUMyeDFo8ys1SBx+ggCN4TVb4lqF2dIXap3m4EFUuquvPDC0TlN0Vgv8U am0ZqdSGq3UWSTad5Fj5gy/n5sIBO6ZqHVade/Bx3psJFXLixDh1lda0yuxWY+zDu1Ll 4yoHmfSboSlL61dVATg2lkB2X2qeVHxuJ7I/Z4Klr/fuCj3SeCWAMlVyn4VQsk5aaMbo ID6W+cjk7jO9HVgAJT9yOFbUBN/wLHLA487sm1gvH5GCBdBgqgxTyth7pEsdgSfyjGKy jYUvNPfI5q4iK+6bFGaI2hUZCuEuErWV0x9f8Sajv6ew4BBTabe5hx1VeQk548FJFOMP kAbw== X-Gm-Message-State: ALQs6tCjk9LilbULXQsiKdMWAIGgu0fFo3XOeKnyZ01SLvSDp+4wcHNN JacNqZsOjT0Soa2JHzTiU3YqQA== X-Google-Smtp-Source: AIpwx49gBxXRPz6blgfQyLLyiKJf3yKFmVYd19cFQFwLRW6ewX4shsup+6cSO6PvxIOkHq/nuPkf1A== X-Received: by 10.46.53.11 with SMTP id z11mr7882555ljz.69.1523897209075; Mon, 16 Apr 2018 09:46:49 -0700 (PDT) Received: from titan.bredbandsbolaget.se (c-b9b6e655.03-91-6d6c6d4.cust.bredbandsbolaget.se. [85.230.182.185]) by smtp.gmail.com with ESMTPSA id f200-v6sm2953241lff.35.2018.04.16.09.46.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 09:46:48 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, Javier Gonzales , linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH 1/2] lightnvm: pblk: only try to recover lines with written smeta Date: Mon, 16 Apr 2018 18:46:15 +0200 Message-Id: <1523897176-6241-2-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523897176-6241-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1523897176-6241-1-git-send-email-hans.ml.holmberg@owltronix.com> 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 When switching between different lun configurations, there is no guarantee that all lines that contain closed/open chunks have some valid data to recover. Check that the smeta chunk has been written to instead. Also skip bad lines (that does not have enough good chunks). Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-recovery.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 3e079c2..9cb6d5d 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -865,18 +865,30 @@ static void pblk_recov_wa_counters(struct pblk *pblk, } static int pblk_line_was_written(struct pblk_line *line, - struct pblk_line_meta *lm) + struct pblk *pblk) { - int i; - int state_mask = NVM_CHK_ST_OFFLINE | NVM_CHK_ST_FREE; + struct pblk_line_meta *lm = &pblk->lm; + struct nvm_tgt_dev *dev = pblk->dev; + struct nvm_geo *geo = &dev->geo; + struct nvm_chk_meta *chunk; + struct ppa_addr bppa; + int smeta_blk; - for (i = 0; i < lm->blk_per_line; i++) { - if (!(line->chks[i].state & state_mask)) - return 1; - } + if (line->state == PBLK_LINESTATE_BAD) + return 0; - return 0; + smeta_blk = find_first_zero_bit(line->blk_bitmap, lm->blk_per_line); + if (smeta_blk >= lm->blk_per_line) + return 0; + + bppa = pblk->luns[smeta_blk].bppa; + chunk = &line->chks[pblk_ppa_to_pos(geo, bppa)]; + + if (chunk->state & NVM_CHK_ST_FREE) + return 0; + + return 1; } struct pblk_line *pblk_recov_l2p(struct pblk *pblk) @@ -915,7 +927,7 @@ 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)) + if (!pblk_line_was_written(line, pblk)) continue; /* Lines that cannot be read are assumed as not written here */