| Message ID | 20251231223008.3251711-17-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220298; bh=ni9mZ2AKOfJ6YSwLGVJ517XBH0cIvM8frDHa5TTZlmY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uDpDamKq37Qnhmcq7nf+D4fWt9udOZ/veM5nCCsJS12+02W10oAZuoUJUeNLi8WWF mddmt/Uf51cDEB1JDSRly5DPSrnM/1GTX+k2Y9Z3pzWAtQ5fDWms/IdB3DmuqIBgpn vXkll1MfYsGUWV8V58/JoAQwWqhfebodZIQVwQ53DyWFrin6tSMS46gxAZ9IBlSILv 1H7QL6YyMf3+pF/uuAYkYmPYBEaV/894J0R1YKchyf/B1bhv4Nv9hnnMhmFKbhbGVs aBwW5Z+8leSOZc3yXEJzjY4ZVAWzd/UnQKycJfoxEsO55t/hvMeVtnBwagMlvWSQxh HmZU31726SWdw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0078168FEA for <u-boot-concept@u-boot.org>; Wed, 31 Dec 2025 15:31:38 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GKHnrhLqTnU2 for <u-boot-concept@u-boot.org>; Wed, 31 Dec 2025 15:31:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220296; bh=ni9mZ2AKOfJ6YSwLGVJ517XBH0cIvM8frDHa5TTZlmY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MC0EzXpzK08XL02rHTF+VbvertWJjE1ot+QMyr80r3aM4+cO/Sd5KsaZc3EInpbfA XxUsIYCjBYja0PED/1a4gNhnBJk9Kyt7O1yPIdq9QuJPJ0Dqw/uwaFoFXvRUuO/cdU r/C7POYn81JXBs53ue4gzp/bOhB/5UucbYjNtkebNpgAtjnwZsqKhIsTPkOW0VXNrN ce7e5oV/9kNxelmOI7+vu8dpxS7V+1Pn5MlbtgnyT7U4y4c/X0wtRgzuSja3b2f+o8 /T6NtwqhoYY66xdO1cBZGbBobkwGdrvT3TUmrLQy2jODXyWHVlxVb+r47fCTRuaTvL urIkXYlLXPvxA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED15F68F65 for <u-boot-concept@u-boot.org>; Wed, 31 Dec 2025 15:31:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220295; bh=4JbotGJE8pNdXCvcB1y6k99TdYLZ2/0w97LPB2LSrLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uZpoVY6pQXVGsEPz+VQSQFHp86kNRZy/0jHKkGROLuAZGqFFmIgLWSb4v/Dpi/3de j+P6JTwVy8D8eosIgqiGCdjD0o0DLPeu8+eaQwWsun/EU/vUvf7cTyJPzDYPgUtWDS Z6BToGjDE+QmsHSFyPZWFE1kjqDIebUx8npkKwBX7go7yUwD58RUydwCgrFLdDH4sH tI3QaUPbIltWWf5He9A9aAP495biqlyJs84HikG0hrP4luylcRHxbfxDUZcqrEBa6n rGW3WpIbU/rAUsCtb4PIEVPJ0YCxa7v57Rzj8Tx8taY/eyqrxB8ZL00frK7Kz2GvPK 8YZ5jUXMsPUwg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4BA6368FCB; Wed, 31 Dec 2025 15:31:35 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id FG6PSjNBp8ZD; Wed, 31 Dec 2025 15:31:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220295; bh=85IK569qU4Bbx/S/INjLEOj69VxLGTvfMawi1T/V6Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AG9OkUHwz7deQ9ZHhLb697uiSppowKWRaoff6oUxwjlC1d6jzniDVxRrnCYZEkpmc YpSTGO+z3+KTrdhWIysPh5SUihvXhroW/5zQSVKboKmD8iqM88Yu0kn4891otAoD+c AzoIlgKkO8Q4eyVnD2i0zyrpjkvv1vaUnDQDIksCAPflqu2OzZgLKu0TMw8EfEYxSg he96M16csk29ZNbU4Gc8yBFj7tGzw/MRBWFpR0MwytG2dR0O12zMlXE3pbaSnHU7VB Jc/O5jDuHT1UcQ4eyBgOAhbAyRXp2W0AVms/cFXIm+YJ3b2FxtlHjchfEtXWVtYZ36 tkr0l1ZtDYrkA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A54BC68F61; Wed, 31 Dec 2025 15:31:34 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Wed, 31 Dec 2025 15:29:49 -0700 Message-ID: <20251231223008.3251711-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251231223008.3251711-1-sjg@u-boot.org> References: <20251231223008.3251711-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EYODYMZAFBCAQEUI2GXBTSKI2NT7OG6P X-Message-ID-Hash: EYODYMZAFBCAQEUI2GXBTSKI2NT7OG6P X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt <xypron.glpk@gmx.de>, Simon Glass <simon.glass@canonical.com>, Claude <noreply@anthropic.com> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/26] ext4l: Add safeguard to close previous mount in probe List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/EYODYMZAFBCAQEUI2GXBTSKI2NT7OG6P/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
ext4l: Add write support (part L)
|
|
Commit Message
Simon Glass
Dec. 31, 2025, 10:29 p.m. UTC
From: Simon Glass <simon.glass@canonical.com> When running multiple filesystem tests in sequence, probe may be called without an explicit close of the previous mount. The old device may have been rebound to a different file, making I/O to it invalid. Add a new ext4l_close_internal() function with a skip_io parameter to handle this case. When skip_io is true, it skips journal-destroy entirely since the device may be invalid. It will be recovered on next mount. Also call the ext4- and JBD2- cleanup functions to properly reset the global state for subsequent mounts: ext4_exit_system_zone(), ext4_exit_es(), ext4_exit_mballoc(), and jbd2_journal_exit_global() This ensures the caches are destroyed, thus freeing all orphaned journal_heads, even when skip_io is true. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/interface.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index ceedabdb727..301e28af3b8 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -286,6 +286,17 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, if (!fs_dev_desc) return -EINVAL; + /* + * Ensure any previous mount is properly closed before mounting again. + * This prevents resource leaks if probe is called without close. + * + * Since we're being called while a previous mount exists, we can't + * trust the old device state (it may have been rebound to a different + * file). Use skip_io=true to skip all I/O during close. + */ + if (ext4l_sb) + ext4l_close_internal(true); + /* Initialise message buffer for recording ext4 messages */ ext4l_msg_init(); @@ -855,12 +866,7 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, void ext4l_close(void) { - if (ext4l_open_dirs > 0) - return; - - ext4l_dev_desc = NULL; - ext4l_sb = NULL; - ext4l_clear_blk_dev(); + ext4l_close_internal(false); } /**