| Message ID | 20260102005112.552256-21-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=1767315155; bh=6TArTX8z1hWRFlsgFxs7zzQK3iSsDuVKiI9yP1ucBZY=; 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=Rhp/jupJ78lLdkXRY+kNO7K8hTB6aZ2L5dlgvkAj/WmE06QyYmVoA9dKTf6So0Q2Z UUr3jjLmIb+whoMboS/bjYjqeKrZkluvrQw/CFhAYXegEKc8CsvpugMRFyNEnRJhr3 5vizpgmvBYp3hTjML16aKa52HeJDi77hGCKqpa2w4iieuXvuDV9QuyuErW8WBIjQPS Oa2tt2QFSywYurLjDkP3ShxXAtGksqItPbxzzJMiAr1yVpuvm7dcCbyDKbk4YnBnkr jWmT8e0QQGsPLGP74AwIxrZVf3RgqC1wCY/LrRR2ecHm5t/7HLiV1wRm8f51pXZOsG 2F4zXk3582AUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F8F769023 for <u-boot-concept@u-boot.org>; Thu, 1 Jan 2026 17:52: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 10024) with ESMTP id peXjxoyOCV41 for <u-boot-concept@u-boot.org>; Thu, 1 Jan 2026 17:52:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315155; bh=6TArTX8z1hWRFlsgFxs7zzQK3iSsDuVKiI9yP1ucBZY=; 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=Rhp/jupJ78lLdkXRY+kNO7K8hTB6aZ2L5dlgvkAj/WmE06QyYmVoA9dKTf6So0Q2Z UUr3jjLmIb+whoMboS/bjYjqeKrZkluvrQw/CFhAYXegEKc8CsvpugMRFyNEnRJhr3 5vizpgmvBYp3hTjML16aKa52HeJDi77hGCKqpa2w4iieuXvuDV9QuyuErW8WBIjQPS Oa2tt2QFSywYurLjDkP3ShxXAtGksqItPbxzzJMiAr1yVpuvm7dcCbyDKbk4YnBnkr jWmT8e0QQGsPLGP74AwIxrZVf3RgqC1wCY/LrRR2ecHm5t/7HLiV1wRm8f51pXZOsG 2F4zXk3582AUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A1DD68F58 for <u-boot-concept@u-boot.org>; Thu, 1 Jan 2026 17:52:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315153; bh=ex+V+EswiWAXKUhYfsm+GWumW4hs+K0yeddTOjbEWgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Psvlg7MZR7saU5eG04147l5wq9LBEnOq6PU6WtECvfgARs0ERSxk1lAt+A7SFDdf8 RIq7Vbi5pb9YKbNKLUfFbnGIVWjvT+lpSRdugfiNbtkkUxwDib1P07uYgVspP2xLD8 5erHEIuDt+4V6qiBRE42fuGm6ntrTOQFPiNNogm8/C+OA+UkJ2i3aDZKmaE4Ip7HJu 9CpdyomrWFxhKgtRiUPcAKSrHLi980qi/zNdLX3RYMF1PK2gJ2zfUH3mHA3fGkGQfi 7cNWWs062lWHcSaDUN/MYF6nruDvFOzFrJUZGqlPJFs47jK0H2PPgA7PdlWAsO4tBf LxPTZq9eEqVuA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F84368F58; Thu, 1 Jan 2026 17:52:33 -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 qDzlBLpSrKj6; Thu, 1 Jan 2026 17:52:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315147; bh=zRzMd9tKFkHSqIvPJUORtjvD3qIVbHvZL8itEUEGPVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUkXsfwUcu/8BvL5ufuEzIcT0BjRau/RPt1iVnFzOcJOPbTNcCpjpKXajPJei4kpW Q2v6IHVjnj2Y2/leGsC0lWfk4YSId9BcP3WG+WCzxAw1YNM3K8vX+D73KYtLgAewHj 36izTS+FsxeYSQeZ4JhqpgmVxBNuoDSkBZvMrz/MOfBgCyIPx+bH887CzsvG3xhbDB t/SPZ09AVxzPscNNHYptf9bVm1EP1aLhWuDxEs8LvUetkGjtcEavsuPv+gxCGPPjzW rb/jCrVO/5VgO37AyXlb3s6ru81GbSOc6l+GyfFg2A6V58pM4/df3IVJ0qg/j2hTKK Ke4LTEFTXH/PQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D9AC868313; Thu, 1 Jan 2026 17:52:26 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Thu, 1 Jan 2026 17:50:50 -0700 Message-ID: <20260102005112.552256-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: E3VTQUOZB75F5IX5B7LZFWPWTIWUEQLY X-Message-ID-Hash: E3VTQUOZB75F5IX5B7LZFWPWTIWUEQLY 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 v2 20/30] 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/E3VTQUOZB75F5IX5B7LZFWPWTIWUEQLY/> 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
Jan. 2, 2026, 12:50 a.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> --- (no changes since v1) 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); } /**