All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: sendfile handles O_NONBLOCK of out_fd
@ 2022-04-15  0:50 Andrei Vagin
  2022-05-02  7:01 ` Andrei Vagin
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Vagin @ 2022-04-15  0:50 UTC (permalink / raw)
  To: linux-kernel, Alexander Viro; +Cc: linux-fsdevel, Andrei Vagin, stable

sendfile has to return EAGAIN if out_fd is nonblocking and the write
into it would block.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: stable@kernel.org
Fixes: b964bf53e540 ("teach sendfile(2) to handle send-to-pipe directly")
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
 fs/read_write.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index e643aec2b0ef..ee59419cbf0f 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1247,6 +1247,9 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
 					  count, fl);
 		file_end_write(out.file);
 	} else {
+		if (out.file->f_flags & O_NONBLOCK)
+			fl |= SPLICE_F_NONBLOCK;
+
 		retval = splice_file_to_pipe(in.file, opipe, &pos, count, fl);
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-08 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15  0:50 [PATCH] fs: sendfile handles O_NONBLOCK of out_fd Andrei Vagin
2022-05-02  7:01 ` Andrei Vagin
2022-05-07 21:52   ` Andrew Morton
2022-05-08 18:28     ` Andrei Vagin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.