]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
f2fs: avoid attaching SB_ACTIVE flag during mount/remount
authorChao Yu <yuchao0@huawei.com>
Tue, 25 May 2021 11:39:09 +0000 (19:39 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 26 May 2021 14:00:36 +0000 (07:00 -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()
- f2fs_disable_checkpoint()

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

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

index 6c208108d69c18b3fc7622f85d7606b3088f3720..a578c7d13d8177bbad480d3aea13e64e62af9d2b 100644 (file)
@@ -691,9 +691,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 4b2f7d1d5bf4ba38a02a8b797f17d6ab11e91b2e..4cfe36fa41be90ea7791039cfd34ef9d0677999d 100644 (file)
@@ -782,8 +782,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
@@ -811,10 +809,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);
 
index b29de80ab60e8b2dc8200cbcc342551af849e02a..e70aca8f97bde4b7a673aed95280acfbb548f587 100644 (file)
@@ -1866,17 +1866,15 @@ static int f2fs_enable_quotas(struct super_block *sb);
 
 static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
 {
-       unsigned int s_flags = sbi->sb->s_flags;
        struct cp_control cpc;
        int err = 0;
        int ret;
        block_t unusable;
 
-       if (s_flags & SB_RDONLY) {
+       if (sbi->sb->s_flags & SB_RDONLY) {
                f2fs_err(sbi, "checkpoint=disable on readonly fs");
                return -EINVAL;
        }
-       sbi->sb->s_flags |= SB_ACTIVE;
 
        f2fs_update_time(sbi, DISABLE_TIME);
 
@@ -1894,13 +1892,13 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
        ret = sync_filesystem(sbi->sb);
        if (ret || err) {
                err = ret ? ret : err;
-               goto restore_flag;
+               goto out;
        }
 
        unusable = f2fs_get_unusable_blocks(sbi);
        if (f2fs_disable_cp_again(sbi, unusable)) {
                err = -EAGAIN;
-               goto restore_flag;
+               goto out;
        }
 
        down_write(&sbi->gc_lock);
@@ -1916,8 +1914,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
 
 out_unlock:
        up_write(&sbi->gc_lock);
-restore_flag:
-       sbi->sb->s_flags = s_flags;     /* Restore SB_RDONLY status */
+out:
        return err;
 }