Re: Splicing to/from a tty

From: Al Viro
Date: Mon Jan 18 2021 - 14:52:19 EST


On Mon, Jan 18, 2021 at 11:26:00AM -0800, Linus Torvalds wrote:
> On Mon, Jan 18, 2021 at 12:58 AM Johannes Berg
> <johannes@xxxxxxxxxxxxxxxx> wrote:
> >
> > > I think just wiring up iter_file_splice_write would work. Al?
> >
> > Seems to work for the simple test case that I had, at least:
>
> Mind sending me a signed-off patch for this?
>
> Yeah, I know it's a trivial one-liner, but I much prefer having an
> author with a patch and a sign-off to just doing it personally and
> reaping all that glory for it..

IMO it's a wrong way to handle that. Look: do_sendfile() calls
do_splice_direct(), which calls splice_direct_to_actor(). There
we allocate an internal pipe and go through "feed from source into
that pipe, then shove what's there into destination". Which is
insane for the case when destination (or source, for that matter)
is a pipe itself.

do_splice_direct() does something that do_splice() won't - it
handles non-pipe to non-pipe case. Which is how sendfile(2) is
normally used, of course.

I'll look into that in more details, but IMO bothering with
internal pipe is just plain wrong for those cases.