NFS: Add COPY nfs operation
[deliverable/linux.git] / fs / nfs / nfs4file.c
index 22c35abbee9d6c88244b220054d2256c30d050ec..014b0e41ace5a8f5b17510fd32d9403faa0c4084 100644 (file)
@@ -26,7 +26,7 @@ static int
 nfs4_file_open(struct inode *inode, struct file *filp)
 {
        struct nfs_open_context *ctx;
-       struct dentry *dentry = filp->f_path.dentry;
+       struct dentry *dentry = file_dentry(filp);
        struct dentry *parent = NULL;
        struct inode *dir;
        unsigned openflags = filp->f_flags;
@@ -57,7 +57,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
        parent = dget_parent(dentry);
        dir = d_inode(parent);
 
-       ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode);
+       ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode);
        err = PTR_ERR(ctx);
        if (IS_ERR(ctx))
                goto out;
@@ -129,6 +129,28 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
 }
 
 #ifdef CONFIG_NFS_V4_2
+static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in,
+                                   struct file *file_out, loff_t pos_out,
+                                   size_t count, unsigned int flags)
+{
+       struct inode *in_inode = file_inode(file_in);
+       struct inode *out_inode = file_inode(file_out);
+       int ret;
+
+       if (in_inode == out_inode)
+               return -EINVAL;
+
+       /* flush any pending writes */
+       ret = nfs_sync_inode(in_inode);
+       if (ret)
+               return ret;
+       ret = nfs_sync_inode(out_inode);
+       if (ret)
+               return ret;
+
+       return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count);
+}
+
 static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence)
 {
        loff_t ret;
@@ -243,6 +265,7 @@ const struct file_operations nfs4_file_operations = {
        .check_flags    = nfs_check_flags,
        .setlease       = simple_nosetlease,
 #ifdef CONFIG_NFS_V4_2
+       .copy_file_range = nfs4_copy_file_range,
        .llseek         = nfs4_file_llseek,
        .fallocate      = nfs42_fallocate,
        .clone_file_range = nfs42_clone_file_range,
This page took 0.026281 seconds and 5 git commands to generate.