Commit c89128a0 authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Theodore Ts'o

ext4: handle errors on ext4_commit_super

When remounting ext4 from ro to rw, currently it allows its transition,
even if ext4_commit_super() returns EIO. Even worse thing is, after that,
fs/buffer complains buffer dirty bits like:

 Call trace:
 [<ffffff9750c259dc>] mark_buffer_dirty+0x184/0x1a4
 [<ffffff9750cb398c>] __ext4_handle_dirty_super+0x4c/0xfc
 [<ffffff9750c7a9fc>] ext4_file_open+0x154/0x1c0
 [<ffffff9750bea51c>] do_dentry_open+0x114/0x2d0
 [<ffffff9750bea75c>] vfs_open+0x5c/0x94
 [<ffffff9750bf879c>] path_openat+0x668/0xfe8
 [<ffffff9750bf8088>] do_filp_open+0x74/0x120
 [<ffffff9750beac98>] do_sys_open+0x148/0x254
 [<ffffff9750beade0>] SyS_openat+0x10/0x18
 [<ffffff9750a83ab0>] el0_svc_naked+0x24/0x28
 EXT4-fs (dm-1): previous I/O error to superblock detected
 Buffer I/O error on dev dm-1, logical block 0, lost sync page write
 EXT4-fs (dm-1): re-mounted. Opts: (null)
 Buffer I/O error on dev dm-1, logical block 80, lost async page write
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@google.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent db6516a5
...@@ -2146,12 +2146,12 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, ...@@ -2146,12 +2146,12 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
int read_only) int read_only)
{ {
struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(sb);
int res = 0; int err = 0;
if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) { if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) {
ext4_msg(sb, KERN_ERR, "revision level too high, " ext4_msg(sb, KERN_ERR, "revision level too high, "
"forcing read-only mode"); "forcing read-only mode");
res = SB_RDONLY; err = -EROFS;
} }
if (read_only) if (read_only)
goto done; goto done;
...@@ -2184,7 +2184,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, ...@@ -2184,7 +2184,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
if (sbi->s_journal) if (sbi->s_journal)
ext4_set_feature_journal_needs_recovery(sb); ext4_set_feature_journal_needs_recovery(sb);
ext4_commit_super(sb, 1); err = ext4_commit_super(sb, 1);
done: done:
if (test_opt(sb, DEBUG)) if (test_opt(sb, DEBUG))
printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, "
...@@ -2196,7 +2196,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, ...@@ -2196,7 +2196,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
sbi->s_mount_opt, sbi->s_mount_opt2); sbi->s_mount_opt, sbi->s_mount_opt2);
cleancache_init_fs(sb); cleancache_init_fs(sb);
return res; return err;
} }
int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup) int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup)
...@@ -4254,8 +4254,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4254,8 +4254,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
goto failed_mount4; goto failed_mount4;
} }
if (ext4_setup_super(sb, es, sb_rdonly(sb))) ret = ext4_setup_super(sb, es, sb_rdonly(sb));
if (ret == -EROFS) {
sb->s_flags |= SB_RDONLY; sb->s_flags |= SB_RDONLY;
ret = 0;
} else if (ret)
goto failed_mount4a;
/* determine the minimum size of new large inodes, if present */ /* determine the minimum size of new large inodes, if present */
if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE && if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE &&
...@@ -4790,11 +4794,7 @@ static int ext4_commit_super(struct super_block *sb, int sync) ...@@ -4790,11 +4794,7 @@ static int ext4_commit_super(struct super_block *sb, int sync)
unlock_buffer(sbh); unlock_buffer(sbh);
error = __sync_dirty_buffer(sbh, error = __sync_dirty_buffer(sbh,
REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0)); REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0));
if (error) if (buffer_write_io_error(sbh)) {
return error;
error = buffer_write_io_error(sbh);
if (error) {
ext4_msg(sb, KERN_ERR, "I/O error while writing " ext4_msg(sb, KERN_ERR, "I/O error while writing "
"superblock"); "superblock");
clear_buffer_write_io_error(sbh); clear_buffer_write_io_error(sbh);
...@@ -5195,8 +5195,12 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -5195,8 +5195,12 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
if (sbi->s_journal) if (sbi->s_journal)
ext4_clear_journal_err(sb, es); ext4_clear_journal_err(sb, es);
sbi->s_mount_state = le16_to_cpu(es->s_state); sbi->s_mount_state = le16_to_cpu(es->s_state);
if (!ext4_setup_super(sb, es, 0))
sb->s_flags &= ~SB_RDONLY; err = ext4_setup_super(sb, es, 0);
if (err)
goto restore_opts;
sb->s_flags &= ~SB_RDONLY;
if (ext4_has_feature_mmp(sb)) if (ext4_has_feature_mmp(sb))
if (ext4_multi_mount_protect(sb, if (ext4_multi_mount_protect(sb,
le64_to_cpu(es->s_mmp_block))) { le64_to_cpu(es->s_mmp_block))) {
...@@ -5220,8 +5224,11 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -5220,8 +5224,11 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
} }
ext4_setup_system_zone(sb); ext4_setup_system_zone(sb);
if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
ext4_commit_super(sb, 1); err = ext4_commit_super(sb, 1);
if (err)
goto restore_opts;
}
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
/* Release old quota file names */ /* Release old quota file names */
......
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