From patchwork Mon Aug 28 06:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 13367598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4527DC71153 for ; Mon, 28 Aug 2023 06:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=EmZiPpIdUZg4D34rBvudQzkuZlz4btWV9kg6dIYaUAU=; b=NSWP4gzqZZBb00 J6L+p9myBuFk26CGkEiJeNG/TcqcX3O1rrpL3TfXZT0+fQfZucKzmxy9OiOVDxNm+libyG1KQz2zj +bqYT/6Z1HUZY8tqWspNkuY4RjTR0xub/Xx6d6fMsPauHtrolQELHddpyOgJ+TkBn2ACdZz9eQwiS cB2T7oF4tauOML06y1TrHcRNI/fE+41S8KRhC9cOLUJsQAdkgGB4GmQzayVDrGbLojVDV6NecHMWg crK/KClB5BnBsTCIhn3yhWQRpaGTTkdcLXuTeLRc+lTTRr3+ZrqD+YXdXRHk1l1dmFFlUACYE3jXm UiDXgvAn7anKx3H2izxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qaVy9-008yGO-11; Mon, 28 Aug 2023 06:43:25 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qaVy5-008yAq-1B; Mon, 28 Aug 2023 06:43:23 +0000 Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RZ1B22c9GzhZGk; Mon, 28 Aug 2023 14:39:22 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 28 Aug 2023 14:43:10 +0800 From: Zhihao Cheng To: , , , , CC: , , , Subject: [PATCH v2 00/12] ubi: fastmap: Fix a series of wear leveling problems Date: Mon, 28 Aug 2023 14:38:33 +0800 Message-ID: <20230828063845.3142561-1-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Originating-IP: [10.175.104.67] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230827_234321_581409_4781DA92 X-CRM114-Status: UNSURE ( 9.35 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series of patches fix three problems: 1. Inconsistent erase counter from wl entry and disk, for patches 1~4. 2. Same PEB is always resued for fastmap data, for patches 5~9. 3. First 64 PEBs have large erase counter than others, for patches 10~12. Besides, patches 4/5 bring an improvement of the UBI service life. Regression tests are in [Link]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=217787. v1->v2: Patch 6: Change wait condition in wait_free_pebs_for_pool(), there are two situations that cause waiting infinately: 1. __erase_worker schedules itself if -EBUSY returned when shutting down system. 2. The 'min_expect_free' cannot be satisfied when bad block occurs and ubi becomes ro(The erased PEB should be the last one of 'min_expect_free', but it becomes bad in __erase_worker). PS: After re-testing, the testing results in [Link] is not affected. Zhihao Cheng (12): ubi: fastmap: Fix missed ec updating after erasing old fastmap data block ubi: fastmap: erase_block: Get erase counter from wl_entry rather than flash ubi: fastmap: Allocate memory with GFP_NOFS in ubi_update_fastmap ubi: Replace erase_block() with sync_erase() ubi: fastmap: Use free pebs reserved for bad block handling ubi: fastmap: Wait until there are enough free PEBs before filling pools ubi: fastmap: Remove unneeded break condition while filling pools ubi: fastmap: may_reserve_for_fm: Don't reserve PEB if fm_anchor exists ubi: fastmap: Get wl PEB even ec beyonds the 'max' if free PEBs are run out ubi: fastmap: Fix lapsed wear leveling for first 64 PEBs ubi: fastmap: Add module parameter to control reserving filling pool PEBs ubi: fastmap: Add control in 'UBI_IOCATT' ioctl to reserve PEBs for filling pools drivers/mtd/ubi/build.c | 25 +++++++- drivers/mtd/ubi/cdev.c | 3 +- drivers/mtd/ubi/eba.c | 3 - drivers/mtd/ubi/fastmap-wl.c | 112 +++++++++++++++++++++++++++-------- drivers/mtd/ubi/fastmap.c | 66 +++------------------ drivers/mtd/ubi/ubi.h | 10 +++- drivers/mtd/ubi/wl.c | 48 +++++++++------ drivers/mtd/ubi/wl.h | 6 +- include/uapi/mtd/ubi-user.h | 4 +- 9 files changed, 164 insertions(+), 113 deletions(-)