Commit 5c31c779 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ext3: error handling robustness

Fix a couple of ext3 error handling routines to not assume that the
superblock has valid journal and buffer_head pointers.  These functions are
called during mount and unmount and that may not be true.

This should fix the oops which Zwane saw when mounting a corrupt filesystem.
parent 39cb2588
...@@ -141,8 +141,11 @@ static void ext3_handle_error(struct super_block *sb) ...@@ -141,8 +141,11 @@ static void ext3_handle_error(struct super_block *sb)
printk (KERN_CRIT "Remounting filesystem read-only\n"); printk (KERN_CRIT "Remounting filesystem read-only\n");
sb->s_flags |= MS_RDONLY; sb->s_flags |= MS_RDONLY;
} else { } else {
journal_t *journal = EXT3_SB(sb)->s_journal;
EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT;
journal_abort(EXT3_SB(sb)->s_journal, -EIO); if (journal)
journal_abort(journal, -EIO);
} }
ext3_commit_super(sb, es, 1); ext3_commit_super(sb, es, 1);
} }
...@@ -1622,11 +1625,15 @@ static void ext3_commit_super (struct super_block * sb, ...@@ -1622,11 +1625,15 @@ static void ext3_commit_super (struct super_block * sb,
struct ext3_super_block * es, struct ext3_super_block * es,
int sync) int sync)
{ {
struct buffer_head *sbh = EXT3_SB(sb)->s_sbh;
if (!sbh)
return;
es->s_wtime = cpu_to_le32(get_seconds()); es->s_wtime = cpu_to_le32(get_seconds());
BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "marking dirty"); BUFFER_TRACE(sbh, "marking dirty");
mark_buffer_dirty(EXT3_SB(sb)->s_sbh); mark_buffer_dirty(sbh);
if (sync) if (sync)
sync_dirty_buffer(EXT3_SB(sb)->s_sbh); sync_dirty_buffer(sbh);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment