From: Matthew Wilcox <willy@infradead.org>
To: David Howells <dhowells@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>, Amit Shah <amit@kernel.org>,
linux-fsdevel@vger.kernel.org,
virtualization@lists.linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] splice: Prevent gifting of multipage folios
Date: Mon, 27 Feb 2023 14:45:27 +0000 [thread overview]
Message-ID: <Y/zCB43mmeZ/vSbz@casper.infradead.org> (raw)
In-Reply-To: <2734058.1677507812@warthog.procyon.org.uk>
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.
next prev parent reply other threads:[~2023-02-27 14:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 14:23 David Howells
2023-02-27 14:45 ` Matthew Wilcox [this message]
2023-02-27 15:24 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/zCB43mmeZ/vSbz@casper.infradead.org \
--to=willy@infradead.org \
--cc=amit@kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=miklos@szeredi.hu \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox