Skip to content

Commit

Permalink
linux/copy_file_range: properly request a fallback copy on Linux <5.3
Browse files Browse the repository at this point in the history
Before Linux 5.3, the filesystem's copy_file_range handler had to signal
back to the kernel that we can't fulfull the request and it should
fallback to a content copy. This is done by returning -EOPNOTSUPP.

This commit converts the EXDEV return from zfs_clone_range to
EOPNOTSUPP, to force the kernel to fallback for all the valid reasons it
might be unable to clone. Without it the copy_file_range() syscall will
return EXDEV to userspace, breaking its semantics.

Signed-off-by: Rob Norris <[email protected]>
  • Loading branch information
robn committed Aug 1, 2023
1 parent 89e861b commit 88de7b3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions module/os/linux/zfs/zpl_file_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ zpl_copy_file_range(struct file *src_file, loff_t src_off,
if (ret == -EOPNOTSUPP || ret == -EXDEV)
ret = generic_copy_file_range(src_file, src_off, dst_file,
dst_off, len, flags);
#else
/*
* Before Linux 5.3 the filesystem has to return -EOPNOTSUPP to signal
* to the kernel that it should fallback to a content copy.
*/
if (ret == -EXDEV)
ret = -EOPNOTSUPP;
#endif /* HAVE_VFS_GENERIC_COPY_FILE_RANGE */

return (ret);
Expand Down

0 comments on commit 88de7b3

Please sign in to comment.