diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-05-09 09:12:24 -0600 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2023-05-12 17:17:27 +0200 |
commit | c04fe8e32f907ea668f3f802387c1148fdb0e6c9 (patch) | |
tree | f59e8af5e48f2b1291b3d537c1bdb6b71e549abf /fs | |
parent | ac9a78681b921877518763ba0e89202254349d1b (diff) | |
download | lwn-c04fe8e32f907ea668f3f802387c1148fdb0e6c9.tar.gz lwn-c04fe8e32f907ea668f3f802387c1148fdb0e6c9.zip |
pipe: check for IOCB_NOWAIT alongside O_NONBLOCK
Pipe reads or writes need to enable nonblocking attempts, if either
O_NONBLOCK is set on the file, or IOCB_NOWAIT is set in the iocb being
passed in. The latter isn't currently true, ensure we check for both
before waiting on data or space.
Fixes: afed6271f5b0 ("pipe: set FMODE_NOWAIT on pipes")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Message-Id: <e5946d67-4e5e-b056-ba80-656bab12d9f6@kernel.dk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/pipe.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/pipe.c b/fs/pipe.c index ceb17d2dfa19..2d88f73f585a 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -342,7 +342,8 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) break; if (ret) break; - if (filp->f_flags & O_NONBLOCK) { + if ((filp->f_flags & O_NONBLOCK) || + (iocb->ki_flags & IOCB_NOWAIT)) { ret = -EAGAIN; break; } @@ -547,7 +548,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) continue; /* Wait for buffer space to become available. */ - if (filp->f_flags & O_NONBLOCK) { + if ((filp->f_flags & O_NONBLOCK) || + (iocb->ki_flags & IOCB_NOWAIT)) { if (!ret) ret = -EAGAIN; break; |