Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
[cascardo/linux.git] / fs / nfsd / vfs.c
index ff476e6..8ca642f 100644 (file)
@@ -513,6 +513,22 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
                        count));
 }
 
+ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst,
+                            u64 dst_pos, u64 count)
+{
+
+       /*
+        * Limit copy to 4MB to prevent indefinitely blocking an nfsd
+        * thread and client rpc slot.  The choice of 4MB is somewhat
+        * arbitrary.  We might instead base this on r/wsize, or make it
+        * tunable, or use a time instead of a byte limit, or implement
+        * asynchronous copy.  In theory a client could also recognize a
+        * limit like this and pipeline multiple COPY requests.
+        */
+       count = min_t(u64, count, 1 << 22);
+       return vfs_copy_file_range(src, src_pos, dst, dst_pos, count, 0);
+}
+
 __be32 nfsd4_vfs_fallocate(struct svc_rqst *rqstp, struct svc_fh *fhp,
                           struct file *file, loff_t offset, loff_t len,
                           int flags)