Skip to content

Commit

Permalink
BACKPORT: f2fs: fix to check return value of f2fs_do_truncate_blocks()
Browse files Browse the repository at this point in the history
Otherwise, if truncation on cow_inode failed, remained data may
pollute current transaction of atomic write.

Bug: 298879042
Cc: Daeho Jeong <daehojeong@google.com>
Fixes: a46bebd502fe ("f2fs: synchronize atomic write aborts")
Change-Id: I964ef3e57b0f0dbf77ec4cc8f9cbf349c2a01fff
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 5a37d6f4943555ef57fc16016872f713818f0b2a)
Signed-off-by: zhoudan8 <zhoudan8@xiaomi.com>
  • Loading branch information
chaseyu authored and drosen-google committed Oct 17, 2023
1 parent f3f08c6 commit 2dfe664
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,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);
Expand Down

0 comments on commit 2dfe664

Please sign in to comment.