copy on write for splice() from file to pipe?

Linus Torvalds torvalds at linux-foundation.org
Fri Feb 10 20:51:21 UTC 2023


On Fri, Feb 10, 2023 at 12:45 PM Stefan Metzmacher <metze at samba.org> wrote:
>
> I guess it would be easy to pass a flag (maybe SPLICE_F_FORCE_COPY)
> down to generic_file_splice_read() and let it create dedicated pages
> and use memcpy() from the page cache to the dedicated pages.

I really think you'd be much better off passing it off to the
*destination*, not the source.

The destination knows whether it needs to copy or not, and in the case
of at least networking, already has the copy option.

The destination might also already know whether it can use the data
synchronously, so that there isn't even any issue with "data may
change later".

In contrast, the source has no clue. It just knows "I'm a page cache
page". It would have to always copy.

               Linus



More information about the samba-technical mailing list