Commit 7bf0dc9b authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Linus Torvalds

ext2: avoid WARN() messages when failing to write to the superblock

This fixes a common warning reported by kerneloops.org

[Kernel summit hacking hour]
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 28dfef8f
...@@ -1105,9 +1105,30 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1105,9 +1105,30 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
return ret; return ret;
} }
static void ext2_clear_super_error(struct super_block *sb)
{
struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
if (buffer_write_io_error(sbh)) {
/*
* Oh, dear. A previous attempt to write the
* superblock failed. This could happen because the
* USB device was yanked out. Or it could happen to
* be a transient write error and maybe the block will
* be remapped. Nothing we can do but to retry the
* write and hope for the best.
*/
printk(KERN_ERR "EXT2-fs: %s previous I/O error to "
"superblock detected", sb->s_id);
clear_buffer_write_io_error(sbh);
set_buffer_uptodate(sbh);
}
}
static void ext2_commit_super (struct super_block * sb, static void ext2_commit_super (struct super_block * sb,
struct ext2_super_block * es) struct ext2_super_block * es)
{ {
ext2_clear_super_error(sb);
es->s_wtime = cpu_to_le32(get_seconds()); es->s_wtime = cpu_to_le32(get_seconds());
mark_buffer_dirty(EXT2_SB(sb)->s_sbh); mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
sb->s_dirt = 0; sb->s_dirt = 0;
...@@ -1115,6 +1136,7 @@ static void ext2_commit_super (struct super_block * sb, ...@@ -1115,6 +1136,7 @@ static void ext2_commit_super (struct super_block * sb,
static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
{ {
ext2_clear_super_error(sb);
es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
es->s_wtime = cpu_to_le32(get_seconds()); es->s_wtime = cpu_to_le32(get_seconds());
......
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