From: "Stefan Bühler" <source@stbuehler.de>
To: Jens Axboe <axboe@kernel.dk>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 3/5] pipe: use IOCB_NOWAIT instead of O_NONBLOCK
Date: Sat, 11 May 2019 18:57:25 +0200 [thread overview]
Message-ID: <20190511165727.31599-3-source@stbuehler.de> (raw)
In-Reply-To: <20190511165727.31599-1-source@stbuehler.de>
Fix pipe read_iter/write_iter implementations to handle IOCB_NOWAIT; for
simple reads IOCB_NOWAIT will be set if O_NONBLOCK was set.
Signed-off-by: Stefan Bühler <source@stbuehler.de>
---
fs/pipe.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/fs/pipe.c b/fs/pipe.c
index 41065901106b..a122331cf30f 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -335,13 +335,13 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
break;
if (!pipe->waiting_writers) {
/* syscall merging: Usually we must not sleep
- * if O_NONBLOCK is set, or if we got some data.
+ * if IOCB_NOWAIT is set, or if we got some data.
* But if a writer sleeps in kernel space, then
* we can wait for that data without violating POSIX.
*/
if (ret)
break;
- if (filp->f_flags & O_NONBLOCK) {
+ if (iocb->ki_flags & IOCB_NOWAIT) {
ret = -EAGAIN;
break;
}
@@ -446,7 +446,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
pipe->tmp_page = page;
}
/* Always wake up, even if the copy fails. Otherwise
- * we lock up (O_NONBLOCK-)readers that sleep due to
+ * we lock up (IOCB_NOWAIT-)readers that sleep due to
* syscall merging.
* FIXME! Is this really true?
*/
@@ -477,7 +477,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
}
if (bufs < pipe->buffers)
continue;
- if (filp->f_flags & O_NONBLOCK) {
+ if (iocb->ki_flags & IOCB_NOWAIT) {
if (!ret)
ret = -EAGAIN;
break;
@@ -780,6 +780,7 @@ int create_pipe_files(struct file **res, int flags)
iput(inode);
return PTR_ERR(f);
}
+ f->f_mode |= FMODE_NOWAIT;
f->private_data = inode->i_pipe;
@@ -791,6 +792,7 @@ int create_pipe_files(struct file **res, int flags)
return PTR_ERR(res[0]);
}
res[0]->private_data = inode->i_pipe;
+ res[0]->f_mode |= FMODE_NOWAIT;
res[1] = f;
return 0;
}
@@ -996,6 +998,8 @@ static int fifo_open(struct inode *inode, struct file *filp)
goto err;
}
+ filp->f_mode |= FMODE_NOWAIT;
+
/* Ok! */
__pipe_unlock(pipe);
return 0;
--
2.20.1
next prev parent reply other threads:[~2019-05-11 16:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-23 19:06 io_uring: not good enough for release Stefan Bühler
2019-04-23 20:31 ` Jens Axboe
2019-04-23 22:07 ` Jens Axboe
2019-04-24 16:09 ` Jens Axboe
2019-04-27 16:05 ` io_uring: RWF_NOWAIT support Stefan Bühler
2019-04-27 18:34 ` [PATCH v1 1/1] [io_uring] fix handling SQEs requesting NOWAIT Stefan Bühler
2019-04-30 15:40 ` Jens Axboe
2019-04-27 15:50 ` io_uring: submission error handling Stefan Bühler
2019-04-30 16:02 ` Jens Axboe
2019-04-30 16:15 ` Jens Axboe
2019-04-30 18:15 ` Stefan Bühler
2019-04-30 18:42 ` Jens Axboe
2019-05-01 11:49 ` [PATCH v1 1/1] [io_uring] don't stall on submission errors Stefan Bühler
2019-05-01 12:43 ` Jens Axboe
2019-04-27 21:07 ` io_uring: closing / release Stefan Bühler
2019-05-11 16:26 ` Stefan Bühler
2019-04-28 15:54 ` io_uring: O_NONBLOCK/IOCB_NOWAIT/RWF_NOWAIT mess Stefan Bühler
2019-05-11 16:34 ` Stefan Bühler
2019-05-11 16:57 ` [PATCH 1/5] fs: RWF flags override default IOCB flags from file flags Stefan Bühler
2019-05-11 16:57 ` [PATCH 2/5] tcp: handle SPLICE_F_NONBLOCK in tcp_splice_read Stefan Bühler
2019-05-11 16:57 ` Stefan Bühler [this message]
2019-05-11 16:57 ` [PATCH 4/5] socket: use IOCB_NOWAIT instead of O_NONBLOCK Stefan Bühler
2019-05-11 16:57 ` [PATCH 5/5] io_uring: use FMODE_NOWAIT to detect files supporting IOCB_NOWAIT Stefan Bühler
2019-05-03 9:47 ` [PATCH 1/2] io_uring: restructure io_{read,write} control flow Stefan Bühler
2019-05-03 9:47 ` [PATCH 2/2] io_uring: punt to workers if file doesn't support async Stefan Bühler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190511165727.31599-3-source@stbuehler.de \
--to=source@stbuehler.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).