Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp496536imu; Mon, 5 Nov 2018 04:27:29 -0800 (PST) X-Google-Smtp-Source: AJdET5cDytZOZpRVVRnQKUe3sImk0D3EywYUYkDmM3EnVrVK5T7EECzFe3yENHH3yVbM3GqkHDvU X-Received: by 2002:a17:902:50e3:: with SMTP id c32-v6mr21799013plj.39.1541420849064; Mon, 05 Nov 2018 04:27:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541420849; cv=none; d=google.com; s=arc-20160816; b=B4QoyJk2Db5idWpQKfhkb1+1xyEj8V8Dc4OJGMa/N3tPNGl2+2L8HteQ8oqg7Ize0K N0SKjaVrBaBdafOwteexnj+GShXHl1RcROsDYOF6FC4Tut+xy+UzkbUk0hYNIGHioTon caTbFJywQFtOmrN9AaqZpG1Lt2QyyCuke8voo3ZSB4SPRJJCHJ+ebevKmON32nU1b3Mk gLtm5UFo+zZGpGjxspcG3330aYm0hX1KUMWtH0Cvi7B+UoptiIqQCq2xpyGnJy2ABbwP 1DtXdIA2a+5z+Nzs3Sic1j/MSzG9+moyhHO1eO/XsxJJGXsYXQQbZpi/5vbz/ucAdL0Q hMvQ== 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=cnKaeRoQQa8i6RB5+OFZeMivpWgE29k57o0EeueExqw=; b=suDA5nNVqpWQYMtuRXNjcyNUxxmNGlcPOWoEOgO3/9UVlzSfXVrVAKz/Tj3wODjOES Bk1S4BJW7O8n7FFHQCmL1jAWKu0nnMNZcal+Y1VxwRdvQ29bq4Mn8frX/JlJlLhSe8YO YaL0hjagDwVt91maOg1RfoiyOhbATlwcc7Dh8S5naBqGSXzaNYwnSq08PGEIR5USwT5l KRiDEg8Os1ZQummhNhBeDJL5IbW0OSgoMzEA856cXfIibs6vOjjlO6V9iv7M/OsMTe2i f3jRH6JDPS9/z0y1BCQfyGrsT4dS+pMcCRwCXmkRcCF9N63HeoF5jslHbjEktvNdQegX U8tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=te6Hid59; 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 w2si8517133pgs.264.2018.11.05.04.27.12; Mon, 05 Nov 2018 04:27:29 -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=te6Hid59; 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 S1729638AbeKEVqS (ORCPT + 99 others); Mon, 5 Nov 2018 16:46:18 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:37331 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728870AbeKEVqR (ORCPT ); Mon, 5 Nov 2018 16:46:17 -0500 Received: by mail-ed1-f66.google.com with SMTP id y10-v6so813462edr.4 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=fW66v28/3Mb5tDUbFfZEO0glVhdx4jsEyCuG6r2bjEZDdtnab9/9+5L5aBe2/XVSgN InRq1VIPRdgxFr96cZgQKp+Lp9xmbG+awRH2POA+8mzic+QZFeL44OxtvNK355XiDLjO S79A8wiGdGbibF4ILiN8pDzoCOgQZ3Cco1bFpBmk8CLNx4sQ0D4yO1p8p537QW0+go4J iNUJNZemdgvI8uN6az7Lsoy19ybsyRjSCkvjMmfvTx0MSl2qB77YuIFeD+9YTlKlUMKs iDWE+4rV4gxfgBH/Ihx8CM4KQTUjHrlTmQWAs1scbVhZ5FH4PWyowm2xCDKq6OUfjzcE lfRQ== X-Gm-Message-State: AGRZ1gKOp61mCZW7SL0FcDbP+kSX1/00SYUrnN9hIIpvdca4yoglT/eU 50myd7VXmWST+SOn8q87qDOD+w== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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