Skip to content

Commit

Permalink
io_uring: remove REQ_F_MUST_PUNT
Browse files Browse the repository at this point in the history
ANBZ: torvalds#190

commit 24c7467 upstream.

REQ_F_MUST_PUNT may seem looking good and clear, but it's the same
as not having REQ_F_NOWAIT set. That rather creates more confusion.
Moreover, it doesn't even affect any behaviour (e.g. see the patch
removing it from io_{read,write}).

Kill theg flag and update already outdated comments.

[Joseph]
Fix conflicts with commit "io_uring: don't use retry based buffered
reads for non-async bdev".

Signed-off-by: Pavel Begunkov <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Joseph Qi <[email protected]>
Reviewed-by: Xiaoguang Wang <[email protected]>
Reviewed-by: Hao Xu <[email protected]>
Tested-by: Hao Xu <[email protected]>
  • Loading branch information
isilence authored and josephhz committed Dec 31, 2021
1 parent ec8910e commit 3c8f884
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ enum {
REQ_F_LINK_TIMEOUT_BIT,
REQ_F_TIMEOUT_BIT,
REQ_F_ISREG_BIT,
REQ_F_MUST_PUNT_BIT,
REQ_F_TIMEOUT_NOSEQ_BIT,
REQ_F_COMP_LOCKED_BIT,
REQ_F_NEED_CLEANUP_BIT,
Expand Down Expand Up @@ -616,8 +615,6 @@ enum {
REQ_F_TIMEOUT = BIT(REQ_F_TIMEOUT_BIT),
/* regular file */
REQ_F_ISREG = BIT(REQ_F_ISREG_BIT),
/* must be punted even for NONBLOCK */
REQ_F_MUST_PUNT = BIT(REQ_F_MUST_PUNT_BIT),
/* no timeout sequence */
REQ_F_TIMEOUT_NOSEQ = BIT(REQ_F_TIMEOUT_NOSEQ_BIT),
/* completion under lock */
Expand Down Expand Up @@ -3068,10 +3065,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock)
if (!force_nonblock)
kiocb->ki_flags &= ~IOCB_NOWAIT;

/*
* If the file doesn't support async, mark it as REQ_F_MUST_PUNT so
* we know to async punt it even if it was opened O_NONBLOCK
*/
/* If the file doesn't support async, just async punt */
no_async = force_nonblock && !io_file_supports_async(req->file, READ);
if (no_async)
goto copy_iov;
Expand Down Expand Up @@ -3157,10 +3151,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock)
if (!force_nonblock)
req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;

/*
* If the file doesn't support async, mark it as REQ_F_MUST_PUNT so
* we know to async punt it even if it was opened O_NONBLOCK
*/
/* If the file doesn't support async, just async punt */
if (force_nonblock && !io_file_supports_async(req->file, WRITE))
goto copy_iov;

Expand Down Expand Up @@ -3889,8 +3880,10 @@ static int io_close(struct io_kiocb *req, bool force_nonblock)

/* if the file has a flush method, be safe and punt to async */
if (close->put_file->f_op->flush && force_nonblock) {
/* was never set, but play safe */
req->flags &= ~REQ_F_NOWAIT;
/* avoid grabbing files - we don't need the files */
req->flags |= REQ_F_NO_FILE_TABLE | REQ_F_MUST_PUNT;
req->flags |= REQ_F_NO_FILE_TABLE;
return -EAGAIN;
}

Expand Down Expand Up @@ -4929,7 +4922,7 @@ static bool io_arm_poll_handler(struct io_kiocb *req)

if (!req->file || !file_can_poll(req->file))
return false;
if (req->flags & (REQ_F_MUST_PUNT | REQ_F_POLLED))
if (req->flags & REQ_F_POLLED)
return false;
if (!def->pollin && !def->pollout)
return false;
Expand Down Expand Up @@ -6176,8 +6169,7 @@ static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe)
* We async punt it if the file wasn't marked NOWAIT, or if the file
* doesn't support non-blocking read/write attempts
*/
if (ret == -EAGAIN && (!(req->flags & REQ_F_NOWAIT) ||
(req->flags & REQ_F_MUST_PUNT))) {
if (ret == -EAGAIN && !(req->flags & REQ_F_NOWAIT)) {
if (io_arm_poll_handler(req)) {
if (linked_timeout)
io_queue_linked_timeout(linked_timeout);
Expand Down

0 comments on commit 3c8f884

Please sign in to comment.