Patch "f2fs: fix race condition on setting FI_NO_EXTENT flag" 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 race condition on setting FI_NO_EXTENT flag

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-race-condition-on-setting-fi_no_extent-flag.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 b3dbe3fe1f2586230740247f99f7eb6b21578ee8
Author: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
Date:   Mon Sep 5 12:59:17 2022 +0800

    f2fs: fix race condition on setting FI_NO_EXTENT flag
    
    [ Upstream commit 07725adc55c0a414c10acb5c8c86cea34b95ddef ]
    
    The following scenarios exist.
    process A:               process B:
    ->f2fs_drop_extent_tree  ->f2fs_update_extent_cache_range
                              ->f2fs_update_extent_tree_range
                               ->write_lock
     ->set_inode_flag
                               ->is_inode_flag_set
                               ->__free_extent_tree // Shouldn't
                                                    // have been
                                                    // cleaned up
                                                    // here
      ->write_lock
    
    In this case, the "FI_NO_EXTENT" flag is set between
    f2fs_update_extent_tree_range and is_inode_flag_set
    by other process. it leads to clearing the whole exten
    tree which should not have happened. And we fix it by
    move the setting it to the range of write_lock.
    
    Fixes:5f281fab9b9a3 ("f2fs: disable extent_cache for fcollapse/finsert inodes")
    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/extent_cache.c b/fs/f2fs/extent_cache.c
index 866e72b29bd5..761fd42c93f2 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -804,9 +804,8 @@ void f2fs_drop_extent_tree(struct inode *inode)
 	if (!f2fs_may_extent_tree(inode))
 		return;
 
-	set_inode_flag(inode, FI_NO_EXTENT);
-
 	write_lock(&et->lock);
+	set_inode_flag(inode, FI_NO_EXTENT);
 	__free_extent_tree(sbi, et);
 	if (et->largest.len) {
 		et->largest.len = 0;



[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