From 5c31c7796bfccae34b499aa7f7d1d5c6e3237576 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 10 Mar 2003 07:42:39 -0800 Subject: [PATCH] [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. --- fs/ext3/super.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index ef7ec7b2aecd1..78226c29259e2 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -141,8 +141,11 @@ static void ext3_handle_error(struct super_block *sb) printk (KERN_CRIT "Remounting filesystem read-only\n"); sb->s_flags |= MS_RDONLY; } else { + journal_t *journal = EXT3_SB(sb)->s_journal; + 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); } @@ -1622,11 +1625,15 @@ static void ext3_commit_super (struct super_block * sb, struct ext3_super_block * es, int sync) { + struct buffer_head *sbh = EXT3_SB(sb)->s_sbh; + + if (!sbh) + return; es->s_wtime = cpu_to_le32(get_seconds()); - BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "marking dirty"); - mark_buffer_dirty(EXT3_SB(sb)->s_sbh); + BUFFER_TRACE(sbh, "marking dirty"); + mark_buffer_dirty(sbh); if (sync) - sync_dirty_buffer(EXT3_SB(sb)->s_sbh); + sync_dirty_buffer(sbh); } -- 2.53.0