Skip to content

Commit

Permalink
block: cleanup and fix batch completion adding conditions
Browse files Browse the repository at this point in the history
The conditions for whether or not a request is allowed adding to a
completion batch are a bit hard to read, and they also have a few
issues. One is that ioerror may indeed be a random value on passthrough,
and it's being checked unconditionally of whether or not the given
request is a passthrough request or not.

Rewrite the conditions to be separate for easier reading, and only check
ioerror for non-passthrough requests. This fixes an issue with bio
unmapping on passthrough, where it fails getting added to a batch. This
both leads to suboptimal performance, and may trigger a potential
schedule-under-atomic condition for polled passthrough IO.

Fixes: f794f33 ("block: add support for blk_mq_end_request_batch()")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Feb 13, 2025
1 parent 96b531f commit 1f47ed2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,22 @@ static inline bool blk_mq_add_to_batch(struct request *req,
void (*complete)(struct io_comp_batch *))
{
/*
* blk_mq_end_request_batch() can't end request allocated from
* sched tags
* Check various conditions that exclude batch processing:
* 1) No batch container
* 2) Has scheduler data attached
* 3) Not a passthrough request and end_io set
* 4) Not a passthrough request and an ioerror
*/
if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror ||
(req->end_io && !blk_rq_is_passthrough(req)))
if (!iob)
return false;
if (req->rq_flags & RQF_SCHED_TAGS)
return false;
if (!blk_rq_is_passthrough(req)) {
if (req->end_io)
return false;
if (ioerror < 0)
return false;
}

if (!iob->complete)
iob->complete = complete;
Expand Down

0 comments on commit 1f47ed2

Please sign in to comment.