From patchwork Fri Aug 7 20:38:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 6972991 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 094DB9F457 for ; Fri, 7 Aug 2015 20:38:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 363B020437 for ; Fri, 7 Aug 2015 20:38:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F171205E4 for ; Fri, 7 Aug 2015 20:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946227AbbHGUie (ORCPT ); Fri, 7 Aug 2015 16:38:34 -0400 Received: from mx143.netapp.com ([216.240.21.24]:35114 "EHLO mx143.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035AbbHGUic (ORCPT ); Fri, 7 Aug 2015 16:38:32 -0400 X-IronPort-AV: E=Sophos;i="5.15,630,1432623600"; d="scan'208";a="59648534" Received: from vmwexchts01-prd.hq.netapp.com ([10.122.105.12]) by mx143-out.netapp.com with ESMTP; 07 Aug 2015 13:38:32 -0700 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) with Microsoft SMTP Server id 15.0.1076.9; Fri, 7 Aug 2015 13:38:31 -0700 Received: from davros.com ([10.63.230.123]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id t77KcP1O011473; Fri, 7 Aug 2015 13:38:30 -0700 (PDT) From: Anna Schumaker To: , , CC: Subject: [PATCH 4/7] VFS: Fall back on splice if no copy function defined Date: Fri, 7 Aug 2015 16:38:20 -0400 Message-ID: <1438979904-8775-5-git-send-email-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438979904-8775-1-git-send-email-Anna.Schumaker@Netapp.com> References: <1438979904-8775-1-git-send-email-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The NFS server will need a fallback for filesystems that don't have any kind of copy acceleration yet. Let's handle this by having vfs_copy_range() fall back to splice, enabling an in-kernel fallback for all filesystems. Signed-off-by: Anna Schumaker --- fs/read_write.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 3804547..e564a6b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1358,7 +1358,7 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (!(file_in->f_mode & FMODE_READ) || !(file_out->f_mode & FMODE_WRITE) || (file_out->f_flags & O_APPEND) || - !file_in->f_op || !file_in->f_op->copy_file_range) + !file_in->f_op) return -EINVAL; inode_in = file_inode(file_in); @@ -1382,8 +1382,12 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (ret) return ret; - ret = file_in->f_op->copy_file_range(file_in, pos_in, file_out, pos_out, - len, flags); + ret = -ENOTSUPP; + if (file_in->f_op->copy_file_range) + ret = file_in->f_op->copy_file_range(file_in, pos_in, file_out, + pos_out, len, flags); + if (ret == -ENOTSUPP) + ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, len, flags); if (ret > 0) { fsnotify_access(file_in); add_rchar(current, ret);