Return-Path: Received: from mx2.suse.de ([195.135.220.15]:37439 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753861AbeD3TOu (ORCPT ); Mon, 30 Apr 2018 15:14:50 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 022CFAC20 for ; Mon, 30 Apr 2018 19:14:49 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PATCH] fs: Perform splice in copy_file_range if SB are not same Date: Mon, 30 Apr 2018 14:14:33 -0500 Message-Id: <20180430191433.24942-1-rgoldwyn@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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. Signed-off-by: Goldwyn Rodrigues diff --git a/fs/read_write.c b/fs/read_write.c index c4eabbfc90df..e71270033402 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -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);