diff options
author | Fan Li <fanofcode.li@samsung.com> | 2016-09-13 05:35:42 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-09-15 01:52:06 +0200 |
commit | d95fd91c1ac1f551909ccdc4fcc80159521d0ef5 (patch) | |
tree | 5e13c3ab75763209a936a16e1bbf00caba2f7c43 /fs/f2fs | |
parent | f2fs: fix to set PageUptodate in f2fs_write_end correctly (diff) | |
download | linux-d95fd91c1ac1f551909ccdc4fcc80159521d0ef5.tar.xz linux-d95fd91c1ac1f551909ccdc4fcc80159521d0ef5.zip |
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>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/file.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 40fe72e5147c..d400380a8630 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2092,6 +2092,13 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) return -EOPNOTSUPP; + if (src == dst) { + if (pos_in == pos_out) + return 0; + if (pos_out > pos_in && pos_out < pos_in + len) + return -EINVAL; + } + inode_lock(src); if (src != dst) { if (!inode_trylock(dst)) { |