Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: exclude special cases for f2fs_move_file_range

When src and dst is the same file, and the latter part of source region
overlaps with the former part of destination region, current implement
will overwrite data which hasn't been moved yet and truncate data in
overlapped region.
This patch return -EINVAL when such cases occur and return 0 when
source region and destination region is actually the same part of
the same file.

Signed-off-by: Fan li <fanofcode.li@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Fan Li and committed by
Jaegeuk Kim
d95fd91c 649d7df2

+7
+7
fs/f2fs/file.c
··· 2092 2092 if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) 2093 2093 return -EOPNOTSUPP; 2094 2094 2095 + if (src == dst) { 2096 + if (pos_in == pos_out) 2097 + return 0; 2098 + if (pos_out > pos_in && pos_out < pos_in + len) 2099 + return -EINVAL; 2100 + } 2101 + 2095 2102 inode_lock(src); 2096 2103 if (src != dst) { 2097 2104 if (!inode_trylock(dst)) {