All of lore.kernel.org
 help / color / mirror / Atom feed
From: <bjschuma@netapp.com>
To: <Trond.Myklebust@netapp.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [RFC 1/5] Improve on the copyfile systemcall
Date: Fri, 19 Jul 2013 17:03:46 -0400	[thread overview]
Message-ID: <1374267830-30154-2-git-send-email-bjschuma@netapp.com> (raw)
In-Reply-To: <1374267830-30154-1-git-send-email-bjschuma@netapp.com>

From: Bryan Schumaker <bjschuma@netapp.com>

I added in a fallback to do_splice_direct() if the filesystem doesn't
support the copy_range call.  This is because the declaration of
do_splice_direct() is now found in fs/internal.h and can't be used by
other filesystems.

I also had to add sys_copy_range to include/linux/syscalls.h to get my
test program to recognize the new syscall.

Other thoughts:
- Pass count = 0 to mean "copy the entire file"
- rw_verify_area() limits count to values that can fit in an int, so
  files larger than about 2GB cannot be copied.
---
 fs/copy_range.c          | 10 +++++++---
 include/linux/syscalls.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/copy_range.c b/fs/copy_range.c
index 3000b9f..bcf6e67 100644
--- a/fs/copy_range.c
+++ b/fs/copy_range.c
@@ -10,6 +10,8 @@
 #include <linux/export.h>
 #include <linux/fsnotify.h>
 
+#include "internal.h"
+
 /**
  * vfs_copy_range - copy range of bytes from source file to existing file
  * @file_in:   source regular file
@@ -52,7 +54,7 @@ ssize_t vfs_copy_range(struct file *file_in, loff_t pos_in,
 	if (!(file_in->f_mode & FMODE_READ) ||
 	    !(file_out->f_mode & FMODE_WRITE) ||
 	    (file_out->f_flags & O_APPEND) ||
-	    !file_in->f_op || !file_in->f_op->copy_range)
+	    !file_in->f_op)
 		return -EINVAL;
 
 	inode_in = file_inode(file_in);
@@ -82,8 +84,10 @@ ssize_t vfs_copy_range(struct file *file_in, loff_t pos_in,
 	if (ret)
 		return ret;
 
-	ret = file_in->f_op->copy_range(file_in, pos_in, file_out, pos_out,
-					count);
+	if (file_in->f_op->copy_range)
+		ret = file_in->f_op->copy_range(file_in, pos_in, file_out, pos_out, count);
+	else
+		ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, count, 0);
 	if (ret > 0) {
 		fsnotify_access(file_in);
 		add_rchar(current, ret);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 4147d70..5afcd00 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -485,6 +485,7 @@ asmlinkage long sys_sendfile(int out_fd, int in_fd,
 			     off_t __user *offset, size_t count);
 asmlinkage long sys_sendfile64(int out_fd, int in_fd,
 			       loff_t __user *offset, size_t count);
+asmlinkage long sys_copy_range(int, loff_t __user *, int, loff_t __user *, size_t);
 asmlinkage long sys_readlink(const char __user *path,
 				char __user *buf, int bufsiz);
 asmlinkage long sys_creat(const char __user *pathname, umode_t mode);
-- 
1.8.3.3


  reply	other threads:[~2013-07-19 21:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 21:03 [RFC 0/5] NFS Server Side Copy bjschuma
2013-07-19 21:03 ` bjschuma [this message]
2013-07-19 21:03 ` [RFC 2/5] NFSD: Implement the COPY call bjschuma
2013-07-22 18:05   ` J. Bruce Fields
2013-07-22 18:59     ` Bryan Schumaker
2013-07-19 21:03 ` [RFC 3/5] NFS: Add COPY nfs operation bjschuma
2013-07-24 14:21   ` Myklebust, Trond
2013-07-19 21:03 ` [RFC 4/5] NFSD: Defer copying bjschuma
2013-07-22 18:50   ` J. Bruce Fields
2013-07-22 19:17     ` Bryan Schumaker
2013-07-22 19:30       ` J. Bruce Fields
2013-07-22 19:37         ` Bryan Schumaker
2013-07-22 19:43           ` J. Bruce Fields
2013-07-22 19:54             ` Bryan Schumaker
2013-07-22 19:55               ` J. Bruce Fields
2013-08-05  8:38                 ` Ric Wheeler
2013-08-05 14:41                   ` J. Bruce Fields
2013-08-05 14:44                     ` Ric Wheeler
2013-08-05 14:56                       ` J. Bruce Fields
2013-08-05 14:44                     ` Bryan Schumaker
2013-08-05 14:50                     ` Myklebust, Trond
2013-08-05 18:11                       ` J. Bruce Fields
2013-08-05 18:17                         ` Chuck Lever
2013-08-05 18:24                           ` Myklebust, Trond
2013-08-05 18:30                         ` J. Bruce Fields
2013-07-19 21:03 ` [RFC 5/5] NFS: Change copy to support async servers bjschuma
2013-07-24 14:28   ` Myklebust, Trond
2013-07-22 18:53 ` [RFC 0/5] NFS Server Side Copy J. Bruce Fields
2013-07-22 19:38   ` Bryan Schumaker
2013-07-22 19:42     ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374267830-30154-2-git-send-email-bjschuma@netapp.com \
    --to=bjschuma@netapp.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.