diff options
author | David Howells <dhowells@redhat.com> | 2023-02-14 15:01:42 +0000 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2023-02-20 17:25:43 -0600 |
commit | 07073eb01c5f630344bc1c3e56b0e0d94aedf919 (patch) | |
tree | c7580c7fd9e188c26bcb8b0d618a345036224639 /include/linux/pipe_fs_i.h | |
parent | dd5b9d003ebcb469de05f967af7164e6b9450ca2 (diff) | |
download | linux-07073eb01c5f630344bc1c3e56b0e0d94aedf919.tar.gz linux-07073eb01c5f630344bc1c3e56b0e0d94aedf919.tar.bz2 linux-07073eb01c5f630344bc1c3e56b0e0d94aedf919.zip |
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>
Reviewed-by: 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
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'include/linux/pipe_fs_i.h')
-rw-r--r-- | include/linux/pipe_fs_i.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index 6cb65df3e3ba..d2c3f16cf6b1 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -157,6 +157,26 @@ static inline bool pipe_full(unsigned int head, unsigned int tail, } /** + * pipe_buf - Return the pipe buffer for the specified slot in the pipe ring + * @pipe: The pipe to access + * @slot: The slot of interest + */ +static inline struct pipe_buffer *pipe_buf(const struct pipe_inode_info *pipe, + unsigned int slot) +{ + return &pipe->bufs[slot & (pipe->ring_size - 1)]; +} + +/** + * pipe_head_buf - Return the pipe buffer at the head of the pipe ring + * @pipe: The pipe to access + */ +static inline struct pipe_buffer *pipe_head_buf(const struct pipe_inode_info *pipe) +{ + return pipe_buf(pipe, pipe->head); +} + +/** * pipe_buf_get - get a reference to a pipe_buffer * @pipe: the pipe that the buffer belongs to * @buf: the buffer to get a reference to |