Skip to content

Commit c268b41

Browse files
author
Ming Lei
committed
block: cleanup and fix batch completion adding conditions
JIRA: https://issues.redhat.com/browse/RHEL-79409 commit 1f47ed2 Author: Jens Axboe <axboe@kernel.dk> Date: Thu Feb 13 08:18:46 2025 -0700 block: cleanup and fix batch completion adding conditions 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/20575f0a-656e-4bb3-9d82-dec6c7e3a35c@kernel.dk Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent 695c865 commit c268b41

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

include/linux/blk-mq.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,12 +892,22 @@ static inline bool blk_mq_add_to_batch(struct request *req,
892892
void (*complete)(struct io_comp_batch *))
893893
{
894894
/*
895-
* blk_mq_end_request_batch() can't end request allocated from
896-
* sched tags
895+
* Check various conditions that exclude batch processing:
896+
* 1) No batch container
897+
* 2) Has scheduler data attached
898+
* 3) Not a passthrough request and end_io set
899+
* 4) Not a passthrough request and an ioerror
897900
*/
898-
if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror ||
899-
(req->end_io && !blk_rq_is_passthrough(req)))
901+
if (!iob)
900902
return false;
903+
if (req->rq_flags & RQF_SCHED_TAGS)
904+
return false;
905+
if (!blk_rq_is_passthrough(req)) {
906+
if (req->end_io)
907+
return false;
908+
if (ioerror < 0)
909+
return false;
910+
}
901911

902912
if (!iob->complete)
903913
iob->complete = complete;

0 commit comments

Comments
 (0)