diff mbox series

[f2fs-dev,2/5] f2fs: clear atomic_write_task in f2fs_abort_atomic_write()

Message ID 20230109034453.490176-2-chao@kernel.org (mailing list archive)
State Accepted
Commit 0e8d040bfa4c476d7d2a23119527c744c7de13cd
Headers show
Series [f2fs-dev,1/5] f2fs: introduce trace_f2fs_replace_atomic_write_block | expand

Commit Message

Chao Yu Jan. 9, 2023, 3:44 a.m. UTC
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@kernel.org>
---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index c6f6d0618164..5f7e42b355eb 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -201,9 +201,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;
 	}
 }