Skip to content

Commit

Permalink
f2fs: fix to check return value of f2fs_do_truncate_blocks()
Browse files Browse the repository at this point in the history
[ Upstream commit b851ee6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chaseyu authored and gregkh committed May 11, 2023
1 parent a8091dc commit 2eb5d01
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/f2fs/file.c
Expand Up @@ -2115,7 +2115,11 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
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 2eb5d01

Please sign in to comment.