|
@@ -972,6 +972,86 @@ out:
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ssize_t cifs_file_copychunk_range(unsigned int xid,
|
|
|
|
+ struct file *src_file, loff_t off,
|
|
|
|
+ struct file *dst_file, loff_t destoff,
|
|
|
|
+ size_t len, unsigned int flags)
|
|
|
|
+{
|
|
|
|
+ struct inode *src_inode = file_inode(src_file);
|
|
|
|
+ struct inode *target_inode = file_inode(dst_file);
|
|
|
|
+ struct cifsFileInfo *smb_file_src;
|
|
|
|
+ struct cifsFileInfo *smb_file_target;
|
|
|
|
+ struct cifs_tcon *src_tcon;
|
|
|
|
+ struct cifs_tcon *target_tcon;
|
|
|
|
+ ssize_t rc;
|
|
|
|
+
|
|
|
|
+ cifs_dbg(FYI, "copychunk range\n");
|
|
|
|
+
|
|
|
|
+ if (src_inode == target_inode) {
|
|
|
|
+ rc = -EINVAL;
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!src_file->private_data || !dst_file->private_data) {
|
|
|
|
+ rc = -EBADF;
|
|
|
|
+ cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rc = -EXDEV;
|
|
|
|
+ smb_file_target = dst_file->private_data;
|
|
|
|
+ smb_file_src = src_file->private_data;
|
|
|
|
+ src_tcon = tlink_tcon(smb_file_src->tlink);
|
|
|
|
+ target_tcon = tlink_tcon(smb_file_target->tlink);
|
|
|
|
+
|
|
|
|
+ if (src_tcon->ses != target_tcon->ses) {
|
|
|
|
+ cifs_dbg(VFS, "source and target of copy not on same server\n");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Note: cifs case is easier than btrfs since server responsible for
|
|
|
|
+ * checks for proper open modes and file type and if it wants
|
|
|
|
+ * server could even support copy of range where source = target
|
|
|
|
+ */
|
|
|
|
+ lock_two_nondirectories(target_inode, src_inode);
|
|
|
|
+
|
|
|
|
+ cifs_dbg(FYI, "about to flush pages\n");
|
|
|
|
+ /* should we flush first and last page first */
|
|
|
|
+ truncate_inode_pages(&target_inode->i_data, 0);
|
|
|
|
+
|
|
|
|
+ if (target_tcon->ses->server->ops->copychunk_range)
|
|
|
|
+ rc = target_tcon->ses->server->ops->copychunk_range(xid,
|
|
|
|
+ smb_file_src, smb_file_target, off, len, destoff);
|
|
|
|
+ else
|
|
|
|
+ rc = -EOPNOTSUPP;
|
|
|
|
+
|
|
|
|
+ /* force revalidate of size and timestamps of target file now
|
|
|
|
+ * that target is updated on the server
|
|
|
|
+ */
|
|
|
|
+ CIFS_I(target_inode)->time = 0;
|
|
|
|
+ /* although unlocking in the reverse order from locking is not
|
|
|
|
+ * strictly necessary here it is a little cleaner to be consistent
|
|
|
|
+ */
|
|
|
|
+ unlock_two_nondirectories(src_inode, target_inode);
|
|
|
|
+
|
|
|
|
+out:
|
|
|
|
+ return rc;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
|
|
|
|
+ struct file *dst_file, loff_t destoff,
|
|
|
|
+ size_t len, unsigned int flags)
|
|
|
|
+{
|
|
|
|
+ unsigned int xid = get_xid();
|
|
|
|
+ ssize_t rc;
|
|
|
|
+
|
|
|
|
+ rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
|
|
|
|
+ len, flags);
|
|
|
|
+ free_xid(xid);
|
|
|
|
+ return rc;
|
|
|
|
+}
|
|
|
|
+
|
|
const struct file_operations cifs_file_ops = {
|
|
const struct file_operations cifs_file_ops = {
|
|
.read_iter = cifs_loose_read_iter,
|
|
.read_iter = cifs_loose_read_iter,
|
|
.write_iter = cifs_file_write_iter,
|
|
.write_iter = cifs_file_write_iter,
|
|
@@ -984,6 +1064,7 @@ const struct file_operations cifs_file_ops = {
|
|
.splice_read = generic_file_splice_read,
|
|
.splice_read = generic_file_splice_read,
|
|
.llseek = cifs_llseek,
|
|
.llseek = cifs_llseek,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.setlease = cifs_setlease,
|
|
.setlease = cifs_setlease,
|
|
.fallocate = cifs_fallocate,
|
|
.fallocate = cifs_fallocate,
|
|
@@ -1001,6 +1082,7 @@ const struct file_operations cifs_file_strict_ops = {
|
|
.splice_read = generic_file_splice_read,
|
|
.splice_read = generic_file_splice_read,
|
|
.llseek = cifs_llseek,
|
|
.llseek = cifs_llseek,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.setlease = cifs_setlease,
|
|
.setlease = cifs_setlease,
|
|
.fallocate = cifs_fallocate,
|
|
.fallocate = cifs_fallocate,
|
|
@@ -1018,6 +1100,7 @@ const struct file_operations cifs_file_direct_ops = {
|
|
.mmap = cifs_file_mmap,
|
|
.mmap = cifs_file_mmap,
|
|
.splice_read = generic_file_splice_read,
|
|
.splice_read = generic_file_splice_read,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.llseek = cifs_llseek,
|
|
.llseek = cifs_llseek,
|
|
.setlease = cifs_setlease,
|
|
.setlease = cifs_setlease,
|
|
@@ -1035,6 +1118,7 @@ const struct file_operations cifs_file_nobrl_ops = {
|
|
.splice_read = generic_file_splice_read,
|
|
.splice_read = generic_file_splice_read,
|
|
.llseek = cifs_llseek,
|
|
.llseek = cifs_llseek,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.setlease = cifs_setlease,
|
|
.setlease = cifs_setlease,
|
|
.fallocate = cifs_fallocate,
|
|
.fallocate = cifs_fallocate,
|
|
@@ -1051,6 +1135,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = {
|
|
.splice_read = generic_file_splice_read,
|
|
.splice_read = generic_file_splice_read,
|
|
.llseek = cifs_llseek,
|
|
.llseek = cifs_llseek,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.setlease = cifs_setlease,
|
|
.setlease = cifs_setlease,
|
|
.fallocate = cifs_fallocate,
|
|
.fallocate = cifs_fallocate,
|
|
@@ -1067,6 +1152,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
|
|
.mmap = cifs_file_mmap,
|
|
.mmap = cifs_file_mmap,
|
|
.splice_read = generic_file_splice_read,
|
|
.splice_read = generic_file_splice_read,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.llseek = cifs_llseek,
|
|
.llseek = cifs_llseek,
|
|
.setlease = cifs_setlease,
|
|
.setlease = cifs_setlease,
|
|
@@ -1078,6 +1164,7 @@ const struct file_operations cifs_dir_ops = {
|
|
.release = cifs_closedir,
|
|
.release = cifs_closedir,
|
|
.read = generic_read_dir,
|
|
.read = generic_read_dir,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
.unlocked_ioctl = cifs_ioctl,
|
|
|
|
+ .copy_file_range = cifs_copy_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.clone_file_range = cifs_clone_file_range,
|
|
.llseek = generic_file_llseek,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
};
|