From patchwork Fri Jun 1 14:41:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10443645 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 3B83A602BD for ; Fri, 1 Jun 2018 14:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E35B2860A for ; Fri, 1 Jun 2018 14:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D8728944; Fri, 1 Jun 2018 14:45:12 +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 C3A282860A for ; Fri, 1 Jun 2018 14:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751693AbeFAOop (ORCPT ); Fri, 1 Jun 2018 10:44:45 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44897 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437AbeFAOoF (ORCPT ); Fri, 1 Jun 2018 10:44:05 -0400 Received: by mail-lf0-f67.google.com with SMTP id 36-v6so13260924lfr.11 for ; Fri, 01 Jun 2018 07:44:04 -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=IoMj0i1WwSi3hH6LSz9EQAQwic4BgMJ8z08dFz4WZyM=; b=lQNaeVpKHmoN6KkuHJPMzWOW49Pm8LUYST+T0cMliB3xkuMXTY+UG4B9thI8dly/Gt 0/O+PvmZXvE3Ivfn4SOGDwUqrrRSaoWQu1b57UOXDxNj4+JV2SrMk1GvCwVu1XEdGZwi 5qU8Dd14ZyEfPtmiOiiObWxxJd6P/OSJLaLaqdr+i/nYyBDRv8sLhraAM7+084NVXmLh QX400NG5nSqXpNDKYPZUnEaEZG4Ccz6XFTKRMb51Aqh4ahLOdnUQavENpmN7yV5+0qiu QJk2/wjsafP04wf8ocIx0qyXQxNuiRAsCmTomJk0I/0KhNZiKLiEnnEZmnVZg6RCaZZ0 BGVQ== 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=IoMj0i1WwSi3hH6LSz9EQAQwic4BgMJ8z08dFz4WZyM=; b=FFH9YxYsTspobef1HQAPBtUGDKoaL+fhZJuepsDm8Cmg6l4YqFx7cYBKNmWUlE+dY7 kywDz0YqqgNTLRRPofc9nn8bJAxUWRvOiFTvZm8C1d1MTlNOG5wcx54L4w0DLYqgVIw/ /lUyFW/gpkhT+1VJtU3+YCy3gJiGot+cpmdJ9X+aRfDuCt455kppVgzfTetH97Ds+rHW N3iTXBk+1WdERMc+gY5W0ejGiYjR9hokFKfr9MF8e2gr8Otb9gt6YZmvtEXYketzQM3z YM/TMUGVzNmaVrA1FbyqtMNhg+x73XSmF+GiJxSoXZENYHUER/uYpsGwMCbjaa423Iz/ 2/Wg== X-Gm-Message-State: ALKqPwcTKIb2SdXFePyeUNYsr0PsL2ab9AYCfsx7YKWncV87OaaCNFLJ f/oVug/EvDeLFdIAP3aNSbzk+A== X-Google-Smtp-Source: ADUXVKIQqg7Zvn08xEoMA3uM8T7fpdcID/ABFiPG5uEpG7Vd9Fz96xTU+wvcpmtsc14AbIgNMKc5UQ== X-Received: by 2002:a2e:8759:: with SMTP id q25-v6mr8300968ljj.66.1527864243364; Fri, 01 Jun 2018 07:44:03 -0700 (PDT) Received: from Macroninja.cnexlabs.com (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id e65-v6sm356488lff.13.2018.06.01.07.44.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 07:44:02 -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, javier@cnexlabs.com, igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 08/10] lightnvm: pblk: only try to recover lines with written smeta Date: Fri, 1 Jun 2018 16:41:12 +0200 Message-Id: <20180601144114.17490-9-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180601144114.17490-1-mb@lightnvm.io> References: <20180601144114.17490-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 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 Signed-off-by: Matias Bjørling --- 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 788dce87043e..598342833d0d 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -774,18 +774,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) @@ -824,7 +836,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 */