Skip to content

Commit 0769663

Browse files
olgakorn1Trond Myklebust
authored andcommitted
NFSv4.1 fix incorrect return value in copy_file_range
According to the NFSv4.2 spec if the input and output file is the same file, operation should fail with EINVAL. However, linux copy_file_range() system call has no such restrictions. Therefore, in such case let's return EOPNOTSUPP and allow VFS to fallback to doing do_splice_direct(). Also when copy_file_range is called on an NFSv4.0 or 4.1 mount (ie., a server that doesn't support COPY functionality), we also need to return EOPNOTSUPP and fallback to a regular copy. Fixes xfstest generic/075, generic/091, generic/112, generic/263 for all NFSv4.x versions. Signed-off-by: Olga Kornievskaia <kolga@netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent e1ede31 commit 0769663

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

fs/nfs/nfs42proc.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
329329
};
330330
ssize_t err, err2;
331331

332-
if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
333-
return -EOPNOTSUPP;
334-
335332
src_lock = nfs_get_lock_context(nfs_file_open_context(src));
336333
if (IS_ERR(src_lock))
337334
return PTR_ERR(src_lock);

fs/nfs/nfs4file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
133133
struct file *file_out, loff_t pos_out,
134134
size_t count, unsigned int flags)
135135
{
136+
if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY))
137+
return -EOPNOTSUPP;
136138
if (file_inode(file_in) == file_inode(file_out))
137-
return -EINVAL;
139+
return -EOPNOTSUPP;
138140
return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
139141
}
140142

0 commit comments

Comments
 (0)