Patch "f2fs: fix to check return value of inc_valid_block_count()" has been added to the 6.2-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 to check return value of inc_valid_block_count()

to the 6.2-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-to-check-return-value-of-inc_valid_block_co.patch
and it can be found in the queue-6.2 subdirectory.

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



commit d4afbac79f4dad4e884170a5a9060f013d8bf035
Author: Chao Yu <chao@xxxxxxxxxx>
Date:   Wed Apr 5 22:45:36 2023 +0800

    f2fs: fix to check return value of inc_valid_block_count()
    
    [ Upstream commit 935fc6fa6466cf18dd72dd1518ebc7bfc4cd58a4 ]
    
    In __replace_atomic_write_block(), we missed to check return value
    of inc_valid_block_count(), for extreme testcase that f2fs image is
    run out of space, it may cause inconsistent status in between SIT
    table and total valid block count.
    
    Cc: Daeho Jeong <daehojeong@xxxxxxxxxx>
    Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
    Signed-off-by: Chao Yu <chao@xxxxxxxxxx>
    Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 2822b04082eec..06991cf643296 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -246,10 +246,16 @@ static int __replace_atomic_write_block(struct inode *inode, pgoff_t index,
 	} else {
 		blkcnt_t count = 1;
 
+		err = inc_valid_block_count(sbi, inode, &count);
+		if (err) {
+			f2fs_put_dnode(&dn);
+			return err;
+		}
+
 		*old_addr = dn.data_blkaddr;
 		f2fs_truncate_data_blocks_range(&dn, 1);
 		dec_valid_block_count(sbi, F2FS_I(inode)->cow_inode, count);
-		inc_valid_block_count(sbi, inode, &count);
+
 		f2fs_replace_block(sbi, &dn, dn.data_blkaddr, new_addr,
 					ni.version, true, false);
 	}



[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