diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-03-07 17:56:28 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-04-25 14:08:59 -0600 |
commit | afed6271f5b0d78ca1a3739c1da4aa3629b26bba (patch) | |
tree | 33691f325a88cedf1241a01e02522ee0f4c1096b /fs/pipe.c | |
parent | 0f99fc513ddd28de155c58547824a9fd63daacea (diff) | |
download | lwn-afed6271f5b0d78ca1a3739c1da4aa3629b26bba.tar.gz lwn-afed6271f5b0d78ca1a3739c1da4aa3629b26bba.zip |
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>
Diffstat (limited to 'fs/pipe.c')
-rw-r--r-- | fs/pipe.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/pipe.c b/fs/pipe.c index 42c7ff41c2db..ceb17d2dfa19 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: |