From patchwork Tue Nov 6 13:33:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10670427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 344F61803 for ; Tue, 6 Nov 2018 13:34:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21DCA2A3D4 for ; Tue, 6 Nov 2018 13:34:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1693E2A3E0; Tue, 6 Nov 2018 13:34:14 +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=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 B4A5E2A3D4 for ; Tue, 6 Nov 2018 13:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388351AbeKFW67 (ORCPT ); Tue, 6 Nov 2018 17:58:59 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:36725 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388244AbeKFW66 (ORCPT ); Tue, 6 Nov 2018 17:58:58 -0500 Received: by mail-it1-f193.google.com with SMTP id w7-v6so17603627itd.1 for ; Tue, 06 Nov 2018 05:33:42 -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:in-reply-to:references; bh=cnKaeRoQQa8i6RB5+OFZeMivpWgE29k57o0EeueExqw=; b=LA6L1IQUzuO7LC97IoxUFJ778GmWPnjKnd181fn1Ini/4EZFzqI2WR7H1iV8OHKZ16 AbXJVL6bANE3obMTJwdjHkF06XuAAjZXaMmeOl98MLlBqzbEPoEcOzTpAAkXz9RKN5We 0sKl1qCIHXKlOaH16rV/6rA9LUblii89utgG5byK4b418tC3c7DgWm3p5qtcDEfEuJ38 eNMKT1qdvwYEGJEKvpxcXOv9PO6unuvguxfvm5yteT+QjbkOzNAQ4BMbFDzSpmxqz15/ OSbmI9J5Cv+Vyc3eHnV/Qs9SpmyqhPVjX/T2KUHjCjHechMin4nceQN5zbzUbGAEeyc/ f06w== 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=cnKaeRoQQa8i6RB5+OFZeMivpWgE29k57o0EeueExqw=; b=MLnIJTZDbEGxRy5G/dkhDy9NyDsbJJwr7WQ4KCGRlsT6x5ieH9KIhCRBwJ+GJnr926 LJRJ0TwzoInfP3ItgBbBGu09NivLnlBTm3R2liffJuVq5lbdwTUSmEOjent5FamVc+76 jJpMOtXRzZ4gsr3Gv9wn+VWiUnNWltW4c6fXt23sewThyKm6EUn0O5gFVCXC3CC30j4K JA1Va7oj+JNNy7Q0I33fia0LOw4k6YGvqBz3g3PklaHGyRADfgyYFeYUj5CLmfpGTCIE DgsA3ZqBxoNKDMAblGzQBZn9JHqLdArBJqPsrMxiulB+lXwceadv4V5pGfQi2k4QgjhS Rp1A== X-Gm-Message-State: AGRZ1gLHICHzORVUuMUuX8B29lU7vPWchxmktMoi1UiH6RhNP3LxGatu zLsrCsJ1rSre5l3mV+Etw0jz82oYT5KddA== X-Google-Smtp-Source: AJdET5c9JGSZL+3CGhx0pmgvDHQlJdOwX0yjQFs41YDdKAFmrYMLXMOTeUw4TnidTWXXreij/iK2Jg== X-Received: by 2002:a24:59c1:: with SMTP id p184-v6mr1986559itb.93.1541511222242; Tue, 06 Nov 2018 05:33:42 -0800 (PST) Received: from ch-lap-hans.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id u132-v6sm897282itb.21.2018.11.06.05.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 05:33:41 -0800 (PST) From: Hans Holmberg To: Matias Bjorling Cc: Javier Gonzales , Sebastien Boisvert , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH v3 2/7] lightnvm: pblk: account for write error sectors in emeta Date: Tue, 6 Nov 2018 14:33:25 +0100 Message-Id: <20181106133330.26570-3-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106133330.26570-1-hans.ml.holmberg@owltronix.com> References: <20181106133330.26570-1-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 Lines inflicted with write errors lines might be recovered if they have not been recycled after write error garbage collection. Ensure that the emeta accounting of valid lbas is correct for such lines to avoid recovery inconsistencies. Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-write.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index 3ddd16f47106..750f04b8a227 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -105,14 +105,20 @@ static void pblk_complete_write(struct pblk *pblk, struct nvm_rq *rqd, } /* Map remaining sectors in chunk, starting from ppa */ -static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa) +static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa, + int rqd_ppas) { struct pblk_line *line; struct ppa_addr map_ppa = *ppa; + __le64 addr_empty = cpu_to_le64(ADDR_EMPTY); + __le64 *lba_list; u64 paddr; int done = 0; + int n = 0; line = pblk_ppa_to_line(pblk, *ppa); + lba_list = emeta_to_lbas(pblk, line->emeta->buf); + spin_lock(&line->lock); while (!done) { @@ -121,10 +127,17 @@ static void pblk_map_remaining(struct pblk *pblk, struct ppa_addr *ppa) if (!test_and_set_bit(paddr, line->map_bitmap)) line->left_msecs--; + if (n < rqd_ppas && lba_list[paddr] != addr_empty) + line->nr_valid_lbas--; + + lba_list[paddr] = addr_empty; + if (!test_and_set_bit(paddr, line->invalid_bitmap)) le32_add_cpu(line->vsc, -1); done = nvm_next_ppa_in_chk(pblk->dev, &map_ppa); + + n++; } line->w_err_gc->has_write_err = 1; @@ -202,7 +215,7 @@ static void pblk_submit_rec(struct work_struct *work) pblk_log_write_err(pblk, rqd); - pblk_map_remaining(pblk, ppa_list); + pblk_map_remaining(pblk, ppa_list, rqd->nr_ppas); pblk_queue_resubmit(pblk, c_ctx); pblk_up_rq(pblk, c_ctx->lun_bitmap);