From patchwork Wed Jan 31 02:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 10193037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E98D601A0 for ; Wed, 31 Jan 2018 02:07:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 804CD284BD for ; Wed, 31 Jan 2018 02:07:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74C21284C4; Wed, 31 Jan 2018 02:07:05 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 EF30D284B9 for ; Wed, 31 Jan 2018 02:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752068AbeAaCHD (ORCPT ); Tue, 30 Jan 2018 21:07:03 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40370 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752015AbeAaCHC (ORCPT ); Tue, 30 Jan 2018 21:07:02 -0500 Received: by mail-wm0-f67.google.com with SMTP id v123so4861553wmd.5 for ; Tue, 30 Jan 2018 18:07:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=dA3FmoBfTmV7CkRa9sCiCbdBjs9RE24uoJSF22PwI+w=; b=lZ006UpynZUQ/+rXJzwADV6NaUQCPxE4ji6gH2PDAai9vdBNHjbekt+AMe9VF38U1Q RmiB3EsHw7x42DHO4w/F4xhiiDTOn39+vXMvOYGbHi2p6OBhMWS4jrQu7nYtoc4j27J3 un71kgieo+apW3iFkMfUMjBWKB0ABcYBT/HPBg3iMn6YVQTIq8+79X+Txsnk8IXFy7Gx 2Fn1HuxWiB5u0kF7QrxYgr8WkQdWsP95PLthifaaT2ZwzgAlebcGkTXDDLBvv1oNeBOy WLDeadHnGj9K3unZeATIlls3vx/MoaxwnS+UuYozFhP1nsQnNDdr5eePZPsyevK0XsFO xP1g== 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; bh=dA3FmoBfTmV7CkRa9sCiCbdBjs9RE24uoJSF22PwI+w=; b=K9ATCUWgwTTton7d5Hh+LIOayyRG6GKL9ZJESkIvysFk1+RyXFlUFw5FXiU7u3cUmN psQLs2+8fXff82LDAd+zfH60pVlPk6BOdu5Hpex20Vj8vQom0lfG6igBKLfB9l3fEYsa mISFSEsyJ4Tv0tErRIokUR4cXzZ8P+14S3c5VEeHS2AyXTpgJA/RSpdIrKPD+Sfrgw0Z Xhaa+mYaawId4y3kfmAZJHVSV0tzzYfQFt2wjJD6X9ZxxUVynRZnMiH0MqosD8llz2pq 94NAiqRyVh+XKesqb3pqm6hFvicVxsZTou/9m4HJsnFQuVpWk6LzhOufjr3INc6ILw0B 4Nzg== X-Gm-Message-State: AKwxytfMbQ54g9whKINPKuZ7cP9vmqrEWHrGNWZ2Yb3SWZ5iBk5p0yIu dQmJl7SrMF+rSeeJf9Y4fDqR3g== X-Google-Smtp-Source: AH8x225OC9ieE4xeQ3HjPKJGkfjO10Ek5mggai6aDShZ60uZoJ9Oz1Iz1PaIgvMSGHKo5E7owzV4sA== X-Received: by 10.80.201.134 with SMTP id w6mr53538631edh.22.1517364421139; Tue, 30 Jan 2018 18:07:01 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id m17sm8249001edc.31.2018.01.30.18.07.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jan 2018 18:07:00 -0800 (PST) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH 1/5] lightnvm: pblk: handle bad sectors in the emeta area correctly Date: Wed, 31 Jan 2018 03:06:47 +0100 Message-Id: <1517364411-22386-1-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 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 Unless we check if there are bad sectors in the entire emeta-area we risk ending up with valid bitmap / available sector count inconsistency. This results in lines with a bad chunk at the last LUN marked as bad, so go through the whole emeta area and mark up the invalid sectors. Signed-off-by: Hans Holmberg --- drivers/lightnvm/pblk-core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 0487b9340c1d..9027cf2ed1d8 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1021,6 +1021,7 @@ static int pblk_line_init_bb(struct pblk *pblk, struct pblk_line *line, int nr_bb = 0; u64 off; int bit = -1; + int emeta_secs; line->sec_in_line = lm->sec_per_line; @@ -1055,18 +1056,18 @@ static int pblk_line_init_bb(struct pblk *pblk, struct pblk_line *line, /* Mark emeta metadata sectors as bad sectors. We need to consider bad * blocks to make sure that there are enough sectors to store emeta */ - off = lm->sec_per_line - lm->emeta_sec[0]; - bitmap_set(line->invalid_bitmap, off, lm->emeta_sec[0]); - while (nr_bb) { + emeta_secs = lm->emeta_sec[0]; + off = lm->sec_per_line; + while (emeta_secs) { off -= geo->sec_per_pl; if (!test_bit(off, line->invalid_bitmap)) { bitmap_set(line->invalid_bitmap, off, geo->sec_per_pl); - nr_bb--; + emeta_secs -= geo->sec_per_pl; } } - line->sec_in_line -= lm->emeta_sec[0]; line->emeta_ssec = off; + line->sec_in_line -= lm->emeta_sec[0]; line->nr_valid_lbas = 0; line->left_msecs = line->sec_in_line; *line->vsc = cpu_to_le32(line->sec_in_line);