From patchwork Tue Mar 14 22:07:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13175050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39353C7618B for ; Tue, 14 Mar 2023 22:08:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C84828E0008; Tue, 14 Mar 2023 18:08:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C348A8E0003; Tue, 14 Mar 2023 18:08:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD5908E0008; Tue, 14 Mar 2023 18:08:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9D89D8E0003 for ; Tue, 14 Mar 2023 18:08:37 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6169B1C5EF1 for ; Tue, 14 Mar 2023 22:08:37 +0000 (UTC) X-FDA: 80568893874.09.4B252CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 8E1B640002 for ; Tue, 14 Mar 2023 22:08:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iAWWcarj; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678831715; a=rsa-sha256; cv=none; b=Az+8R/edc23u9McaYPFDuWUp//4AtP7QBoVcapw+6cCiroiMrVjbFyj5WqawBw3sGhkRzT FnBfIV2u5pIxbQ/b36GnWLRNLhAsEFURSWT8bb8eu6T7uEbxygF2Fmsti0MD0VjLDS4I86 0S9zCc8F8cOj2VyAKPavyjdPGjd2hlk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iAWWcarj; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678831715; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tPHDzTeiqkehQq1hzvPvPGknkMXTxgyXWdFbtANbawg=; b=zUs5GvOuAJgClT7x7fY/o7luIn6OzemHKj4dHTJyIzS1ul2MO9z5Tw6jKIt29EUf1jC7G/ r8zXWw6mn33zsE7Swc0t6kNebN6WfqMRgnJrr4yKiVvb3E1ogUHNz1lLStFrA5pYfWV77d 5CSXpWa74bX5QSVfMbimaP/qaSbuyXE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678831714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tPHDzTeiqkehQq1hzvPvPGknkMXTxgyXWdFbtANbawg=; b=iAWWcarjZGORj1XpTrs7WLkU66Wn02dGKlo5PTlXGVjAdzAsofefD1xWo2OBQtOQC7bBX6 X6Uil+99G8eTLlui2H6BmTKJm1oIki8ZNdChyFbLpLwzJr972u1O6CmmSmbsNdvcEprXtB KtyG0/7t2phJ4M8jObdASNgJy//9M9E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-yinWqeU4PtWbq9L6irR4zQ-1; Tue, 14 Mar 2023 18:08:29 -0400 X-MC-Unique: yinWqeU4PtWbq9L6irR4zQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6700D85A5A3; Tue, 14 Mar 2023 22:08:28 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B9EAC164E7; Tue, 14 Mar 2023 22:08:26 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Steve French , John Hubbard , linux-cifs@vger.kernel.org Subject: [PATCH v18 07/15] splice: Do splice read from a file without using ITER_PIPE Date: Tue, 14 Mar 2023 22:07:49 +0000 Message-Id: <20230314220757.3827941-8-dhowells@redhat.com> In-Reply-To: <20230314220757.3827941-1-dhowells@redhat.com> References: <20230314220757.3827941-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Queue-Id: 8E1B640002 X-Rspamd-Server: rspam01 X-Stat-Signature: 6ackccq6txusxj481wpha45quwmez64c X-HE-Tag: 1678831715-906463 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QQWfhV6cMxCuJRcQdRL25bhua0G0UxuklUysL+ezbjfPwF+pLpoX2HrySQyRJty4NAncD6CZCN6ttuFeeSYnkuqGRVWt8bmdVWjmK4LOUdR0ghPidZRSuCoq1QqNN9YtSwbARBjRUHuRpKLjX3sA8K1KLqw1lDP59sjV0D5CZztwkiBV9UUPgZumuYkEGEP675I82QF7UhwxgEW8Krhw+QfQOzneO9I5cjde49VnBqS2lhm38jDRvHpMmJbkz0miRcFF0h0Oag5rIMc6kLDZ6s/P9UDWviDd/3DX3a4gVcVKffZgAc1jzdQuJdrlDzIhtYMXYpfH3sdTx+YaNoxkM+nR1rz8/LjyWl0TI8eKHEHc2JVw1AOeBKkyrsRZoR74DCFp6XWM1KG3gcXO4ZbBH8Q2wCNIiLb+a73SF/Q7WT6d961a8yvB7GXnlHTQRgPRjrDu23MJg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Make generic_file_splice_read() use filemap_splice_read() and direct_splice_read() rather than using an ITER_PIPE and call_read_iter(). With this, ITER_PIPE is no longer used. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Jens Axboe cc: Steve French cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #18) - Split out the change to cifs to make it use generic_file_splice_read(). - Split out the unexport of filemap_splice_read() (still needed by cifs). fs/splice.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 90ccd3666dca..f46dd1fb367b 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -387,29 +387,13 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags) { - struct iov_iter to; - struct kiocb kiocb; - int ret; - - iov_iter_pipe(&to, ITER_DEST, pipe, len); - init_sync_kiocb(&kiocb, in); - kiocb.ki_pos = *ppos; - ret = call_read_iter(in, &kiocb, &to); - if (ret > 0) { - *ppos = kiocb.ki_pos; - file_accessed(in); - } else if (ret < 0) { - /* free what was emitted */ - pipe_discard_from(pipe, to.start_head); - /* - * callers of ->splice_read() expect -EAGAIN on - * "can't put anything in there", rather than -EFAULT. - */ - if (ret == -EFAULT) - ret = -EAGAIN; - } - - return ret; + if (unlikely(*ppos >= file_inode(in)->i_sb->s_maxbytes)) + return 0; + if (unlikely(!len)) + return 0; + if (in->f_flags & O_DIRECT) + return direct_splice_read(in, ppos, pipe, len, flags); + return filemap_splice_read(in, ppos, pipe, len, flags); } EXPORT_SYMBOL(generic_file_splice_read);