From patchwork Wed Jun 13 21:23:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 929091 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IyjjK0b6"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415fsd0cs3z9s01 for ; Thu, 14 Jun 2018 07:24:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xDqnpZMKbWQXcVnVgia7n6aI+6nJDYx7ij6kLGfM0bc=; b=IyjjK0b6aGgsISmAP/oVcjlfau 7ZQFg9i/QA+nywXysv8Jd19PMgCl529gHsM/dP+NmarcBu+AfDlTufcJJmoFVi17PPsVJm9ejgVMA Nunqy3rkw76Q7cYrPusIhdIl4gaBAPknsRR24e587emMfr4CuXIaRnRD0SCInn1knHCUwjB/dOiQP t0z9xa0xT1zBoDx2uhxDfDcqiBeeaTvbtUH2Kizx87Ko55SIru96M2ulBMkIcfIKjE9BL3pZ/7cam uVpffbIN2aIGfle/b7ZSbMjUY6yzQlOXx24kbgw2a6RvTMdfuFjwW9ZmRyg/E+aynMZBL9QNG89rJ uaZGLfyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTDFu-00059G-Tr; Wed, 13 Jun 2018 21:24:38 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTDFV-0004qL-HY for linux-mtd@lists.infradead.org; Wed, 13 Jun 2018 21:24:15 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id ED503181B504D; Wed, 13 Jun 2018 23:24:00 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 02/14] ubi: Fix assert in ubi_wl_init Date: Wed, 13 Jun 2018 23:23:32 +0200 Message-Id: <20180613212344.11608-3-richard@nod.at> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180613212344.11608-1-richard@nod.at> References: <20180613212344.11608-1-richard@nod.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180613_142413_770788_D0B4FA5A X-CRM114-Status: GOOD ( 15.78 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When multiple PEBs are used for a fastmap, found_pebs can be wrong and the assert triggers. The current approach is broken in two ways: 1. The "continue" in list_for_each_entry() over all fastmap PEBs misses the counter at all. 2. When the fastmap changes in size, growing due to a preseeded fastmap or shrinking due to new bad blocks, iterating over the current fastmap will give wrong numbers. We have to exclude the fastmap size at all from the calculation to be able to compare the numbers. At this stage we simply have no longer the information whether the fastmap changed in size. Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/wl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index f66b3b22f328..6bbb968fe9da 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -1695,11 +1695,19 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) err = erase_aeb(ubi, aeb, sync); if (err) goto out_free; - } - found_pebs++; + /* + * If no fastmap is used, all fastmap PEBs will get be + * erased and are member of ai->fastmap. + */ + if (!ubi->fm) + found_pebs++; + } } + if (ubi->fm) + found_pebs += ubi->fm->used_blocks; + dbg_wl("found %i PEBs", found_pebs); ubi_assert(ubi->good_peb_count == found_pebs);