From patchwork Tue Dec 30 20:51:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1111 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=1767127942; bh=acbwvY78xnMqg9LdR9AvlvHH5l/cK7jaK5vcsayQbBU=; 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=ptx1cy3/Ew3e1b/ijZOkgW6EaglGA8Fy6VlXQ529URyi1I953MBPNSUGbi2mJQZjq X+JWmTOdxO83fV4ApCKquVe+9bCPRWw/jjVSyrj+VZDIJbXc14NAxiPlg6Bz2tTtEf sd6k5GRlfSCQMQEOH7RrxzNfG8JbASu7aNRp8gP8fxTOwxO6+8LvN71E4tbxnGGYyV mMJ8jlhtgrlL0YUflNb9LHXW/ex7v6/EopSGiO/2MB61U4OSluKXl46a5pFW9ZqZLA 9uUTQ7SvpDnO9+OkVFtTt4LUBb8sdJgUsM25BGdhnlmGUFDOZYoh3Nrwauyv58FMJo P+sxNHzxjWuug== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ABD5C68F80 for ; Tue, 30 Dec 2025 13:52:22 -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 cBAGIzVhEnBU for ; Tue, 30 Dec 2025 13:52:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127941; bh=acbwvY78xnMqg9LdR9AvlvHH5l/cK7jaK5vcsayQbBU=; 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=chcasN+j7AV3Wheeo3FM/9rnl8lquXmYlqQbHWOSCUt8VTD/h9wB/TDMPg6jRp7jP eT/HzHmTLoUE6XzGNno6yMKMSLZ62LlG3eI05NiGAfZUOUFXgedkeK7EokrmgABy0K cKlNFNLIEAceB1FP1N5UDN3UCbU2B1dho3PfxV5/Rn1jtZC0Fz4NyL+VLDq/5ghl57 UuQVUiwzoheHcakTgTii3DGlTYaK2MpZ7bbXcAwn+mYEExZ/gMpsw77oxvmJXEBGNf s7PV3Y7J/KcrV840KC942IysC9aKo4R13bCC3vLC04cIh2TBMH+I/kMJNb58AhnJxA Zckglv1sEzSlA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CE4168F86 for ; Tue, 30 Dec 2025 13:52:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127939; bh=Qqrh0nQjhhiNMZ/1sg86fMRb7rJAT6GMriEhNuYECmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m//P8nY9p2713AE4ZkW3cSpIaU/Mh+oIyaUram4AcThzcbRlT9fH7tUgwPoVbpWtj M5M6zEh4MxxkpV8JTs2CoroWWtGW5iRObBoZ9uiyTptA3FbFHBilO0Movat5x5oOlT cbscy+CRCfP+F3fnw115S6A/woxmgrJcdFtuMiAuZ2il0GuKF78hLG+NPHHcEjVBcc 161SMIZPGn1cPf8tjVCYLUMPFI4z1sRMO3vwbbP/f514yttEyB0E6kLgWCZGVz8EkM o5ZvPHP3/mkwxjaTOQoYbQ29UZgiBk5TyKRnlHev6fxiTUG3ZV7aZoR9vK3KvAG47N ZLbeazvmH70sg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0EF7368F73; Tue, 30 Dec 2025 13:52:19 -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 iGMXe1256MmF; Tue, 30 Dec 2025 13:52:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767127938; bh=6BOvmK+I76n7zEbZAUjsEgE1r5B7RxTv02LVieryHXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xxl4lW7lXQD3sUVY8Jc9yMMejYL+LIsIkMuv+RloxnCsRCGwTD/C8zZClM95bNqr7 r+EV5j52618URGzvEJpGEUIgQFFtL2aP/fnYH5V0kmRYInmmOFRkWfoungjdRE7w8o XKTKV+sh58bn5m/OCeK7WxdLTZpe0aJ4aC6HxOYKHjBsgllDkuO/I8JzKZYPhwRb/y u8NRcccCqvZzK2xj8Sfz0Ga8WICY14N3C9SSV4YfVsDBM3MODQdcw/SYtbxCHZBjYk 1Ums/rLIrVXN/GNIOb8vPB1TFnqbSg03VgsqEFApYEQgpgzWp7/IISCInfXTM8DztV SZGLInwGNZHaw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8A18864C8A; Tue, 30 Dec 2025 13:52:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Dec 2025 13:51:39 -0700 Message-ID: <20251230205157.3383926-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251230205157.3383926-1-sjg@u-boot.org> References: <20251230205157.3383926-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ENI3TQT7SH54MOO4QW7IJS3TEHNEA5NF X-Message-ID-Hash: ENI3TQT7SH54MOO4QW7IJS3TEHNEA5NF 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 02/14] linux: jbd2: Add synchronous commit on transaction stop 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 U-Boot operates in a single-threaded environment without a journal daemon. Commit transactions synchronously when jbd2_journal_stop() is called and there are no active handles (t_updates == 0). This ensures crash-safety by writing journal entries to disk immediately after each file-operation completes. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/jbd2/transaction.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index a524f490c79..b997c8495f5 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -1938,6 +1938,24 @@ int jbd2_journal_stop(handle_t *handle) */ stop_this_handle(handle); +#ifdef __UBOOT__ + /* + * U-Boot: Always commit synchronously for crash safety. + * In single-threaded mode, we commit immediately after each + * operation completes to ensure durability. + */ + if (IS_ENABLED(CONFIG_EXT4_WRITE) && + journal->j_running_transaction && + atomic_read(&journal->j_running_transaction->t_updates) == 0) { + jbd2_journal_commit_transaction(journal); + /* + * Check if journal was aborted during commit + * (e.g., due to I/O error) and propagate the error. + */ + if (is_journal_aborted(journal) && !err) + err = -EIO; + } else +#endif if (wait_for_commit) err = jbd2_log_wait_commit(journal, tid);