Received: by 10.192.165.156 with SMTP id m28csp857857imm; Mon, 16 Apr 2018 09:48:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx48BcZuTRMYe8GtIy2iiyR6rs2m5T+zBOkk+lUDJsX+kfX0QtWDwGM5r3ceIHRwhN1O9e4ay X-Received: by 10.99.99.68 with SMTP id x65mr9739039pgb.34.1523897327468; Mon, 16 Apr 2018 09:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523897327; cv=none; d=google.com; s=arc-20160816; b=M9hGu0EhX2cMSXPHcXAV4eqR7/RDNQHI7nyzw/+CpSqYz2YPI2SY0ksOxQcMm+ik5P O8IHZzOhEEqGzfX2PIN01iQlmchqHp0SPce7f2/9umnqV7bCwgxOzzGb+gpYePnDuvVm 6iG0aOiRembwGRZ2JuN52WuA9NILBNwIvj5U0ogCwJZDorgrZpHYzC2slOJL+Q+lscvR 1l3BnhXidaTuuKh0uIr88Zff6qugX+rZBZVhc+tX7hTSBQIsdeWEuQz5oyBg2s2UQkDG oz/CRe9j9VE/Esf+VGUBtkT6YcDZvXdbenU/8FgseoZ72Xv+NeNDFUSdYb48djOu6TM3 7Dig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=LG90FDD/qhyAhiYQF/ZJlhTKccgHRWbxOeG5RfkLIh8=; b=fxDVCqPs7LJIthgzmQv4uz0svn9qWqI1iO3ZLlyCijF/nCPPIYlVgpWscDY3iHTjuM N1KfuMoOr9enE6+kHfYGKJSbGCTzusn2S+gpy5sgrBIpfZTWq8jb4h9iM4I1sjqhdGaI mqGRrRhnTmoZyPZyN5aZR4LRPfN6k+PETIa4X5g1HptaG/y0wvWHcq9PSJzrH30f+VXi aeegVytXGYUuz7J5ORE5yyhtKTMXBbfjcAoq5AxQ0+tt0w2ubi7fqiHXj0oQ6Dm3g3SE FH7WmMu4+lyQdlhJ071jtwodMSwe7ZatgtlY9WUERNxh+nULL7AKElSqCOWloWrzHTv0 tRXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=HI8zAPk1; 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 t16si11183312pfj.10.2018.04.16.09.48.33; Mon, 16 Apr 2018 09:48:47 -0700 (PDT) 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=HI8zAPk1; 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 S1752900AbeDPQrO (ORCPT + 99 others); Mon, 16 Apr 2018 12:47:14 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34354 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752359AbeDPQqu (ORCPT ); Mon, 16 Apr 2018 12:46:50 -0400 Received: by mail-lf0-f66.google.com with SMTP id r7-v6so15994756lfr.1 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=rUUwYAhG6qkWMnnatIH1O0BXoAsmoI2j7SrT7UWR0YDfcytS251iY8DGJ5yPM+lXxu ehlQE3ahjH7EPip9GYA6gg25iyKSzPL9VSDft7/3TnHTEO/KxrAhacDAkAuhmfXkw8mj GqffaJ6S1NqSuHNPsij9H7gz0am3fa2lq4bE0ie2e5yvggOvAXHPLqfBdU6q0rJKLOqv G7soSu7cS5zj8y/s5dejPvZPaZ96ZdxRTJeN/axWnycyS1zYcLSvd+2EJuaHnYv+4npY Elru8HjSWm+iXWlO/E2wl7by1HtFShfDgwYQ86Coc2JJchx5AkhgA9zJScYBqkaYBITC 9VTg== X-Gm-Message-State: ALQs6tCJ1Gyk8d8HFZM8SfjmOjoCVpk7f9PSSP+TfLrcWesHvTHpfG3E wAAp8Bb0Oxy1iSwhJvl9D1AmHQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.7.4