This is a note to let you know that I've just added the patch titled f2fs: clear atomic_write_task in f2fs_abort_atomic_write() to the 6.1-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-clear-atomic_write_task-in-f2fs_abort_atomic_wr.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit bb518c9b9ac2b9d02ff071f8ece9be4480bf6714 Author: Chao Yu <chao@xxxxxxxxxx> Date: Mon Jan 9 11:44:50 2023 +0800 f2fs: clear atomic_write_task in f2fs_abort_atomic_write() [ Upstream commit 0e8d040bfa4c476d7d2a23119527c744c7de13cd ] 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: 7a10f0177e11 ("f2fs: don't give partially written atomic data from process crash") 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 60d79e427f988..63c6894099799 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -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; } }