Skip to content

Commit

Permalink
jbd2: If a journal checksum error is detected, propagate the error to…
Browse files Browse the repository at this point in the history
… ext4

If a journal checksum error is detected, the ext4 filesystem will call
ext4_error(), and the mount will either continue, become a read-only
mount, or cause a kernel panic based on the superblock flags
indicating the user's preference of what to do in case of filesystem
corruption being detected.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Theodore Ts'o committed Jun 6, 2008
1 parent 8ea7690 commit 624080e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
23 changes: 23 additions & 0 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,29 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
if (ext4_load_journal(sb, es, journal_devnum))
goto failed_mount3;
if (!(sb->s_flags & MS_RDONLY) &&
EXT4_SB(sb)->s_journal->j_failed_commit) {
printk(KERN_CRIT "EXT4-fs error (device %s): "
"ext4_fill_super: Journal transaction "
"%u is corrupt\n", sb->s_id,
EXT4_SB(sb)->s_journal->j_failed_commit);
if (test_opt (sb, ERRORS_RO)) {
printk (KERN_CRIT
"Mounting filesystem read-only\n");
sb->s_flags |= MS_RDONLY;
EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
}
if (test_opt(sb, ERRORS_PANIC)) {
EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
ext4_commit_super(sb, es, 1);
printk(KERN_CRIT
"EXT4-fs (device %s): mount failed\n",
sb->s_id);
goto failed_mount4;
}
}
} else if (journal_inum) {
if (ext4_create_journal(sb, es, journal_inum))
goto failed_mount3;
Expand Down
11 changes: 4 additions & 7 deletions fs/jbd2/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,8 @@ static int do_one_pass(journal_t *journal,
chksum_err = chksum_seen = 0;

if (info->end_transaction) {
printk(KERN_ERR "JBD: Transaction %u "
"found to be corrupt.\n",
next_commit_ID - 1);
journal->j_failed_commit =
info->end_transaction;
brelse(bh);
break;
}
Expand Down Expand Up @@ -644,10 +643,8 @@ static int do_one_pass(journal_t *journal,

if (!JBD2_HAS_INCOMPAT_FEATURE(journal,
JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)){
printk(KERN_ERR
"JBD: Transaction %u "
"found to be corrupt.\n",
next_commit_ID);
journal->j_failed_commit =
next_commit_ID;
brelse(bh);
break;
}
Expand Down
3 changes: 3 additions & 0 deletions include/linux/jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,9 @@ struct journal_s
struct proc_dir_entry *j_proc_entry;
struct transaction_stats_s j_stats;

/* Failed journal commit ID */
unsigned int j_failed_commit;

/*
* An opaque pointer to fs-private information. ext3 puts its
* superblock pointer here
Expand Down

0 comments on commit 624080e

Please sign in to comment.