From patchwork Mon Nov 5 12:26:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10668129 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 49B0A1751 for ; Mon, 5 Nov 2018 12:27:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AD95294D9 for ; Mon, 5 Nov 2018 12:27:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F3FE294E2; Mon, 5 Nov 2018 12:27:23 +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 C6709294E1 for ; Mon, 5 Nov 2018 12:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728961AbeKEVqS (ORCPT ); Mon, 5 Nov 2018 16:46:18 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:42012 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729402AbeKEVqR (ORCPT ); Mon, 5 Nov 2018 16:46:17 -0500 Received: by mail-ed1-f65.google.com with SMTP id h21-v6so6862585edq.9 for ; Mon, 05 Nov 2018 04:26:45 -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=te6Hid59cIIWKRRQciZfIZ1h7Cv6AXnsglt3poBcaSqT2WaDwyp8N5qxRwMBsSSl3Y ny/nTAL66fQ54S//nu8XROrYTQjQPtUmQXfKx6pCmq0R4nFez80ld4//OJd0ZFFGL0en fkRXfFxM7j0hhLFp7UW9HzXXBpSbODwUwQsetLMukMJ+xY1sCWkKOdqi21wdGXOEDomL /p/mez+f3j3JEEyzyM/MSzBmrp4PT5GFOGxNnlAc0I5KxiEiNepNxQ3ynkEX3cnGDl8N fwt5+GWY8pfQLq+Hqh1wAgi/nMIcbxo5jw0NWT7L9bwKkVRQ9lEJiSeyubq2LZspnMRt awKQ== 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=XOHNWrnDAt51Hvx+oL80p+SqD7c3F1oVSLyRX1UAO78QKf+QRRXSn19WVN2piNOkqN 31IXQlPhxHsyCKgT1l4MwsUaxQ7MVVkSQuVIE0oAHuwumT5WWSBe9uPlMNY/kU1nfqNG RPUcdsOG9NYFwh4y+h3waYcVt1WwMMj6l73UwCNaq91ypQSX9DDoL6dKFLjd5o94jZWK gH13LO8hs+TBXsCrTdHuJ8RtuprlCznRHyMBcBghzkKx4SEfebRuM/Mc5+pNm5OimClm al6DzRg//3K3bzSxuxYPmn5EqxjglTqE5ZrNK7I+l0ZyBy3bB0j6B23wF9VuE7FaGEWd iLag== X-Gm-Message-State: AGRZ1gIbrR+y+ihYt6uCx2baKyQUKsf98rkju1Qgg4T52eCPx9oBfyBp N+bm058LnBDQ6IGJnb8W7nM4hg== X-Google-Smtp-Source: AJdET5ej0cCSl8cvEGawBuv/2L9zrSC6apK1d/eaAxf4ucQS8Q2vCY7HpQQpBaOjsG6HOw75wYhvVw== X-Received: by 2002:a17:906:5387:: with SMTP id g7-v6mr14054240ejo.174.1541420804987; Mon, 05 Nov 2018 04:26:44 -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 9-v6sm7046056ejw.46.2018.11.05.04.26.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 04:26:44 -0800 (PST) From: Hans Holmberg To: Matias Bjorling Cc: Javier Gonzales , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH v2 2/7] lightnvm: pblk: account for write error sectors in emeta Date: Mon, 5 Nov 2018 13:26:05 +0100 Message-Id: <20181105122610.1555-3-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105122610.1555-1-hans.ml.holmberg@owltronix.com> References: <20181105122610.1555-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);