Patch "f2fs: Fix the race condition of resize flag between resizefs" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    f2fs: Fix the race condition of resize flag between resizefs

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     f2fs-fix-the-race-condition-of-resize-flag-between-r.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 54b7534194fb953130faff104e5a015ad3ecc342
Author: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
Date:   Tue Oct 18 10:45:32 2022 +0800

    f2fs: Fix the race condition of resize flag between resizefs
    
    [ Upstream commit 28fc4e9077ce59ab28c89c20dc6be5154473218f ]
    
    Because the set/clear SBI_IS_RESIZEFS flag not between any locks,
    In the following case:
      thread1                       thread2
       ->ioctl(resizefs)
        ->set RESIZEFS flag          ->ioctl(resizefs)
        ...                           ->set RESIZEFS flag
        ->clear RESIZEFS flag
                                      ->resizefs stream
                                        # No RESIZEFS flag in the stream
    
    Also before freeze_super, the resizefs not started, we should not set
    the SBI_IS_RESIZEFS flag.
    
    So move the set/clear SBI_IS_RESIZEFS flag between the cp_mutex and
    gc_lock.
    
    Fixes: b4b10061ef98 ("f2fs: refactor resize_fs to avoid meta updates in progress")
    Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@xxxxxxxxxx>
    Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
    Reviewed-by: Chao Yu <chao@xxxxxxxxxx>
    Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index e75a276f5b9c..4cbaa6ab083f 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -2051,8 +2051,6 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 	if (err)
 		return err;
 
-	set_sbi_flag(sbi, SBI_IS_RESIZEFS);
-
 	freeze_super(sbi->sb);
 	down_write(&sbi->gc_lock);
 	down_write(&sbi->cp_global_sem);
@@ -2068,6 +2066,7 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 	if (err)
 		goto out_err;
 
+	set_sbi_flag(sbi, SBI_IS_RESIZEFS);
 	err = free_segment_range(sbi, secs, false);
 	if (err)
 		goto recover_out;
@@ -2091,6 +2090,7 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 		f2fs_commit_super(sbi, false);
 	}
 recover_out:
+	clear_sbi_flag(sbi, SBI_IS_RESIZEFS);
 	if (err) {
 		set_sbi_flag(sbi, SBI_NEED_FSCK);
 		f2fs_err(sbi, "resize_fs failed, should run fsck to repair!");
@@ -2103,6 +2103,5 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 	up_write(&sbi->cp_global_sem);
 	up_write(&sbi->gc_lock);
 	thaw_super(sbi->sb);
-	clear_sbi_flag(sbi, SBI_IS_RESIZEFS);
 	return err;
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux