Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp453606imu; Mon, 5 Nov 2018 03:44:18 -0800 (PST) X-Google-Smtp-Source: AJdET5e3VKo4LBx7QuBa42dTuYigzMyoyP2JYIaPz5lsMs9ZcQEd8AInm3AgjDIsW3ZVRdU0U9H6 X-Received: by 2002:a63:fc22:: with SMTP id j34-v6mr20135028pgi.434.1541418258619; Mon, 05 Nov 2018 03:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541418258; cv=none; d=google.com; s=arc-20160816; b=InrZQPBzqan9dsZYsttZFxVhBg6meFf2LR2nJwIsboU2PlMWy992JUJxXV6KidKxg5 DGN80VR1HAxxPeh3dQFriTqdqF6Cd4hHMhMEPZM+VdjXr3EtEZ5rMe0m1hUFBrvs/37T pxyTlR4azLdxlrmH0jbI0szNj4kSOiuZq6SF1LB59DJPCL25Xpbrpb46Vqa2cRDhw5VJ HM3Pq+Kk0f3fGVOS14n5BbYgPdoCibHOzK1mtQD0OL7QsVGdshJ0tpWnjLqPCoUaPBxm f1oUxasBTiMhOAYg2uLqkN6++JqlSHxhzLJ0dnnYM8Av6v5fvfsrVQWr69E5SAXnnp5+ fHuQ== 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; bh=r0quzrvzfUc+HIm+eh/BxAuTv5KVldRphwW9NWd7VSo=; b=KtrCaIhuJho6PFT70csD1CyqRftVqId4jx1x5X2aS3+XHLjsqK9uuTyuMd4GZpkPKO WeoxlK1m/bKjHMm7/pbZAeykiD6tQ08wiNSlwZBMBMkDSC7MZu+0G3s8iwEStCekk+50 2oY/pecJh31xub7v4qPRAOWfFJmBZgRpkH1ME88sJUv/qzOVkQbI0EkFida6IUZjdo2M nt+MfUg2V5hx//42c5qrpNkDW2OIOUR/+TLUrtWH7mIvOtD5ApiLaRhg3zfZevsGJ3Vv u7xH5ukQR9usDWuunzOfu2SwaCWPSVUP9umC3E/sTG1iXdeqwD74DLvPLNghaE9FadNc EC7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=13N0a9Hs; 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 t1-v6si43238972ply.279.2018.11.05.03.44.03; Mon, 05 Nov 2018 03:44:18 -0800 (PST) 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=13N0a9Hs; 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 S1728943AbeKEVCY (ORCPT + 99 others); Mon, 5 Nov 2018 16:02:24 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:51722 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729006AbeKEVBZ (ORCPT ); Mon, 5 Nov 2018 16:01:25 -0500 Received: by mail-it1-f195.google.com with SMTP id h13so12198433itl.1 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=tKIz2N7CIdLEVisP1mSYs0itwqETeRFe1AN1S9IlYkk2a5Ziu33O2NiraYgrqaJrNn /Pdd/Xq8TzPjrYS7suDCKg/dW7O5N3Chs/lrPs9bH0yBc/GJKvZkGWiM4PoqkliC96uR Qbqk/WpRYfQXvYpJFAO4eNMK3tWfV2fhp1kiDd/k92diwNxBh+4lAVMd1fNEjN9MH7kJ 6KsCIU8gCqlQ4+OIyH6dqZ3eAYW0kdQ34x07zeq6My1lqeYpNMTU0E4o3nyhtdSr2jfN dgsygVu9xlTMUlSlenrqYbF0fxUxu4T24KqLvZ1qW1/NnsUPCjhzRhbZshEawh5uBBxB 4lfA== X-Gm-Message-State: AGRZ1gK34CTWaJhWswAUoJOAmQRTaGkdwVzXcC84IchZ6X1V5cn47sFk suo1L/az2jUct2oZ2NSyeklNxY7yxss3/A== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.17.1