From patchwork Mon Nov 19 21:17:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 10689493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57E7513BB for ; Mon, 19 Nov 2018 21:18:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CEF42A651 for ; Mon, 19 Nov 2018 21:18:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 416742A68A; Mon, 19 Nov 2018 21:18:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC272A651 for ; Mon, 19 Nov 2018 21:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730033AbeKTHnX (ORCPT ); Tue, 20 Nov 2018 02:43:23 -0500 Received: from ipmail03.adl6.internode.on.net ([150.101.137.143]:45937 "EHLO ipmail03.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbeKTHnX (ORCPT ); Tue, 20 Nov 2018 02:43:23 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail03.adl6.internode.on.net with ESMTP; 20 Nov 2018 07:47:46 +1030 Received: from discord.disaster.area ([192.168.1.111]) by dastard with esmtp (Exim 4.80) (envelope-from ) id 1gOqvR-0000ZV-4G; Tue, 20 Nov 2018 08:17:45 +1100 Received: from dave by discord.disaster.area with local (Exim 4.91) (envelope-from ) id 1gOqvR-0002QA-2u; Tue, 20 Nov 2018 08:17:45 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 4/5] splice: increase pipe size in splice_direct_to_actor() Date: Tue, 20 Nov 2018 08:17:41 +1100 Message-Id: <20181119211742.8824-5-david@fromorbit.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119211742.8824-1-david@fromorbit.com> References: <20181119211742.8824-1-david@fromorbit.com> MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Chinner When copy_file_range() is called on files that have been opened with O_DIRECT, do_splice_direct() does a manual copy of the range one pipe buffer at a time. The default is 16 pages, which means on x86_64 it is limited to 64kB IO. This is extremely slow - 64k synchrnous read/write will run at maybe 5-10MB/s on a spinning disk and be seek bound. It will be faster on SSDs, but still very inefficient. Increase the pipe size to the maximum allowed user size so that we can get decent throughput for this highly sub-optimal copy loop. We also don't care if changing the pipe size fails - that will just result in a slower copy. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/pipe.c | 2 +- fs/splice.c | 8 ++++++++ include/linux/pipe_fs_i.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/pipe.c b/fs/pipe.c index bdc5d3c0977d..5885d29cdaa6 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1025,7 +1025,7 @@ unsigned int round_pipe_size(unsigned long size) * Allocate a new array of pipe buffers and copy the info over. Returns the * pipe size if successful, or return -ERROR on error. */ -static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) +long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) { struct pipe_buffer *bufs; unsigned int size, nr_pages; diff --git a/fs/splice.c b/fs/splice.c index 3553f1956508..64dcc622db8d 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "internal.h" @@ -931,6 +932,13 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, current->splice_pipe = pipe; } + /* + * Try to increase the data holding capacity of the pipe so we can do + * larger IOs. This may not increase the size at all because maximum + * user pipe size is administrator controlled, but we still should try. + */ + pipe_set_size(pipe, pipe_max_size); + /* * Do the splice. */ diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index 5a3bb3b7c9ad..e7d728e5b5f8 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -191,5 +191,6 @@ struct pipe_inode_info *get_pipe_info(struct file *file); int create_pipe_files(struct file **, int); unsigned int round_pipe_size(unsigned long size); +long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg); #endif