Skip to content

Commit

Permalink
jbd2: Fail to load a journal if it is too short
Browse files Browse the repository at this point in the history
Due to on disk corruption, it can happen that journal is too short. Fail
to load it in such case so that we don't oops somewhere later.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Jan Kara authored and Theodore Ts'o committed Jul 17, 2009
1 parent 78f1ddb commit f6f50e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,12 @@ static int journal_reset(journal_t *journal)

first = be32_to_cpu(sb->s_first);
last = be32_to_cpu(sb->s_maxlen);
if (first + JBD2_MIN_JOURNAL_BLOCKS > last + 1) {
printk(KERN_ERR "JBD: Journal too short (blocks %llu-%llu).\n",
first, last);
journal_fail_superblock(journal);
return -EINVAL;
}

journal->j_first = first;
journal->j_last = last;
Expand Down

0 comments on commit f6f50e2

Please sign in to comment.