From patchwork Mon May 22 13:50:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250611 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 E56FAC7EE29 for ; Mon, 22 May 2023 13:52:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89C4B90000B; Mon, 22 May 2023 09:52:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84CC5900009; Mon, 22 May 2023 09:52:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EE3290000B; Mon, 22 May 2023 09:52:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 61991900009 for ; Mon, 22 May 2023 09:52:33 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0D930ADADC for ; Mon, 22 May 2023 13:52:33 +0000 (UTC) X-FDA: 80818030986.03.CE7AC8B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 2B8C2A000C for ; Mon, 22 May 2023 13:52:30 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IjfrVPTw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1684763551; 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=1dW3gfal+wiqS1BsUQ7v1POUMzsncK8bE2BxQUdT+Fw=; b=JUbD+ky+4h6WEe1KJgRrEiU6x7slRuRbt3nATM1Ycj6qVhmX5Bdb8cFO4fn+yMI4M4p+lg rjxPdDp2HLL5Gs8Lz3+awWVHE96X3SP1sVPgwesWFt3wPK/nj4uoHeEp040szt3Mk6yphC cQ5wpoFWUigIf9MCHILupP3K0kEgNCo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IjfrVPTw; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763551; a=rsa-sha256; cv=none; b=BMraiHWtA/87ohvtm5x2DFldFmAp/HP+Tqe7Vy061Ws70lckIsTbot2uvaRKPqqWGAxp4T 0EwxXwjlR4Au8KokkC6maoBXQlaI+OZAGrFm/6Z7Nbn4jrMcJKixPTv5oeUwlqtHmmNEDr 8YRDA4YaSRD1rHBm5Ddn+HaNduyd0s8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763550; 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=1dW3gfal+wiqS1BsUQ7v1POUMzsncK8bE2BxQUdT+Fw=; b=IjfrVPTwWf9h0pgVUifVFOusgyffmgP/cWgV5TQb2Dnc6KfG/uVV+8wXWpgYcwHfvWV4pD pJK3A7XP+38LijFZM5n10wj4H/MviMMona2ot7meW9pbXf3OMF3oIVaFY/H9UBkXs6Kmki CE8glafi5mZ16O8Nm0vBADOwrgBkNmY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-O78IS1gQNUW2bLyo8CEsOA-1; Mon, 22 May 2023 09:52:26 -0400 X-MC-Unique: O78IS1gQNUW2bLyo8CEsOA-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 213773C025AD; Mon, 22 May 2023 13:52:25 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AEE4140E95D; Mon, 22 May 2023 13:52:22 +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 , linux-cifs@vger.kernel.org Subject: [PATCH v22 31/31] splice: kdoc for filemap_splice_read() and copy_splice_read() Date: Mon, 22 May 2023 14:50:18 +0100 Message-Id: <20230522135018.2742245-32-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 2B8C2A000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7ftpauux6bqktwbjwewtpixymr5h3dth X-HE-Tag: 1684763550-80074 X-HE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TFrSEdaM/n0e/bPoGcNZ9TqYIjOeA9UbKvQfHHSlq6sN11K1pJUXwb/j/K4GZa/fuz2sdYSpD1aIi+9GBiGTGCGemBIrLWAkJhgM4FfiqqbuaUwFxiDStzT5w/OO0T0ViOQAdVUHfgl+/57/AgOR296SQdklDOT4OwAdL/HxME0rI3DVB8ix2/FzP/tFe1MAm5I5ZN0e7gBZ0hhDHb6XV6K3Uc24vWLzSOJF/pJ865/TX8RfKYvyonuoMg1CzdeAtmsl0hs5fvb9+xSx+klgJzxJAPorJJ2L0y+kjfeBpmgnqIBAx/I78sldTLqOvlp/tZM= 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: Provide kerneldoc comments for filemap_splice_read() and copy_splice_read(). Signed-off-by: David Howells cc: Christian Brauner cc: Christoph Hellwig cc: Jens Axboe cc: Steve French cc: Al Viro cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/splice.c | 21 +++++++++++++++++++-- mm/filemap.c | 21 ++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 9be4cb3b9879..2420ead610a7 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -299,8 +299,25 @@ void splice_shrink_spd(struct splice_pipe_desc *spd) kfree(spd->partial); } -/* - * Copy data from a file into pages and then splice those into the output pipe. +/** + * copy_splice_read - Copy data from a file and splice the copy into a pipe + * @in: The file to read from + * @ppos: Pointer to the file position to read from + * @pipe: The pipe to splice into + * @len: The amount to splice + * @flags: The SPLICE_F_* flags + * + * This function allocates a bunch of pages sufficient to hold the requested + * amount of data (but limited by the remaining pipe capacity), passes it to + * the file's ->read_iter() to read into and then splices the used pages into + * the pipe. + * + * Return: On success, the number of bytes read will be returned and *@ppos + * will be updated if appropriate; 0 will be returned if there is no more data + * to be read; -EAGAIN will be returned if the pipe had no space, and some + * other negative error code will be returned on error. A short read may occur + * if the pipe has insufficient space, we reach the end of the data or we hit a + * hole. */ ssize_t copy_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, diff --git a/mm/filemap.c b/mm/filemap.c index 603b562d69b1..f87e2ad8cff1 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2871,9 +2871,24 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe, return spliced; } -/* - * Splice folios from the pagecache of a buffered (ie. non-O_DIRECT) file into - * a pipe. +/** + * filemap_splice_read - Splice data from a file's pagecache into a pipe + * @in: The file to read from + * @ppos: Pointer to the file position to read from + * @pipe: The pipe to splice into + * @len: The amount to splice + * @flags: The SPLICE_F_* flags + * + * This function gets folios from a file's pagecache and splices them into the + * pipe. Readahead will be called as necessary to fill more folios. This may + * be used for blockdevs also. + * + * Return: On success, the number of bytes read will be returned and *@ppos + * will be updated if appropriate; 0 will be returned if there is no more data + * to be read; -EAGAIN will be returned if the pipe had no space, and some + * other negative error code will be returned on error. A short read may occur + * if the pipe has insufficient space, we reach the end of the data or we hit a + * hole. */ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe,