From patchwork Mon Dec 22 11:56:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1041 Return-Path: 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=1766404649; bh=P6oPkCwonh2Q9tTPW3+JsN56aiZsaRRltQ1K7DtG4X4=; 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=Ce1h28a8k4kbDaGKB/PLhhzL+l4voMLP7vq/3R2sOVif7jo+NFJ3AyoEOhPY/+ygH AGBS1b7y6Kbk5vg+tb3HXNQYXRI+AuPbLsZHabys3MiT0rrJfqiyWq0i1eXBewseYH 2RYYcm1bJTu2FedPeKQjK3+5hwVzYb5dKh5F6px2+eFGqDFlFg1dCRFENmUWK1m6Fp gHQg7Hbt4PeN8jHhC6QkGtZJcKWaqpVvordcScmR3H/6ySKGgJH57x6NJScc5+ees9 IVVHTtQyUx7dux7FGV8CMCIr8ZLkI2bGer0nXJ9iiO6tlXg56sgQ9+FDz2AJmR7PP9 X3Me5/iP6XLTA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ABD9864D8C for ; Mon, 22 Dec 2025 04:57:29 -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 c_P2ugYJhBVR for ; Mon, 22 Dec 2025 04:57:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404647; bh=P6oPkCwonh2Q9tTPW3+JsN56aiZsaRRltQ1K7DtG4X4=; 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=EMV0CyA2M7WCsTi6tmnBkOcLEg7+wJd1DHTRuwnLy8oIky3ne1Tl6UQW8VAhrF6+1 g8n/6qHg4fMf+7O+qxPrbcBnxYei1/pRHHko2WzmyXAGL0G1cU0KYWANImifRsEdKA qHkRLg2hJcLtmM8w4ILmfzVZ08fksRVlm5y+icz1KtKgaFUwwErVjZT0irxnQeyRWW FylaBn8nLWmxwpVPu+ZsGWqfer6CEVo7sKLDpw0l8IJYc98u8JpqGTzIF0R1KLZHoE Z+5rrZtYo7HqkXhPtuhYPryWJ3FwXO/ntk81ZyN2/MkkqnvWV0VkkyzO6aDoASSHDK x7ohsTU/CXEng== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A83B05FB5A for ; Mon, 22 Dec 2025 04:57:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404644; bh=R3mNxPM94dxb2J0hrqLjFG4lkfzpmsW/KhMVPXBDrV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lg/vlQDDCF0j1luf6GYdgiv3i851TR8f+nfqkgUlXtUPWvMYWGdLcKetq9X/lL7EV xiiPjdkjkJmiYPMd743Cq8Tssce3nZ+vpHYMLOZc38Kue8wEYhVlcMhHfA7w/QZpM9 uVqJG/+XkiKF7fmLv92Ih1yEDtH8Ui7N3Xtr8SeyiDoSM5VVYysIAZ6YpobrGWumKS Yduoop4loSs7OSvkwswuOmWsySDpaGqS2AXwRODqJFd2atTLBOUxhQnynWKbT1VZ8k a8NHVr4VPWV8iRkalxoWoZJDX/YDj8BsYNOSnJejfjf96aCEurTvHccXwjrBn5ixnu P6gboYe+nfO3w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 410D95FB5A; Mon, 22 Dec 2025 04:57:24 -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 X3f9em9zGyAs; Mon, 22 Dec 2025 04:57:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404643; bh=PPNqQuxAu30xmobO/5SM4m72N7wrbWLl/w3j5y795pU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E/fcPD40XWx/LXMjaOYF/fTrbbD1WseYvbwfDMzJXJn4fVPLR8BLnPPRxH20Qz8Vh /uYtyx4M7K+9Na3zOWr4xDwG4bOGCqUqaLnGznsXMzQ6+M5YVdoA9/0mGOfdiL7fET 8/BXDmrOGx17pOqONdpxoLyAq4UL/TKh1tdLPyhOlSCe9r2mJmchUdRgU0/L0fyQz+ KBpeIcCNfTlfwXYBuObI2blOU0W8N19VkacPwFC0HFV35+Q4pzQFK4v41mcQGq4zgR kCVZgHQ1LNMkIyvaAs0cnEsVJNdPip20ElQ0230LMpFOHz60T/8idzgC5Eu9sfwE8f zLqtHgd5ROqiw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2649764D62; Mon, 22 Dec 2025 04:57:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 04:56:15 -0700 Message-ID: <20251222115639.700578-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251222115639.700578-1-sjg@u-boot.org> References: <20251222115639.700578-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7HEHMTGIBY2BSMH2KW4OZF3PLE3F7ORZ X-Message-ID-Hash: 7HEHMTGIBY2BSMH2KW4OZF3PLE3F7ORZ 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/26] fs: jbd2: Add jbd2_journal_init_global() for ext4l List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add jbd2_journal_init_global() which initializes the JBD2 journal subsystem caches. This wraps the existing journal_init() with a static guard to ensure it's only called once. Call this from ext4l_probe() when CONFIG_EXT4_JOURNAL is enabled to initialize the journal subsystem before any journal operations. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 8 ++++++++ fs/jbd2/journal.c | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index eb625e0b1a5..546017efd16 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "ext4_uboot.h" @@ -33,6 +34,13 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, if (!fs_dev_desc) return -EINVAL; + /* Initialise journal subsystem if enabled */ + if (IS_ENABLED(CONFIG_EXT4_JOURNAL)) { + ret = jbd2_journal_init_global(); + if (ret) + return ret; + } + buf = malloc(BLOCK_SIZE + 512); if (!buf) return -ENOMEM; diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 0b77fd0f34b..0cd95df8192 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -3118,6 +3118,28 @@ static int __init journal_init(void) return ret; } +/** + * jbd2_journal_init_global() - Initialize JBD2 global state + * + * This must be called before any journal operations. It initializes + * the journal caches and other global state. + * + * Return: 0 on success, negative error code on failure + */ +int jbd2_journal_init_global(void) +{ + static bool initialized; + + if (initialized) + return 0; + + if (journal_init()) + return -ENOMEM; + + initialized = true; + return 0; +} + static void __exit journal_exit(void) { #ifdef CONFIG_JBD2_DEBUG