* [PATCH v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket
@ 2023-07-24 17:39 Jan Stancek
2023-07-26 11:42 ` Xi Ruoyao
2023-07-27 5:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jan Stancek @ 2023-07-24 17:39 UTC (permalink / raw)
To: dhowells, kuba, netdev
Cc: linux-fsdevel, linux-kernel, brauner, viro, jstancek
LTP sendfile07 [1], which expects sendfile() to return EAGAIN when
transferring data from regular file to a "full" O_NONBLOCK socket,
started failing after commit 2dc334f1a63a ("splice, net: Use
sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()").
sendfile() no longer immediately returns, but now blocks.
Removed sock_sendpage() handled this case by setting a MSG_DONTWAIT
flag, fix new splice_to_socket() to do the same for O_NONBLOCK sockets.
[1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/sendfile/sendfile07.c
Fixes: 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()")
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
Changes in v2:
- add David's Acked-by
- add netdev list
fs/splice.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/splice.c b/fs/splice.c
index 004eb1c4ce31..3e2a31e1ce6a 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -876,6 +876,8 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe, struct file *out,
msg.msg_flags |= MSG_MORE;
if (remain && pipe_occupancy(pipe->head, tail) > 0)
msg.msg_flags |= MSG_MORE;
+ if (out->f_flags & O_NONBLOCK)
+ msg.msg_flags |= MSG_DONTWAIT;
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, bvec, bc,
len - remain);
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket
2023-07-24 17:39 [PATCH v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket Jan Stancek
@ 2023-07-26 11:42 ` Xi Ruoyao
2023-07-27 5:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Xi Ruoyao @ 2023-07-26 11:42 UTC (permalink / raw)
To: Jan Stancek, dhowells, kuba, netdev
Cc: linux-fsdevel, linux-kernel, brauner, viro
On Mon, 2023-07-24 at 19:39 +0200, Jan Stancek wrote:
> LTP sendfile07 [1], which expects sendfile() to return EAGAIN when
> transferring data from regular file to a "full" O_NONBLOCK socket,
> started failing after commit 2dc334f1a63a ("splice, net: Use
> sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()").
> sendfile() no longer immediately returns, but now blocks.
>
> Removed sock_sendpage() handled this case by setting a MSG_DONTWAIT
> flag, fix new splice_to_socket() to do the same for O_NONBLOCK sockets.
>
> [1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/sendfile/sendfile07.c
>
> Fixes: 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()")
> Acked-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
This issue caused the "test_asyncio" test in Python 3 test suite to hang
indefinitely. I can confirm this patch fixes the issue.
Tested-by: Xi Ruoyao <xry111@xry111.site>
> ---
> Changes in v2:
> - add David's Acked-by
> - add netdev list
>
> fs/splice.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 004eb1c4ce31..3e2a31e1ce6a 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -876,6 +876,8 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe, struct file *out,
> msg.msg_flags |= MSG_MORE;
> if (remain && pipe_occupancy(pipe->head, tail) > 0)
> msg.msg_flags |= MSG_MORE;
> + if (out->f_flags & O_NONBLOCK)
> + msg.msg_flags |= MSG_DONTWAIT;
>
> iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, bvec, bc,
> len - remain);
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket
2023-07-24 17:39 [PATCH v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket Jan Stancek
2023-07-26 11:42 ` Xi Ruoyao
@ 2023-07-27 5:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-07-27 5:00 UTC (permalink / raw)
To: Jan Stancek
Cc: dhowells, kuba, netdev, linux-fsdevel, linux-kernel, brauner,
viro
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 24 Jul 2023 19:39:04 +0200 you wrote:
> LTP sendfile07 [1], which expects sendfile() to return EAGAIN when
> transferring data from regular file to a "full" O_NONBLOCK socket,
> started failing after commit 2dc334f1a63a ("splice, net: Use
> sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()").
> sendfile() no longer immediately returns, but now blocks.
>
> Removed sock_sendpage() handled this case by setting a MSG_DONTWAIT
> flag, fix new splice_to_socket() to do the same for O_NONBLOCK sockets.
>
> [...]
Here is the summary with links:
- [v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket
https://git.kernel.org/netdev/net/c/0f0fa27b871b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-27 5:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-24 17:39 [PATCH v2] splice, net: Fix splice_to_socket() for O_NONBLOCK socket Jan Stancek
2023-07-26 11:42 ` Xi Ruoyao
2023-07-27 5:00 ` patchwork-bot+netdevbpf
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).