]> git.baikalelectronics.ru Git - kernel.git/commitdiff
f2fs: clear atomic_write_task in f2fs_abort_atomic_write()
authorChao Yu <chao@kernel.org>
Mon, 9 Jan 2023 03:44:50 +0000 (11:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:18 +0000 (13:55 +0100)
[ Upstream commit a2665a1af8c3a29829d6474e674d71710858a4b2 ]

Otherwise, last .atomic_write_task will be remained in structure
f2fs_inode_info, resulting in aborting atomic_write accidentally
in race case. Meanwhile, clear original_i_size as well.

Fixes: 0e0c433c381f ("f2fs: don't give partially written atomic data from process crash")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/segment.c

index 60d79e427f9887df788420d1979ec9df4e4306b3..63c68940997999ecc8b11b6e5279ccce5b0981ae 100644 (file)
@@ -200,9 +200,12 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean)
        clear_inode_flag(inode, FI_ATOMIC_FILE);
        stat_dec_atomic_inode(inode);
 
+       F2FS_I(inode)->atomic_write_task = NULL;
+
        if (clean) {
                truncate_inode_pages_final(inode->i_mapping);
                f2fs_i_size_write(inode, fi->original_i_size);
+               fi->original_i_size = 0;
        }
 }