diff options
author | Chao Yu <chao@kernel.org> | 2023-04-05 17:44:53 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-04-14 02:37:57 +0300 |
commit | b851ee6ba3cc212641e622ebcf92b950c7bafa07 (patch) | |
tree | 2036b11e24ed690e3662d787a3f4519631b961d6 /fs | |
parent | 1ac3d037bee9ac3c4ec4041aafb54c5dffd7e1d0 (diff) | |
download | linux-b851ee6ba3cc212641e622ebcf92b950c7bafa07.tar.xz |
f2fs: fix to check return value of f2fs_do_truncate_blocks()
Otherwise, if truncation on cow_inode failed, remained data may
pollute current transaction of atomic write.
Cc: Daeho Jeong <daehojeong@google.com>
Fixes: a46bebd502fe ("f2fs: synchronize atomic write aborts")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/f2fs/file.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 14e9a20e68df..48a563cc0f34 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2113,7 +2113,11 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) clear_inode_flag(fi->cow_inode, FI_INLINE_DATA); } else { /* Reuse the already created COW inode */ - f2fs_do_truncate_blocks(fi->cow_inode, 0, true); + ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true); + if (ret) { + f2fs_up_write(&fi->i_gc_rwsem[WRITE]); + goto out; + } } f2fs_write_inode(inode, NULL); |