Commit 7c2e7087 authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: add ext4-specific kludge to avoid an oops after the disk disappears

The del_gendisk() function uninitializes the disk-specific data
structures, including the bdi structure, without telling anyone
else.  Once this happens, any attempt to call mark_buffer_dirty()
(for example, by ext4_commit_super), will cause a kernel OOPS.

Fix this for now until we can fix things in an architecturally correct
way.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 02fac129
...@@ -414,6 +414,22 @@ static void save_error_info(struct super_block *sb, const char *func, ...@@ -414,6 +414,22 @@ static void save_error_info(struct super_block *sb, const char *func,
ext4_commit_super(sb, 1); ext4_commit_super(sb, 1);
} }
/*
* The del_gendisk() function uninitializes the disk-specific data
* structures, including the bdi structure, without telling anyone
* else. Once this happens, any attempt to call mark_buffer_dirty()
* (for example, by ext4_commit_super), will cause a kernel OOPS.
* This is a kludge to prevent these oops until we can put in a proper
* hook in del_gendisk() to inform the VFS and file system layers.
*/
static int block_device_ejected(struct super_block *sb)
{
struct inode *bd_inode = sb->s_bdev->bd_inode;
struct backing_dev_info *bdi = bd_inode->i_mapping->backing_dev_info;
return bdi->dev == NULL;
}
/* Deal with the reporting of failure conditions on a filesystem such as /* Deal with the reporting of failure conditions on a filesystem such as
* inconsistencies detected or read IO failures. * inconsistencies detected or read IO failures.
...@@ -4072,7 +4088,7 @@ static int ext4_commit_super(struct super_block *sb, int sync) ...@@ -4072,7 +4088,7 @@ static int ext4_commit_super(struct super_block *sb, int sync)
struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
int error = 0; int error = 0;
if (!sbh) if (!sbh || block_device_ejected(sb))
return error; return error;
if (buffer_write_io_error(sbh)) { if (buffer_write_io_error(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