]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/nfsv4.1-fix-incorrect-return-value-in-copy_file_rang.patch
Linux 4.19.42
[thirdparty/kernel/stable-queue.git] / queue-5.0 / nfsv4.1-fix-incorrect-return-value-in-copy_file_rang.patch
1 From 3801581bf8a91b1f7a606caa717c089545dabf89 Mon Sep 17 00:00:00 2001
2 From: Olga Kornievskaia <kolga@netapp.com>
3 Date: Thu, 11 Apr 2019 14:34:18 -0400
4 Subject: NFSv4.1 fix incorrect return value in copy_file_range
5
6 [ Upstream commit 0769663b4f580566ef6cdf366f3073dbe8022c39 ]
7
8 According to the NFSv4.2 spec if the input and output file is the
9 same file, operation should fail with EINVAL. However, linux
10 copy_file_range() system call has no such restrictions. Therefore,
11 in such case let's return EOPNOTSUPP and allow VFS to fallback
12 to doing do_splice_direct(). Also when copy_file_range is called
13 on an NFSv4.0 or 4.1 mount (ie., a server that doesn't support
14 COPY functionality), we also need to return EOPNOTSUPP and
15 fallback to a regular copy.
16
17 Fixes xfstest generic/075, generic/091, generic/112, generic/263
18 for all NFSv4.x versions.
19
20 Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
21 Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
23 ---
24 fs/nfs/nfs42proc.c | 3 ---
25 fs/nfs/nfs4file.c | 4 +++-
26 2 files changed, 3 insertions(+), 4 deletions(-)
27
28 diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
29 index fed06fd9998d3..94f98e190e632 100644
30 --- a/fs/nfs/nfs42proc.c
31 +++ b/fs/nfs/nfs42proc.c
32 @@ -329,9 +329,6 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
33 };
34 ssize_t err, err2;
35
36 - if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
37 - return -EOPNOTSUPP;
38 -
39 src_lock = nfs_get_lock_context(nfs_file_open_context(src));
40 if (IS_ERR(src_lock))
41 return PTR_ERR(src_lock);
42 diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
43 index 45b2322e092d2..00d17198ee12a 100644
44 --- a/fs/nfs/nfs4file.c
45 +++ b/fs/nfs/nfs4file.c
46 @@ -133,8 +133,10 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
47 struct file *file_out, loff_t pos_out,
48 size_t count, unsigned int flags)
49 {
50 + if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY))
51 + return -EOPNOTSUPP;
52 if (file_inode(file_in) == file_inode(file_out))
53 - return -EINVAL;
54 + return -EOPNOTSUPP;
55 return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
56 }
57
58 --
59 2.20.1
60