From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <dhowells@redhat.com>
Cc: <axboe@kernel.dk>, <borisp@nvidia.com>, <chuck.lever@oracle.com>,
<cong.wang@bytedance.com>, <davem@davemloft.net>,
<dsahern@kernel.org>, <edumazet@google.com>,
<john.fastabend@gmail.com>, <kuba@kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>,
<tom@herbertland.com>, <tom@quantonium.net>,
<torvalds@linux-foundation.org>,
<willemdebruijn.kernel@gmail.com>, <willy@infradead.org>,
<kuniyu@amazon.com>
Subject: Re: [PATCH net-next v5 09/14] kcm: Use splice_eof() to flush
Date: Wed, 7 Jun 2023 09:05:28 -0700 [thread overview]
Message-ID: <20230607160528.20078-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20230607140559.2263470-10-dhowells@redhat.com>
From: David Howells <dhowells@redhat.com>
Date: Wed, 7 Jun 2023 15:05:54 +0100
> Allow splice to undo the effects of MSG_MORE after prematurely ending a
> splice/sendfile due to getting an EOF condition (->splice_read() returned
> 0) after splice had called sendmsg() with MSG_MORE set when the user didn't
> set MSG_MORE.
>
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Link: https://lore.kernel.org/r/CAHk-=wh=V579PDYvkpnTobCLGczbgxpMgGmmhqiTyE34Cpi5Gg@mail.gmail.com/
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Tom Herbert <tom@herbertland.com>
> cc: Tom Herbert <tom@quantonium.net>
> cc: Cong Wang <cong.wang@bytedance.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: Eric Dumazet <edumazet@google.com>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Matthew Wilcox <willy@infradead.org>
> cc: netdev@vger.kernel.org
> ---
> net/kcm/kcmsock.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index ba22af16b96d..d0d8c54562d6 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
> @@ -968,6 +968,19 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
> return err;
> }
>
> +static void kcm_splice_eof(struct socket *sock)
> +{
> + struct sock *sk = sock->sk;
> + struct kcm_sock *kcm = kcm_sk(sk);
> +
> + if (skb_queue_empty(&sk->sk_write_queue))
nit: would be better to use skb_queue_empty_lockless().
> + return;
> +
> + lock_sock(sk);
> + kcm_write_msgs(kcm);
> + release_sock(sk);
> +}
> +
> static ssize_t kcm_sendpage(struct socket *sock, struct page *page,
> int offset, size_t size, int flags)
>
> @@ -1773,6 +1786,7 @@ static const struct proto_ops kcm_dgram_ops = {
> .sendmsg = kcm_sendmsg,
> .recvmsg = kcm_recvmsg,
> .mmap = sock_no_mmap,
> + .splice_eof = kcm_splice_eof,
> .sendpage = kcm_sendpage,
> };
>
> @@ -1794,6 +1808,7 @@ static const struct proto_ops kcm_seqpacket_ops = {
> .sendmsg = kcm_sendmsg,
> .recvmsg = kcm_recvmsg,
> .mmap = sock_no_mmap,
> + .splice_eof = kcm_splice_eof,
> .sendpage = kcm_sendpage,
> .splice_read = kcm_splice_read,
> };
next prev parent reply other threads:[~2023-06-07 16:05 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 14:05 [PATCH net-next v5 00/14] splice, net: Rewrite splice-to-socket, fix SPLICE_F_MORE and handle MSG_SPLICE_PAGES in AF_TLS David Howells
2023-06-07 14:05 ` [PATCH net-next v5 01/14] net: Block MSG_SENDPAGE_* from being passed to sendmsg() by userspace David Howells
2023-06-07 14:05 ` [PATCH net-next v5 02/14] tls: Allow MSG_SPLICE_PAGES but treat it as normal sendmsg David Howells
2023-06-07 14:05 ` [PATCH net-next v5 03/14] splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage() David Howells
2023-06-07 16:55 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 04/14] splice, net: Add a splice_eof op to file-ops and socket-ops David Howells
2023-06-07 16:56 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 05/14] tls/sw: Use splice_eof() to flush David Howells
2023-06-07 16:57 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 06/14] tls/device: " David Howells
2023-06-07 16:58 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 07/14] ipv4, ipv6: " David Howells
2023-06-07 15:32 ` Kuniyuki Iwashima
2023-06-07 15:43 ` David Howells
2023-06-07 15:54 ` Kuniyuki Iwashima
2023-06-07 16:01 ` David Howells
2023-06-07 14:05 ` [PATCH net-next v5 08/14] chelsio/chtls: " David Howells
2023-06-07 14:05 ` [PATCH net-next v5 09/14] kcm: " David Howells
2023-06-07 16:05 ` Kuniyuki Iwashima [this message]
2023-06-07 17:10 ` David Howells
2023-06-07 14:05 ` [PATCH net-next v5 10/14] splice, net: Fix SPLICE_F_MORE signalling in splice_direct_to_actor() David Howells
2023-06-07 14:05 ` [PATCH net-next v5 11/14] tls/sw: Support MSG_SPLICE_PAGES David Howells
2023-06-07 17:19 ` Jakub Kicinski
2023-06-07 17:29 ` David Howells
2023-06-07 17:31 ` David Howells
2023-06-07 17:34 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 12/14] tls/sw: Convert tls_sw_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-06-07 17:20 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 13/14] tls/device: Support MSG_SPLICE_PAGES David Howells
2023-06-07 17:25 ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 14/14] tls/device: Convert tls_device_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-06-07 17:26 ` Jakub Kicinski
2023-06-07 17:35 ` David Howells
2023-06-07 17:46 ` Jakub Kicinski
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=20230607160528.20078-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=axboe@kernel.dk \
--cc=borisp@nvidia.com \
--cc=chuck.lever@oracle.com \
--cc=cong.wang@bytedance.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tom@herbertland.com \
--cc=tom@quantonium.net \
--cc=torvalds@linux-foundation.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).