Skip to content

Commit afed627

Browse files
committed
pipe: set FMODE_NOWAIT on pipes
Pipes themselves do not hold the the pipe lock across IO, and hence are safe for RWF_NOWAIT/IOCB_NOWAIT usage. The "contract" for NOWAIT is really "should not do IO under this lock", not strictly that we cannot block or that the below code is in any way atomic. Pipes fulfil that criteria. Acked-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0f99fc5 commit afed627

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/pipe.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,9 @@ static int __do_pipe_flags(int *fd, struct file **files, int flags)
976976
audit_fd_pair(fdr, fdw);
977977
fd[0] = fdr;
978978
fd[1] = fdw;
979+
/* pipe groks IOCB_NOWAIT */
980+
files[0]->f_mode |= FMODE_NOWAIT;
981+
files[1]->f_mode |= FMODE_NOWAIT;
979982
return 0;
980983

981984
err_fdr:

0 commit comments

Comments
 (0)