ext4: make sure fs error flag setted before clear journal error
authorYe Bin <yebin10@huawei.com>
Tue, 7 Mar 2023 06:17:03 +0000 (14:17 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 11 Mar 2023 05:44:24 +0000 (00:44 -0500)
Now, jounral error number maybe cleared even though ext4_commit_super()
failed. This may lead to error flag miss, then fsck will miss to check
file system deeply.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230307061703.245965-3-yebin@huaweicloud.com
fs/ext4/super.c

index effe5e5bab715708b5df3e3da522fb64f802a833..a7495f4ef3e14e5ff4c26dbb265a783b8a112d37 100644 (file)
@@ -6205,11 +6205,13 @@ static int ext4_clear_journal_err(struct super_block *sb,
                errstr = ext4_decode_error(sb, j_errno, nbuf);
                ext4_warning(sb, "Filesystem error recorded "
                             "from previous mount: %s", errstr);
-               ext4_warning(sb, "Marking fs in need of filesystem check.");
 
                EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
                es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
-               ext4_commit_super(sb);
+               j_errno = ext4_commit_super(sb);
+               if (j_errno)
+                       return j_errno;
+               ext4_warning(sb, "Marked fs in need of filesystem check.");
 
                jbd2_journal_clear_err(journal);
                jbd2_journal_update_sb_errno(journal);