From patchwork Tue Feb 14 17:13:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13140630 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 61DB1C05027 for ; Tue, 14 Feb 2023 17:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E16E16B0081; Tue, 14 Feb 2023 12:14:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9F9F6B0082; Tue, 14 Feb 2023 12:14:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C408A6B0083; Tue, 14 Feb 2023 12:14:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B17356B0081 for ; Tue, 14 Feb 2023 12:14:14 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 81BC940850 for ; Tue, 14 Feb 2023 17:14:14 +0000 (UTC) X-FDA: 80466545628.14.49F5F29 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 8E8F440019 for ; Tue, 14 Feb 2023 17:14:12 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gfL4Mr+k; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1676394852; 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=J4i4bwQTS34x6oFo2ZgYGZTE2NYetAQq5iydlM1fsxY=; b=P+JfYxAbuvAEJFKZnH3yLRHd4juneWdzrJJqWZWxj2VKjxxSbGqv85t1SmLtHQn05kuW2q mOP9gbmcsoevQ9me150+oLPoaeIKo/KnI7V+lO+bhoXeDTCZUzJXlzltMSd9IoDWGvgy5s SIHzDpJnZ6Gk5QxVN06pQ+dBF6fUrlM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gfL4Mr+k; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1676394852; a=rsa-sha256; cv=none; b=P7JIeAJqecoFUkWHhZrV6lk7s1BgEnWKXsTW0T84D6/T0dMFYRxdJLhbFcYZhMhT33BswC VDWUXhLzQxNy0C6na2wWv048KiIDs5LDM/XKUMHay2gV+Y2dXX+gyC5Dd7eXVnMZMFpFRe co3+EHE3JnAa9Q7jPTqNlytDGW1Xc5Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676394852; 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=J4i4bwQTS34x6oFo2ZgYGZTE2NYetAQq5iydlM1fsxY=; b=gfL4Mr+k99US8+sHixVHCfJC1Oei+7T1Bkw2U+5bPSeJ8rExTbU5XKzSxx29QjhWMtVhR5 fNsaEn1SjAJWxSyULSSfDAyflfU8cphJYslDiyZ+U6kOuyYMTPNHf+uFlOInO59095RuJ7 YMaFuZrwIrAiCKAk1FHceqwU0AH9L6A= 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-52-ZogOeZ8jO0-C97KX6CrYIA-1; Tue, 14 Feb 2023 12:14:10 -0500 X-MC-Unique: ZogOeZ8jO0-C97KX6CrYIA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4219F100F907; Tue, 14 Feb 2023 17:14:08 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4767E1415108; Tue, 14 Feb 2023 17:14:06 +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 , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , John Hubbard Subject: [PATCH v14 08/17] splice: Do splice read from a file without using ITER_PIPE Date: Tue, 14 Feb 2023 17:13:21 +0000 Message-Id: <20230214171330.2722188-9-dhowells@redhat.com> In-Reply-To: <20230214171330.2722188-1-dhowells@redhat.com> References: <20230214171330.2722188-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: qzy186gofgnyip1utcdnsedw97bzob44 X-Rspamd-Queue-Id: 8E8F440019 X-HE-Tag: 1676394852-783761 X-HE-Meta: U2FsdGVkX1/fmTX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RUrMvXAPFQ8yFskXP52rDZed4N1k1yaN1S4laesraarto0Wv4C2BdN4kmBtmtmxhiiUyMp7MyhPJYpdnpP79geYZnqvS1gQHkFu86QZn0vUv/vdlAFxahWmwGkO6iXlh2Pewnz1XDaFWsHcx42iDoWv5XgtcyJsNdR0HP99W0fJpcDhpNuY6HezXLuNkzMrjacCLZffPjZKXEfM5SBbSjGTEOA37d0bI/kL21XFKYMb8kb0+J4Zg5qW2Gka9w9cyhiNZbJDaemo1lYPhGHzzWQNFa5YOZLs1xvIb1AKhH4nnrz93w2d30fjAKbzgJiCpTsWf967SQE0sE8OuGZ0IZJiB4mh/Y36rBwXYAGvyeBqJ3Z6RrlBK89cL1nFeBYWlfCOkSoj+e+yrkTsf2N 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 cc: Jens Axboe cc: Christoph Hellwig cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- Notes: ver #14) - Split out filemap_splice_read() into a separate patch. fs/splice.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 4c6332854b63..a93478338cec 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -391,29 +391,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);