jbd2: If a journal checksum error is detected, propagate the error to 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>
This commit is contained in:
parent
8ea76900be
commit
624080eded
3 changed files with 30 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue