Skip to content

Commit 3c94d83

Browse files
committed
blk-mq: change blk_mq_queue_busy() to blk_mq_queue_inflight()
There's a single user of this function, dm, and dm just wants to check if IO is inflight, not that it's just allocated. This fixes a hang with srp/002 in blktests with dm, where it tries to suspend but waits for inflight IO to finish first. As it checks for just allocated requests, this fails. Tested-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e5edd5f commit 3c94d83

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

block/blk-mq.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,14 @@ struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
805805
}
806806
EXPORT_SYMBOL(blk_mq_tag_to_rq);
807807

808-
static bool blk_mq_check_busy(struct blk_mq_hw_ctx *hctx, struct request *rq,
809-
void *priv, bool reserved)
808+
static bool blk_mq_rq_inflight(struct blk_mq_hw_ctx *hctx, struct request *rq,
809+
void *priv, bool reserved)
810810
{
811811
/*
812-
* If we find a request, we know the queue is busy. Return false
813-
* to stop the iteration.
812+
* If we find a request that is inflight and the queue matches,
813+
* we know the queue is busy. Return false to stop the iteration.
814814
*/
815-
if (rq->q == hctx->queue) {
815+
if (rq->state == MQ_RQ_IN_FLIGHT && rq->q == hctx->queue) {
816816
bool *busy = priv;
817817

818818
*busy = true;
@@ -822,14 +822,14 @@ static bool blk_mq_check_busy(struct blk_mq_hw_ctx *hctx, struct request *rq,
822822
return true;
823823
}
824824

825-
bool blk_mq_queue_busy(struct request_queue *q)
825+
bool blk_mq_queue_inflight(struct request_queue *q)
826826
{
827827
bool busy = false;
828828

829-
blk_mq_queue_tag_busy_iter(q, blk_mq_check_busy, &busy);
829+
blk_mq_queue_tag_busy_iter(q, blk_mq_rq_inflight, &busy);
830830
return busy;
831831
}
832-
EXPORT_SYMBOL_GPL(blk_mq_queue_busy);
832+
EXPORT_SYMBOL_GPL(blk_mq_queue_inflight);
833833

834834
static void blk_mq_rq_timed_out(struct request *req, bool reserved)
835835
{

drivers/md/dm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static bool md_in_flight_bios(struct mapped_device *md)
663663
static bool md_in_flight(struct mapped_device *md)
664664
{
665665
if (queue_is_mq(md->queue))
666-
return blk_mq_queue_busy(md->queue);
666+
return blk_mq_queue_inflight(md->queue);
667667
else
668668
return md_in_flight_bios(md);
669669
}

include/linux/blk-mq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
257257
void blk_mq_free_request(struct request *rq);
258258
bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
259259

260-
bool blk_mq_queue_busy(struct request_queue *q);
260+
bool blk_mq_queue_inflight(struct request_queue *q);
261261

262262
enum {
263263
/* return when out of requests */

0 commit comments

Comments
 (0)