Skip to content

Commit

Permalink
blk-mq: change blk_mq_queue_busy() to blk_mq_queue_inflight()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jens Axboe committed Dec 18, 2018
1 parent e5edd5f commit 3c94d83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,14 @@ struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
}
EXPORT_SYMBOL(blk_mq_tag_to_rq);

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

*busy = true;
Expand All @@ -822,14 +822,14 @@ static bool blk_mq_check_busy(struct blk_mq_hw_ctx *hctx, struct request *rq,
return true;
}

bool blk_mq_queue_busy(struct request_queue *q)
bool blk_mq_queue_inflight(struct request_queue *q)
{
bool busy = false;

blk_mq_queue_tag_busy_iter(q, blk_mq_check_busy, &busy);
blk_mq_queue_tag_busy_iter(q, blk_mq_rq_inflight, &busy);
return busy;
}
EXPORT_SYMBOL_GPL(blk_mq_queue_busy);
EXPORT_SYMBOL_GPL(blk_mq_queue_inflight);

static void blk_mq_rq_timed_out(struct request *req, bool reserved)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ static bool md_in_flight_bios(struct mapped_device *md)
static bool md_in_flight(struct mapped_device *md)
{
if (queue_is_mq(md->queue))
return blk_mq_queue_busy(md->queue);
return blk_mq_queue_inflight(md->queue);
else
return md_in_flight_bios(md);
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
void blk_mq_free_request(struct request *rq);
bool blk_mq_can_queue(struct blk_mq_hw_ctx *);

bool blk_mq_queue_busy(struct request_queue *q);
bool blk_mq_queue_inflight(struct request_queue *q);

enum {
/* return when out of requests */
Expand Down

0 comments on commit 3c94d83

Please sign in to comment.