diff options
author | Amir Goldstein <amir73il@gmail.com> | 2019-06-05 11:04:50 -0400 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-06-09 13:06:20 -0400 |
commit | 5dae222a5ff0c269730393018a5539cc970a4726 (patch) | |
tree | e1e4e1634de00d8fb7668f575d7e25acace6518f /fs/nfs | |
parent | 8c3f406c097b83846c7d18438a905b49d17ae528 (diff) |
vfs: allow copy_file_range to copy across devices
We want to enable cross-filesystem copy_file_range functionality
where possible, so push the "same superblock only" checks down to
the individual filesystem callouts so they can make their own
decisions about cross-superblock copy offload and fallack to
generic_copy_file_range() for cross-superblock copy.
[Amir] We do not call ->remap_file_range() in case the files are not
on the same sb and do not call ->copy_file_range() in case the files
do not belong to the same filesystem driver.
This changes behavior of the copy_file_range(2) syscall, which will
now allow cross filesystem in-kernel copy. CIFS already supports
cross-superblock copy, between two shares to the same server. This
functionality will now be available via the copy_file_range(2) syscall.
Cc: Steve French <stfrench@microsoft.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs4file.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4842f3ab3161..f4157eb1f69d 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c | |||
@@ -133,6 +133,9 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, | |||
133 | struct file *file_out, loff_t pos_out, | 133 | struct file *file_out, loff_t pos_out, |
134 | size_t count, unsigned int flags) | 134 | size_t count, unsigned int flags) |
135 | { | 135 | { |
136 | /* Only offload copy if superblock is the same */ | ||
137 | if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) | ||
138 | return -EXDEV; | ||
136 | if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY)) | 139 | if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY)) |
137 | return -EOPNOTSUPP; | 140 | return -EOPNOTSUPP; |
138 | if (file_inode(file_in) == file_inode(file_out)) | 141 | if (file_inode(file_in) == file_inode(file_out)) |
@@ -148,7 +151,7 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, | |||
148 | 151 | ||
149 | ret = __nfs4_copy_file_range(file_in, pos_in, file_out, pos_out, count, | 152 | ret = __nfs4_copy_file_range(file_in, pos_in, file_out, pos_out, count, |
150 | flags); | 153 | flags); |
151 | if (ret == -EOPNOTSUPP) | 154 | if (ret == -EOPNOTSUPP || ret == -EXDEV) |
152 | ret = generic_copy_file_range(file_in, pos_in, file_out, | 155 | ret = generic_copy_file_range(file_in, pos_in, file_out, |
153 | pos_out, count, flags); | 156 | pos_out, count, flags); |
154 | return ret; | 157 | return ret; |