mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
blk-mq: fix potential oops with polling and blk-mq scheduler
If we have a scheduler attached, blk_mq_tag_to_rq() on the
scheduled tags will return NULL if a request is no longer
in flight. This is different than using the normal tags,
where it will always return the fixed request. Check for
this condition for polling, in case we happen to enter
polling for a completed request.
The request address remains valid, so this check and return
should be perfectly safe.
Fixes: bd166ef183
("blk-mq-sched: add framework for MQ capable IO schedulers")
Tested-by: Stephen Bates <sbates@raithlin.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
parent
be56945c4e
commit
3a07bb1d76
@ -2928,8 +2928,17 @@ bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie)
|
||||
hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)];
|
||||
if (!blk_qc_t_is_internal(cookie))
|
||||
rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie));
|
||||
else
|
||||
else {
|
||||
rq = blk_mq_tag_to_rq(hctx->sched_tags, blk_qc_t_to_tag(cookie));
|
||||
/*
|
||||
* With scheduling, if the request has completed, we'll
|
||||
* get a NULL return here, as we clear the sched tag when
|
||||
* that happens. The request still remains valid, like always,
|
||||
* so we should be safe with just the NULL check.
|
||||
*/
|
||||
if (!rq)
|
||||
return false;
|
||||
}
|
||||
|
||||
return __blk_mq_poll(hctx, rq);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user