From: Andrei Vagin <avagin@gmail.com>
To: linux-kernel@vger.kernel.org, Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, Andrei Vagin <avagin@gmail.com>,
stable@kernel.org
Subject: [PATCH] fs: sendfile handles O_NONBLOCK of out_fd
Date: Thu, 14 Apr 2022 17:50:15 -0700 [thread overview]
Message-ID: <20220415005015.525191-1-avagin@gmail.com> (raw)
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
next reply other threads:[~2022-04-15 0:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 0:50 Andrei Vagin [this message]
2022-05-02 7:01 ` [PATCH] fs: sendfile handles O_NONBLOCK of out_fd Andrei Vagin
2022-05-07 21:52 ` Andrew Morton
2022-05-08 18:28 ` Andrei Vagin
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=20220415005015.525191-1-avagin@gmail.com \
--to=avagin@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 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.