From patchwork Wed Mar 15 16:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13176339 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 D7A69C61DA4 for ; Wed, 15 Mar 2023 16:36:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9CF46B0082; Wed, 15 Mar 2023 12:36:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E248E6B0083; Wed, 15 Mar 2023 12:36:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C77586B0085; Wed, 15 Mar 2023 12:36:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B9E976B0082 for ; Wed, 15 Mar 2023 12:36:21 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7537412085C for ; Wed, 15 Mar 2023 16:36:21 +0000 (UTC) X-FDA: 80571685362.03.8EF7646 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id C924514001C for ; Wed, 15 Mar 2023 16:36:19 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nb0sQdrt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678898179; 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=fQdGiCXKHqwcBoJFGafCICryhHB4xNZzThYVAM/NX9wqgb6FBmIWslVGD59nfIFpvVf35D TqBZhvxL9paOQpgQXO9RvGyWGZ6x7hNpj0hGFJBHmN4kHUWGFch95F6gptoEGBpGYkQ+Fk a2mWApH94vKMXUod1uSqnY0IBSV5N8I= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nb0sQdrt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678898179; a=rsa-sha256; cv=none; b=B+62PqnpnVPUw/liTLWJ08FVA6cw/v2mX5O83SJSSdug90nglQ6h5fT9HQAN5J+waOlB7a 89MMdi146h10u8Ua2iRkoMP3hKewOvRkpbmvvWiMZPZPsGvoxw3L6dQ0r2fnnr6eeZRUD1 +xY7o7yTmxJFfdIegcqt/AQUw3G1y0U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678898179; 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=Nb0sQdrtf2dD1zktfWNU3RbDJbtdQ+tUVZoLJCNifPR0WNex4bOo30pzFSjnyT053t6ZMx uPA65/gqaPAflu4Msjmg4e9fIzcsT3+5kUoGRxF3sUrH2hy75l+cUJ6fXwN1nO75byY/+/ 7+6PTOG/FTj0CTUU/mTGim+2Go4efgQ= 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-84-WUgqb5XdM1OrTaCbnHUsDQ-1; Wed, 15 Mar 2023 12:36:15 -0400 X-MC-Unique: WUgqb5XdM1OrTaCbnHUsDQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3540185A78F; Wed, 15 Mar 2023 16:36:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 639B01121314; Wed, 15 Mar 2023 16:36:12 +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 v19 07/15] splice: Do splice read from a file without using ITER_PIPE Date: Wed, 15 Mar 2023 16:35:41 +0000 Message-Id: <20230315163549.295454-8-dhowells@redhat.com> In-Reply-To: <20230315163549.295454-1-dhowells@redhat.com> References: <20230315163549.295454-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C924514001C X-Stat-Signature: tuihox71m3ziftw5t7yedzgh55puyxwx X-HE-Tag: 1678898179-483745 X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vwQXKuTZFNmq5WV8qhbpPiq5OGwyer2bmwuOzcmw5er4W3jmi/kIIeIpKDe4pzGjy1TcRxH3uwk6eGYEKsExaylXMaid/dkPsbeNQqQkfDca8g1hvL4yo2dbWDt5xX813HMZjIr8MfM/nxvOWBNZbfKNnU+wvAVDfX0dbW6XIweyMgSfZ1RAxOwssmxPpEwiHtbST96/YkP1i/JGiGSc98FcEtsSjR4c6BYEldctxW/80neSB4xj0XTYXRmBBXzO3Ggz6PMHz8FpIB9uUQTKYqURn1tQmCnavaNxrkBsGfuqLB4brBw+LoUWvsY+r0ZvuC2UeT8Fz/YWaQYkguIQwo9/n8vSAb2pN8k2OmB6+FXXEYYoiNgeEJvfJLMLj2qhOG9JGD2zdr2sYqQf+hkNZRUVh7jHB2ugFX+lsffIec/RBL3nLfx9B9NUQCnhvpCemkBw== 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 Reviewed-by: Christian Brauner --- 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);