diff options
author | Jens Axboe <axboe@kernel.dk> | 2018-11-08 09:03:51 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-11-08 10:24:23 -0700 |
commit | ae8799125d565c798e49dcab4bf182dbfc483524 (patch) | |
tree | 9cf36f53aad46a716d8b7476da384823d82e9e38 /block/blk-mq.c | |
parent | 7baa85727d0406ffd2b2303cd803a145aa35c505 (diff) | |
download | linux-ae8799125d565c798e49dcab4bf182dbfc483524.tar.bz2 |
blk-mq: provide a helper to check if a queue is busy
Returns true if the queue currently has requests pending,
false if not.
DM can use this to replace the atomic_inc/dec they do per device
to see if a device is busy.
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r-- | block/blk-mq.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index 4a622c832b31..4880e13e2394 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -790,6 +790,32 @@ 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) +{ + /* + * If we find a request, we know the queue is busy. Return false + * to stop the iteration. + */ + if (rq->q == hctx->queue) { + bool *busy = priv; + + *busy = true; + return false; + } + + return true; +} + +bool blk_mq_queue_busy(struct request_queue *q) +{ + bool busy = false; + + blk_mq_queue_tag_busy_iter(q, blk_mq_check_busy, &busy); + return busy; +} +EXPORT_SYMBOL_GPL(blk_mq_queue_busy); + static void blk_mq_rq_timed_out(struct request *req, bool reserved) { req->rq_flags |= RQF_TIMED_OUT; |