From: "Stephen C. Tweedie" ext3 has long had a problem wherein it will unnecessarily write to a read-only filesystem during the mount process. It does this in preparing the journal superblock's sequence numbers. But if the filesystem was shut down cleanly we do not need to do this. Detect the situation and avoid modifying and writing out the journal superblock. /dev/null | 0 fs/jbd/journal.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) diff -puN fs/jbd/journal.c~jbd-really-readonly fs/jbd/journal.c --- 25/fs/jbd/journal.c~jbd-really-readonly 2003-06-18 23:23:43.000000000 -0700 +++ 25-akpm/fs/jbd/journal.c 2003-06-18 23:26:00.000000000 -0700 @@ -868,6 +868,22 @@ void journal_update_superblock(journal_t journal_superblock_t *sb = journal->j_superblock; struct buffer_head *bh = journal->j_sb_buffer; + /* + * As a special case, if the on-disk copy is already marked as needing + * no recovery (s_start == 0) and there are no outstanding transactions + * in the filesystem, then we can safely defer the superblock update + * until the next commit by setting JFS_FLUSHED. This avoids + * attempting a write to a potential-readonly device. + */ + if (sb->s_start == 0 && journal->j_tail_sequence == + journal->j_transaction_sequence) { + jbd_debug(1,"JBD: Skipping superblock update on recovered sb " + "(start %ld, seq %d, errno %d)\n", + journal->j_tail, journal->j_tail_sequence, + journal->j_errno); + goto out; + } + spin_lock(&journal->j_state_lock); jbd_debug(1,"JBD: updating superblock (start %ld, seq %d, errno %d)\n", journal->j_tail, journal->j_tail_sequence, journal->j_errno); @@ -884,6 +900,7 @@ void journal_update_superblock(journal_t else ll_rw_block(WRITE, 1, &bh); +out: /* If we have just flushed the log (by marking s_start==0), then * any future commit will have to be careful to update the * superblock again to re-record the true start of the log. */ diff -puN -L fs/jbd/journal.c.=K0004=.orig /dev/null /dev/null _