From: Simon Glass <simon.glass@canonical.com> Add IS_ENABLED(CONFIG_EXT4_WRITE) guards to jbd2 journal code to exclude write-only functions from read-only ext4l builds. The kjournald2 thread and jbd2_journal_commit_transaction() are only needed when writing to the journal. For read-only builds, skip thread creation and checkpoint/commit operations during journal destroy. This saves approximately 4K on Thumb2 builds. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/jbd2/journal.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index f6478c6ca94..0d38f00e555 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -232,6 +232,14 @@ static int jbd2_journal_start_thread(journal_t *journal) { struct task_struct *t; + /* + * The journal thread handles asynchronous commits. For read-only + * builds, we don't need it - commits happen synchronously in + * jbd2_journal_stop() when write support is enabled. + */ + if (!IS_ENABLED(CONFIG_EXT4_WRITE)) + return 0; + t = kthread_run(kjournald2, journal, "jbd2/%s", journal->j_devname); if (IS_ERR(t)) @@ -2117,14 +2125,15 @@ int jbd2_journal_destroy(journal_t *journal) journal_kill_thread(journal); /* Force a final log commit */ - if (journal->j_running_transaction) + if (IS_ENABLED(CONFIG_EXT4_WRITE) && journal->j_running_transaction) jbd2_journal_commit_transaction(journal); /* Force any old transactions to disk */ /* Totally anal locking here... */ spin_lock(&journal->j_list_lock); - while (journal->j_checkpoint_transactions != NULL) { + while (IS_ENABLED(CONFIG_EXT4_WRITE) && + journal->j_checkpoint_transactions != NULL) { spin_unlock(&journal->j_list_lock); mutex_lock_io(&journal->j_checkpoint_mutex); err = jbd2_log_do_checkpoint(journal); -- 2.43.0