From: Jens Axboe Date: Wed, 8 Mar 2023 00:56:28 +0000 (-0700) Subject: pipe: set FMODE_NOWAIT on pipes X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=afed6271f5b0d78ca1a3739c1da4aa3629b26bba;p=linux.git 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 Reviewed-by: Christian Brauner Signed-off-by: Jens Axboe --- diff --git a/fs/pipe.c b/fs/pipe.c index 42c7ff41c2dba..ceb17d2dfa195 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -976,6 +976,9 @@ static int __do_pipe_flags(int *fd, struct file **files, int flags) audit_fd_pair(fdr, fdw); fd[0] = fdr; fd[1] = fdw; + /* pipe groks IOCB_NOWAIT */ + files[0]->f_mode |= FMODE_NOWAIT; + files[1]->f_mode |= FMODE_NOWAIT; return 0; err_fdr: