Thread (2 messages) 2 messages, 2 authors, 2015-08-27

Re: [PATCH-RFC-RESEND 1/9] vfs: pull btrfs clone API to vfs layer

From: Peng Tao <hidden>
Date: 2015-08-27 06:23:39
Also in: linux-fsdevel, linux-nfs

On Thu, Aug 27, 2015 at 6:52 AM, Dave Chinner [off-list ref] wrote:
On Wed, Aug 26, 2015 at 04:16:42PM +0800, Peng Tao wrote:
quoted
Now that a few file systems are adding clone functionality, namingly
btrfs, NFS (later in the series) and XFS
(ttp://oss.sgi.com/archives/xfs/2015-06/msg00407.html), it makes sense
to pull the ioctl to common code.

Add vfs_file_clone_range() helper and .clone_range file operation interface
to allow underlying filesystems to clone between regular files.

The change in do_vfs_ioctl() is defered to next patch where btrfs
.clone_range is added, just so that we don't break btrfs CLONE ioctl
with this patch.

Signed-off-by: Peng Tao <redacted>
---
 fs/ioctl.c              | 24 ++++++++++++++++++++++++
 fs/read_write.c         | 45 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fs.h      |  4 ++++
 include/uapi/linux/fs.h |  9 +++++++++
 4 files changed, 82 insertions(+)
.....
quoted
+int vfs_file_clone_range(struct file *src_file, struct file *dst_file,
+                      loff_t off, size_t len, loff_t dstoff)
+{
+     struct inode *src_ino;
+     struct inode *dst_ino;
+     ssize_t ret;
+
+     if (!(src_file->f_mode & FMODE_READ) ||
+         !(dst_file->f_mode & FMODE_WRITE) ||
+         (dst_file->f_flags & O_APPEND) ||
+         !src_file->f_op || !src_file->f_op->clone_range)
+             return -EINVAL;
+
+     src_ino = file_inode(src_file);
+     dst_ino = file_inode(dst_file);
+
+        if (S_ISDIR(src_ino->i_mode) || S_ISDIR(dst_ino->i_mode))
+                return -EISDIR;
Whacky whitespace.

Also, shouldn't this call be restricted to S_ISREG() inodes? This
only checks for directories...
Good point. I'll change it. Thanks!

Cheers,
Tao
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help