f2fs: avoid attaching SB_ACTIVE flag during mount
authorChao Yu <chao@kernel.org>
Wed, 1 Sep 2021 08:06:21 +0000 (16:06 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 16 Sep 2021 15:38:32 +0000 (08:38 -0700)
Quoted from [1]

"I do remember that I've added this code back then because otherwise
orphan cleanup was losing updates to quota files. But you're right
that now I don't see how that could be happening and it would be nice
if we could get rid of this hack"

[1] https://lore.kernel.org/linux-ext4/99cce8ca-e4a0-7301-840f-2ace67c551f3@huawei.com/T/#m04990cfbc4f44592421736b504afcc346b2a7c00

Related fix in ext4 by
commit 72ffb49a7b62 ("ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()").

f2fs has the same hack implementation in
- f2fs_recover_orphan_inodes()
- f2fs_recover_fsync_data()

Let's get rid of this hack as well in f2fs.

Cc: Zhang Yi <yi.zhang@huawei.com>
Cc: Jan Kara <jack@suse.cz>
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/recovery.c

index 7b02827242312d9c350c7db667b6c810e65666d2..6f6a7d812d6098431904141bd9457663605c7d16 100644 (file)
@@ -705,9 +705,6 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
        }
 
 #ifdef CONFIG_QUOTA
-       /* Needed for iput() to work correctly and not trash data */
-       sbi->sb->s_flags |= SB_ACTIVE;
-
        /*
         * Turn on quotas which were not enabled for read-only mounts if
         * filesystem has quota feature, so that they are updated correctly.
index 04655511d7f514593d388ef88bd6ac4be17b4988..706ddb3c95c0229a1cb6f481d4f7338b1a1b5a0f 100644 (file)
@@ -787,8 +787,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
        }
 
 #ifdef CONFIG_QUOTA
-       /* Needed for iput() to work correctly and not trash data */
-       sbi->sb->s_flags |= SB_ACTIVE;
        /* Turn on quotas so that they are updated correctly */
        quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
 #endif
@@ -816,10 +814,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
        err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list);
        if (!err)
                f2fs_bug_on(sbi, !list_empty(&inode_list));
-       else {
-               /* restore s_flags to let iput() trash data */
-               sbi->sb->s_flags = s_flags;
-       }
+       else
+               f2fs_bug_on(sbi, sbi->sb->s_flags & SB_ACTIVE);
 skip:
        fix_curseg_write_pointer = !check_only || list_empty(&inode_list);