From patchwork Thu Mar 29 22:04:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10316605 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 0582260383 for ; Thu, 29 Mar 2018 22:16:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E07DD2A4B9 for ; Thu, 29 Mar 2018 22:16:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53BE2A536; Thu, 29 Mar 2018 22:16:48 +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=unavailable 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 814652A4B9 for ; Thu, 29 Mar 2018 22:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752500AbeC2WQe (ORCPT ); Thu, 29 Mar 2018 18:16:34 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33151 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752058AbeC2WG7 (ORCPT ); Thu, 29 Mar 2018 18:06:59 -0400 Received: by mail-lf0-f65.google.com with SMTP id x70-v6so3501071lfa.0 for ; Thu, 29 Mar 2018 15:06:58 -0700 (PDT) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=sWzbcWi0+TC9lG48QH91Py4dW1Pq3ghbDKbCQZP56Gc=; b=RqXVAGrS09snz53lEqZOzyyocjvbW/m/690bP4TrUnLG/bnpmZgRtVYsKJoksp1eZE qKNz6iFiB3rwCMQrddyyGlEVBhaYAYecFgztEVrVH1UBpRrL5yX3KnGXDSu+qRy7NztL tQmBEOGqGqh8jFzrGxpZDY744oThSTy6ria1eNmx7ZGbAWu1nnds1WMkYsYzmIs8eLhO iP4PKy4W2zcvUd+FVq0c8ZRYX/R7oBhCaSCT4TbaupannhlX/f5/Rc1mZkoeT00XP6XG 4AtgfyYd4TspnrXtj8fQkqmWjckM8hEmt1ZKNq8RJ0iVDvlru8Jn2TzbvDLhi3DE6RwO P57g== 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:mime-version:content-transfer-encoding; bh=sWzbcWi0+TC9lG48QH91Py4dW1Pq3ghbDKbCQZP56Gc=; b=VwQed5VBLMpv98/rqhYNNZTGrys/kBfqrnXktlxidfI/9jMcWW/9VjbIEqe2sSlakp K+Fcgbeaeg2z6N7Sa9fD9n+m3qwWb9/RfAFZ/vZ/IW1bcC5026YwQY/WcNNV12Cf5ZfZ PNhW0ydcLW8YMEdP8AVi3J3+TYQSKQnSZePvxVbb8WK0rMGr1XaIhtEFLED6Wyml0uyK 9bwmoPeveNUuzSdJIdZwjRRzNAiAyUUiookDZqKMixhgEHn3OvGlIXafZGuDemS6eNiF 73RZ4C7iHlmSbkRCPZxLElMRURu+Y2VsYhPURrDu0Rz+ZsirEMRG9NSlKK7jjzLVaGxA 2+kA== X-Gm-Message-State: AElRT7FIg4mMf0SQiSe+3ZnhfH7UfUMjhxyXBtoRGBABVjJRvdWmJo/h xtikbsAH096mOEVmRbIRpBA2G48d X-Google-Smtp-Source: AIpwx48b5n0lnDJQcon34Qu22xRI3rIIYj2OeFfJuAi+a5Hknbr5UEalQGW9taGlIN/ZBeL1eC8siQ== X-Received: by 10.46.158.19 with SMTP id e19mr6722387ljk.47.1522361217880; Thu, 29 Mar 2018 15:06:57 -0700 (PDT) Received: from Macroninja.cnexlabs.com (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.gmail.com with ESMTPSA id i89-v6sm1365508lfk.12.2018.03.29.15.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 15:06:57 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, keith.busch@intel.com, javier@cnexlabs.com, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 03/37] lightnvm: pblk: handle bad sectors in the emeta area correctly Date: Fri, 30 Mar 2018 00:04:50 +0200 Message-Id: <20180329220524.30363-4-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180329220524.30363-1-mb@lightnvm.io> References: <20180329220524.30363-1-mb@lightnvm.io> MIME-Version: 1.0 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 Signed-off-by: Matias Bjørling --- 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);