From patchwork Mon Nov 5 11:41:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10667931 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 C285A175A for ; Mon, 5 Nov 2018 11:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFB0A29720 for ; Mon, 5 Nov 2018 11:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A227B2972E; Mon, 5 Nov 2018 11:43:06 +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 311F929720 for ; Mon, 5 Nov 2018 11:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726358AbeKEVCX (ORCPT ); Mon, 5 Nov 2018 16:02:23 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:40140 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729015AbeKEVBZ (ORCPT ); Mon, 5 Nov 2018 16:01:25 -0500 Received: by mail-it1-f196.google.com with SMTP id e11so8805666itl.5 for ; Mon, 05 Nov 2018 03:42:05 -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=r0quzrvzfUc+HIm+eh/BxAuTv5KVldRphwW9NWd7VSo=; b=13N0a9HsfaO2AhbJXeA3vtZIfDjx9BfeFj3OQIUvCxFR/dqPfhCXw+nmEkacTNkHPX yfZg20WS95RtkVWUk/k0WsdjvMmw4NwVHmRY3t0FaVSFeD4itTylBIOQcih+0INYwZjb oyFPi4IIaUs+dRLm7meeuMOdE1JoOpZjOJE7J5citlxk6h7FOEaoGI2AC2Ddw2vnhDAc 3b4dtTyVb8qQyzTKFjPV7oqqBFKPDJxtZn6UQnODI8Ckjf8l08F/QTb7r/3O/2GMYRWS WhRmmFyMVvy5DJYRCn9wMsHJpshCvJmXVXG8v3MBYXsLIJ1xSEOs/Vds8RpFozXHrg2J aXAQ== 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=r0quzrvzfUc+HIm+eh/BxAuTv5KVldRphwW9NWd7VSo=; b=nPzNrPplEM1pvI3gbQERKMAxNoayldL5hkP/TFsp2pMZMZVeVGnIK1u2jUmtgvrSuu UN8ecR25AMx3RDF5zoSmml04EnRia6dLkiVtYuDYTrzCsMaggY25dfdkf5jTe+y+nTgY 4pbegFYXOVvSS3GO4sYHDjlBWI2TQ0TKJ/WgD5NGn2a/RfwS31CTx6MJign1x95sVgbc PlIdqfvdO5tLPbCNFugP5o+VAmTkJH9KMGsz2chJDmXFvCcTRdRFDJOpxuJy5H8SKq9O xPdQGA4lqDXDVFeoUOMTvKwJ1XndtComnYF1Iq+ULH7fbqaFhDoZobob6L0RM8JvZIsV uW/g== X-Gm-Message-State: AGRZ1gLTr86FcXtKNiZBLgs7R4SNBN81RKosqA2xC/778DC4dkDJ7Nhh 6qKTOZ0wuPL8SOW6HrLu19Hq5w== X-Google-Smtp-Source: AJdET5dnUg1UmleJlFJefYJnfEEXmiFh8eO0WXx8WF4+Bzy9e4dYBgd4HJQ4svdZDqD+owqjGWfYKQ== X-Received: by 2002:a24:37ce:: with SMTP id r197-v6mr6045938itr.166.1541418125501; Mon, 05 Nov 2018 03:42:05 -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 186-v6sm14880824itf.11.2018.11.05.03.42.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 03:42:05 -0800 (PST) From: Hans Holmberg X-Google-Original-From: Hans Holmberg To: Matias Bjorling Cc: Javier Gonzales , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , Hans Holmberg Subject: [PATCH 2/7] lightnvm: pblk: account for write error sectors in emeta Date: Mon, 5 Nov 2018 12:41:08 +0100 Message-Id: <20181105114113.30932-3-hans.ml.holmberg@cnexlabs.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105114113.30932-1-hans.ml.holmberg@cnexlabs.com> References: <20181105114113.30932-1-hans.ml.holmberg@cnexlabs.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 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);