[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1379961.1685738320@warthog.procyon.org.uk>
Date: Fri, 02 Jun 2023 21:38:40 +0100
From: David Howells <dhowells@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: dhowells@...hat.com, Jakub Kicinski <kuba@...nel.org>,
netdev@...r.kernel.org, "David S.
Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>,
David Ahern <dsahern@...nel.org>,
Matthew Wilcox <willy@...radead.org>, Jens Axboe <axboe@...nel.dk>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Chuck Lever <chuck.lever@...cle.com>,
Boris Pismenny <borisp@...dia.com>,
John Fastabend <john.fastabend@...il.com>,
Christoph Hellwig <hch@...radead.org>
Subject: Re: Bug in short splice to socket?
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> So a "splice_eof()" sounds fine to me, and we'd make the semantics be
> the current behavior:
>
> - splice() sets SPLICE_F_MORE if 'len > read_len'
>
> - splice() _clears_ SPLICE_F_MORE if we have hit 'len'
>
> - splice always sets SPLICE_F_MORE if it was passed by the user
>
> BUT with the small new 'splice_eof()' rule that:
>
> - if the user did *not* set SPLICE_F_MORE *and* we didn't hit that
> "use all of len" case that cleared SPLICE_F_MORE, *and* we did a
> "->splice_in()" that returned EOF (ie zero), *then* we will also do
> that ->splice_eof() call.
>
> The above sounds like "stable and possibly useful semantics" to me. It
> would just have to be documented.
>
> Is that what people want?
That's easier to implement, I think. That's basically what I was trying to
achieve by sending a zero-length actor call, but this is a cleaner way of
doing it, particularly if it's added as a socket op next to ->sendmsg().
Otherwise I have to build up the input side to try and tell me in advance
whether it thinks we hit an EOF/hole/whatever condition. The problem is that,
as previously mentioned, it doesn't work for all circumstances - seqfile,
pipes, sockets for instance.
Take the following scenario for example: I could read from a TCP socket,
filling up the pipe-buffer, but not with sufficient data to fulfill the
operation. Say I drain the TCP socket, but it's still open, so might produce
more data. I then call the actor, which passes all the data to sendmsg() with
MSG_SPLICE_PAGES and MSG_MORE and clears the buffer. I then go round again,
but in the meantime, the source socket got shut down with no further data
available and do_splice_to() returns 0.
There's no way to predict this, so having a ->splice_eof() call would handle
this situation.
David
Powered by blists - more mailing lists