Skip to contentSkip to conversation

fs: Perform splice in copy_file_range if SB are not same

PATCH New Goldwyn Rodrigues 1 participant 1 message Apr 30, 2018 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: Perform splice in copy_file_range if SB are not same

While performing copy_file_range(), if superblocks of file_in and file_out don't match, instead of returning -EXDEV, perform splice for a fast copy.

fs/read_write.c +4 -4
index c4eabbfc90df..e71270033402 100644
@@ -1575,15 +1575,14 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
 	    (file_out->f_flags & O_APPEND))
 		return -EBADF;
 
-	/* this could be relaxed once a method supports cross-fs copies */
-	if (inode_in->i_sb != inode_out->i_sb)
-		return -EXDEV;
-
 	if (len == 0)
 		return 0;
 
 	file_start_write(file_out);
 
+	if (inode_in->i_sb != inode_out->i_sb)
+		goto do_splice;
+
 	/*
 	 * Try cloning first, this is supported by more file systems, and
 	 * more efficient if both clone and copy are supported (e.g. NFS).
@@ -1604,6 +1603,7 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
 			goto done;
 	}
 
+do_splice:
 	ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out,
 			len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0);