lkml.org 
[lkml]   [2023]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC][PATCH] splice: Prevent gifting of multipage folios
On Mon, Feb 27, 2023 at 02:23:32PM +0000, David Howells wrote:
>
> Don't let parts of multipage folios be gifted by (vm)splice into a pipe as
> the other end may only be expecting single-page gifts (fuse and virtio
> console for example).
>
> replace_page_cache_folio(), for example, will do the wrong thing if it
> tries to replace a single paged folio with a multipage folio.
>
> Try to avoid this by making add_to_pipe() remove the gift flag on multipage
> folios.
>
> Signed-off-by: David Howells <dhowells@redhat.com>

What should the Fixes: here be? This was already possible with THPs
(both anon and tmpfs backed) long before I introduced folios.

> cc: Matthew Wilcox <willy@infradead.org>
> cc: Miklos Szeredi <miklos@szeredi.hu>
> cc: Amit Shah <amit@kernel.org>
> cc: linux-fsdevel@vger.kernel.org
> cc: virtualization@lists.linux-foundation.org
> cc: linux-mm@kvack.org
> ---
> fs/splice.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 2e76dbb81a8f..33caa28a86e4 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -240,6 +240,8 @@ ssize_t add_to_pipe(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
> } else if (pipe_full(head, tail, pipe->max_usage)) {
> ret = -EAGAIN;
> } else {
> + if (folio_nr_pages(page_folio(buf->page)) > 1)
> + buf->flags &= ~PIPE_BUF_FLAG_GIFT;

if (PageCompound(buf->page))
buf->flags &= ~PIPE_BUF_FLAG_GIFT;

would be simpler and more backportable.

\
 
 \ /
  Last update: 2023-03-27 00:37    [W:0.035 / U:1.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site