Skip to content

Commit b851ee6

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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: a46bebd ("f2fs: synchronize atomic write aborts") Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 1ac3d03 commit b851ee6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/f2fs/file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,11 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
21132113
clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
21142114
} else {
21152115
/* Reuse the already created COW inode */
2116-
f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
2116+
ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
2117+
if (ret) {
2118+
f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2119+
goto out;
2120+
}
21172121
}
21182122

21192123
f2fs_write_inode(inode, NULL);

0 commit comments

Comments
 (0)