]> git.itanic.dy.fi Git - linux-stable/commitdiff
ext4: drop EXT4_MF_FS_ABORTED flag
authorJan Kara <jack@suse.cz>
Fri, 16 Jun 2023 16:50:51 +0000 (18:50 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 29 Jul 2023 22:37:53 +0000 (18:37 -0400)
EXT4_MF_FS_ABORTED flag has practically the same intent as
EXT4_FLAGS_SHUTDOWN flag. The shutdown flag is checked in many more
places than the aborted flag which is mostly the historical artifact
where we were relying on SB_RDONLY checks instead of the aborted flag
checks. There are only three places - ext4_sync_file(),
__ext4_remount(), and mballoc debug code - which check aborted flag and
not shutdown flag and this is arguably a bug. Avoid these
inconsistencies by removing EXT4_MF_FS_ABORTED flag and using
EXT4_FLAGS_SHUTDOWN everywhere.

Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230616165109.21695-5-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/fsync.c
fs/ext4/inode.c
fs/ext4/mballoc.c
fs/ext4/super.c

index 907829007f3fcdee824228a8238891696f03e601..89d76d50af4ca8eb839aa18a140c21866ff122a1 100644 (file)
@@ -1799,7 +1799,6 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
  */
 enum {
        EXT4_MF_MNTDIR_SAMPLED,
-       EXT4_MF_FS_ABORTED,     /* Fatal error detected */
        EXT4_MF_FC_INELIGIBLE   /* Fast commit ineligible */
 };
 
index bffc1d0994f5429ec10de46eafcf13116c2b7f5e..b40d3b29f7e5c5b88694794c28198afc2f951aa4 100644 (file)
@@ -131,7 +131,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
        int ret = 0, err;
        bool needs_barrier = false;
        struct inode *inode = file->f_mapping->host;
-       struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 
        if (unlikely(ext4_forced_shutdown(inode->i_sb)))
                return -EIO;
@@ -141,14 +140,14 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
        trace_ext4_sync_file_enter(file, datasync);
 
        if (sb_rdonly(inode->i_sb)) {
-               /* Make sure that we read updated s_mount_flags value */
+               /* Make sure that we read updated s_ext4_flags value */
                smp_rmb();
-               if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FS_ABORTED))
+               if (ext4_forced_shutdown(inode->i_sb))
                        ret = -EROFS;
                goto out;
        }
 
-       if (!sbi->s_journal) {
+       if (!EXT4_SB(inode->i_sb)->s_journal) {
                ret = ext4_fsync_nojournal(file, start, end, datasync,
                                           &needs_barrier);
                if (needs_barrier)
index c6fa59e57f1ea1075a7d47bdd01edbcf97b1b7b3..100c3ec6da6c682a8ec1a568b8584969dc89637f 100644 (file)
@@ -2213,8 +2213,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
                if (err < 0) {
                        struct super_block *sb = inode->i_sb;
 
-                       if (ext4_forced_shutdown(sb) ||
-                           ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED))
+                       if (ext4_forced_shutdown(sb))
                                goto invalidate_dirty_pages;
                        /*
                         * Let the uper layers retry transient errors.
@@ -2534,14 +2533,13 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
         * If the filesystem has aborted, it is read-only, so return
         * right away instead of dumping stack traces later on that
         * will obscure the real source of the problem.  We test
-        * EXT4_MF_FS_ABORTED instead of sb->s_flag's SB_RDONLY because
+        * fs shutdown state instead of sb->s_flag's SB_RDONLY because
         * the latter could be true if the filesystem is mounted
         * read-only, and in that case, ext4_writepages should
         * *never* be called, so if that ever happens, we would want
         * the stack trace.
         */
-       if (unlikely(ext4_forced_shutdown(mapping->host->i_sb) ||
-                    ext4_test_mount_flag(inode->i_sb, EXT4_MF_FS_ABORTED))) {
+       if (unlikely(ext4_forced_shutdown(mapping->host->i_sb))) {
                ret = -EROFS;
                goto out_writepages;
        }
index 78a4a24e2f578d1765dedb520aa7403831cb4e4c..1dc63e329e64bbac2503483b8313510730a52872 100644 (file)
@@ -5664,7 +5664,7 @@ static inline void ext4_mb_show_pa(struct super_block *sb)
 {
        ext4_group_t i, ngroups;
 
-       if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED))
+       if (ext4_forced_shutdown(sb))
                return;
 
        ngroups = ext4_get_groups_count(sb);
@@ -5698,7 +5698,7 @@ static void ext4_mb_show_ac(struct ext4_allocation_context *ac)
 {
        struct super_block *sb = ac->ac_sb;
 
-       if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED))
+       if (ext4_forced_shutdown(sb))
                return;
 
        mb_debug(sb, "Can't allocate:"
index f84142907cd51ef81252352579678fd900c0ccd8..20a8e64da4ac7372bc19d947d258980729475191 100644 (file)
@@ -657,7 +657,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
                WARN_ON_ONCE(1);
 
        if (!continue_fs && !sb_rdonly(sb)) {
-               ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED);
+               set_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags);
                if (journal)
                        jbd2_journal_abort(journal, -EIO);
        }
@@ -6502,7 +6502,7 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
        flush_work(&sbi->s_error_work);
 
        if ((bool)(fc->sb_flags & SB_RDONLY) != sb_rdonly(sb)) {
-               if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) {
+               if (ext4_forced_shutdown(sb)) {
                        err = -EROFS;
                        goto restore_opts;
                }