pipe: check for IOCB_NOWAIT alongside O_NONBLOCK
PATCH 1/1 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.
---
With the pipe nonblock rework, these two hunsk from one of the other patches was inadvertently dropped. We obviously need to check both, or files without O_NONBLOCK but IOCB_NOWAIT set in the iocb will still block on space/data when writing/reading to/from a pipe.
I can just include this in the io_uring changes as it directly impacts io_uring (breaking a few test cases), or you guys can queue it up on the VFS side. Would be great to get this in -rc2 as it's stalling the regression testing with the vanilla kernels.
fs/pipe.c +2 -2
@@ -342,7 +342,7 @@ 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 +547,7 @@ 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 ;
Signature · 1 line
Jens Axboe
Christian Brauner
maintainerQuoted 6 lines · Jens Axboe
Pipe reads or writes need to enable nonblocking attempts, if either
O_NONBLOCKis set on the file, orIOCB_NOWAITis set in the iocb being passed in. The latter isn't currently true, ensure we check for both before waiting on data or space.
Thanks. I picked this up and pushed a tag.
I'll get this to Linus before -rc2, Jens.
tree: git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
tag: vfs/v6.4-rc1/pipe
[1/1] pipe: check for IOCB_NOWAIT alongside O_NONBLOCK
commit: d326147107eb7152941ab3b04ed4ffba8ce93f64