From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C640A9463; Sat, 12 Sep 2026 19:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789240045; cv=none; b=kpo/oTnzDBrXT3hrwbYAHfzwMyyDh8FQ+h1kLqiFsXNQEcOmHIcByrQ3gnHHlLMqrooZE+wVqnG5cTFKJ96LGN+PR/jc8N9c8BjEscFFnsT0RE0oWNUmA2jvejosQjX7ujMIbD2ow6K/ySpX1qjMDzKUVhtx4/ihzgJ1JRrnjWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789240045; c=relaxed/simple; bh=Bh6VMl9Vxbl4Tro3XMwcZHooJ7VAaANegCh/9BHv4mA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fg/p23kdd9laG6/nERsSFjSf88qhFWZaTG/7m/yup72sAjrneQu6zAI10kWHlqR53iAflL3rNDGHqAx9WByWNs4k43/BW2HIUue2p/f/2e/dJro00R3Q6obXhRO8WHr6Ypz0gl9D1rX4nb8VqZrP72n0rtUvbpmCKs+W1A5h95c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wl0Nyg7+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wl0Nyg7+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99FBC1F000FF; Sat, 12 Sep 2026 19:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789240044; bh=EziLuYvQKuEl1RsJlCWcK6w0pdyguZN4YINbZVpg3DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wl0Nyg7+E3qGHVtAKGDw59HrfbPOwhrBcF3K7mGjWmhjnrxUiotH0xKJYtd1m43qg IkuWfwlYDDEckO0zK2Xqc7mkn0pg57tWqCIq/oj+fZ/J8PNiqVju9Yxg1xl6f9td53 1yUPUdyi6ll9RMmY8M5t5lqpQgc1X0M0c3Tuz9Bo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhihao Cheng , Richard Weinberger , Sasha Levin Subject: [PATCH 5.15 788/935] ubi: fastmap: erase_block: Get erase counter from wl_entry rather than flash Date: Sat, 12 Sep 2026 09:03:38 +0200 Message-ID: <20260912065544.901516434@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhihao Cheng [ Upstream commit 08a4267874164b2e9c8c50831acd466f47208acc ] Just like sync_erase() does, getting erase counter from wl_entry is faster than reading from flash. Signed-off-by: Zhihao Cheng Signed-off-by: Richard Weinberger Stable-dep-of: 420477a84f1e ("UBI: Preserve torture flag when rescheduling failed erasures") Signed-off-by: Sasha Levin --- drivers/mtd/ubi/fastmap.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index 5dbab1237fee9..f579493b24b80 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -1400,36 +1400,27 @@ static int ubi_write_fastmap(struct ubi_device *ubi, */ static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e) { - int ret; + int err; struct ubi_ec_hdr *ec_hdr; - long long ec; + long long ec = e->ec; ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL); if (!ec_hdr) return -ENOMEM; - ret = ubi_io_read_ec_hdr(ubi, e->pnum, ec_hdr, 0); - if (ret < 0) - goto out; - else if (ret && ret != UBI_IO_BITFLIPS) { - ret = -EINVAL; - goto out; - } - - ret = ubi_io_sync_erase(ubi, e->pnum, 0); - if (ret < 0) + err = ubi_io_sync_erase(ubi, e->pnum, 0); + if (err < 0) goto out; - ec = be64_to_cpu(ec_hdr->ec); - ec += ret; + ec += err; if (ec > UBI_MAX_ERASECOUNTER) { - ret = -EINVAL; + err = -EINVAL; goto out; } ec_hdr->ec = cpu_to_be64(ec); - ret = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr); - if (ret < 0) + err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr); + if (err < 0) goto out; e->ec = ec; @@ -1440,7 +1431,7 @@ static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e) out: kfree(ec_hdr); - return ret; + return err; } /** -- 2.53.0