Skip to content

Commit

Permalink
ext4: make sure the journal sb is written in ext4_clear_journal_err()
Browse files Browse the repository at this point in the history
After we transfer set the EXT4_ERROR_FS bit in the file system
superblock, it's not enough to call jbd2_journal_clear_err() to clear
the error indication from journal superblock --- we need to call
jbd2_journal_update_sb_errno() as well.  Otherwise, when the root file
system is mounted read-only, the journal is replayed, and the error
indicator is transferred to the superblock --- but the s_errno field
in the jbd2 superblock is left set (since although we cleared it in
memory, we never flushed it out to disk).

This can end up confusing e2fsck.  We should make e2fsck more robust
in this case, but the kernel shouldn't be leaving things in this
confused state, either.

Signed-off-by: "Theodore Ts'o" <[email protected]>
Cc: [email protected]
  • Loading branch information
tytso committed Aug 5, 2012
1 parent 0d7614f commit d796c52
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -4430,6 +4430,7 @@ static void ext4_clear_journal_err(struct super_block *sb,
ext4_commit_super(sb, 1);

jbd2_journal_clear_err(journal);
jbd2_journal_update_sb_errno(journal);
}
}

Expand Down
3 changes: 2 additions & 1 deletion fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ static void jbd2_mark_journal_empty(journal_t *journal)
* Update a journal's errno. Write updated superblock to disk waiting for IO
* to complete.
*/
static void jbd2_journal_update_sb_errno(journal_t *journal)
void jbd2_journal_update_sb_errno(journal_t *journal)
{
journal_superblock_t *sb = journal->j_superblock;

Expand All @@ -1390,6 +1390,7 @@ static void jbd2_journal_update_sb_errno(journal_t *journal)

jbd2_write_superblock(journal, WRITE_SYNC);
}
EXPORT_SYMBOL(jbd2_journal_update_sb_errno);

/*
* Read the superblock for a given journal, performing initial
Expand Down
1 change: 1 addition & 0 deletions include/linux/jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ extern int jbd2_journal_destroy (journal_t *);
extern int jbd2_journal_recover (journal_t *journal);
extern int jbd2_journal_wipe (journal_t *, int);
extern int jbd2_journal_skip_recovery (journal_t *);
extern void jbd2_journal_update_sb_errno(journal_t *);
extern void jbd2_journal_update_sb_log_tail (journal_t *, tid_t,
unsigned long, int);
extern void __jbd2_journal_abort_hard (journal_t *);
Expand Down

0 comments on commit d796c52

Please sign in to comment.