splice: Add a func to do a splice from a buffered file without ITER_PIPE
authorDavid Howells <dhowells@redhat.com>
Tue, 14 Feb 2023 15:01:42 +0000 (15:01 +0000)
committerDavid Howells <dhowells@redhat.com>
Tue, 14 Feb 2023 16:00:01 +0000 (16:00 +0000)
commita53cad008099e26d3f47efc8bd26d9c397f676d8
treed4f079e483514d58621c65f7bad188d988a0b7ff
parent78e11ab5adf7050294a5be5a96716a2218fce0a2
splice: Add a func to do a splice from a buffered file without ITER_PIPE

Provide a function to do splice read from a buffered file, pulling the
folios out of the pagecache directly by calling filemap_get_pages() to do
any required reading and then pasting the returned folios into the pipe.

A helper function is provided to do the actual folio pasting and will
handle multipage folios by splicing as many of the relevant subpages as
will fit into the pipe.

The code is loosely based on filemap_read() and might belong in
mm/filemap.c with that as it needs to use filemap_get_pages().

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Christoph Hellwig <hch@lst.de>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: David Hildenbrand <david@redhat.com>
cc: John Hubbard <jhubbard@nvidia.com>
cc: linux-mm@kvack.org
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
include/linux/fs.h
mm/filemap.c
mm/internal.h