Skip to content

Commit 8f98453

Browse files
LiBaokun96tytso
authored andcommitted
ext4: correct behavior under errors=remount-ro mode
And after commit 9525798 ("ext4: drop EXT4_MF_FS_ABORTED flag") in v6.6-rc1, the EXT4_FLAGS_SHUTDOWN bit is set in ext4_handle_error() under errors=remount-ro mode. This causes the read to fail even when the error is triggered in errors=remount-ro mode. To correct the behavior under errors=remount-ro, EXT4_FLAGS_SHUTDOWN is replaced by the newly introduced EXT4_FLAGS_EMERGENCY_RO. This new flag only prevents writes, matching the previous behavior with SB_RDONLY. Fixes: 9525798 ("ext4: drop EXT4_MF_FS_ABORTED flag") Closes: https://lore.kernel.org/all/[email protected]/ Suggested-by: Jan Kara <[email protected]> Signed-off-by: Baokun Li <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 5bc27f4 commit 8f98453

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

fs/ext4/super.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -693,11 +693,8 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
693693
if (test_opt(sb, WARN_ON_ERROR))
694694
WARN_ON_ONCE(1);
695695

696-
if (!continue_fs && !sb_rdonly(sb)) {
697-
set_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags);
698-
if (journal)
699-
jbd2_journal_abort(journal, -EIO);
700-
}
696+
if (!continue_fs && !ext4_emergency_ro(sb) && journal)
697+
jbd2_journal_abort(journal, -EIO);
701698

702699
if (!bdev_read_only(sb->s_bdev)) {
703700
save_error_info(sb, error, ino, block, func, line);
@@ -723,17 +720,17 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
723720
sb->s_id);
724721
}
725722

726-
if (sb_rdonly(sb) || continue_fs)
723+
if (ext4_emergency_ro(sb) || continue_fs)
727724
return;
728725

729726
ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
730727
/*
731-
* EXT4_FLAGS_SHUTDOWN was set which stops all filesystem
732-
* modifications. We don't set SB_RDONLY because that requires
733-
* sb->s_umount semaphore and setting it without proper remount
734-
* procedure is confusing code such as freeze_super() leading to
735-
* deadlocks and other problems.
728+
* We don't set SB_RDONLY because that requires sb->s_umount
729+
* semaphore and setting it without proper remount procedure is
730+
* confusing code such as freeze_super() leading to deadlocks
731+
* and other problems.
736732
*/
733+
set_bit(EXT4_FLAGS_EMERGENCY_RO, &EXT4_SB(sb)->s_ext4_flags);
737734
}
738735

739736
static void update_super_work(struct work_struct *work)

0 commit comments

Comments
 (0)