Message ID | b2210943-62b2-959a-569a-a404da03bcae@sandisk.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
On 09/26/2016 08:26 PM, Bart Van Assche wrote: > The function blk_queue_stopped() allows to test whether or not a > traditional request queue has been stopped. Introduce a helper > function that allows block drivers to query easily whether or not > one or more hardware contexts of a blk-mq queue have been stopped. > > Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> > Cc: Jens Axboe <axboe@fb.com> > Cc: Christoph Hellwig <hch@lst.de> > --- > block/blk-mq.c | 20 ++++++++++++++++++++ > include/linux/blk-mq.h | 1 + > 2 files changed, 21 insertions(+) > Reviewed-by: Hannes Reinecke <hare@suse.com> Cheers, Hannes
On Mon, Sep 26, 2016 at 11:26:26AM -0700, Bart Van Assche wrote: > The function blk_queue_stopped() allows to test whether or not a > traditional request queue has been stopped. Introduce a helper > function that allows block drivers to query easily whether or not > one or more hardware contexts of a blk-mq queue have been stopped. > > Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> > Cc: Jens Axboe <axboe@fb.com> > Cc: Christoph Hellwig <hch@lst.de> > --- Looks good, Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff --git a/block/blk-mq.c b/block/blk-mq.c index e9ebe98..98d4812 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -938,6 +938,26 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async) } EXPORT_SYMBOL(blk_mq_run_hw_queues); +/** + * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped + * @q: request queue. + * + * The caller is responsible for serializing this function against + * blk_mq_{start,stop}_hw_queue(). + */ +bool blk_mq_queue_stopped(struct request_queue *q) +{ + struct blk_mq_hw_ctx *hctx; + int i; + + queue_for_each_hw_ctx(q, hctx, i) + if (test_bit(BLK_MQ_S_STOPPED, &hctx->state)) + return true; + + return false; +} +EXPORT_SYMBOL(blk_mq_queue_stopped); + void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx) { cancel_work(&hctx->run_work); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 5daa0ef..368c460d 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -233,6 +233,7 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs void blk_mq_abort_requeue_list(struct request_queue *q); void blk_mq_complete_request(struct request *rq, int error); +bool blk_mq_queue_stopped(struct request_queue *q); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_stop_hw_queues(struct request_queue *q);
The function blk_queue_stopped() allows to test whether or not a traditional request queue has been stopped. Introduce a helper function that allows block drivers to query easily whether or not one or more hardware contexts of a blk-mq queue have been stopped. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Jens Axboe <axboe@fb.com> Cc: Christoph Hellwig <hch@lst.de> --- block/blk-mq.c | 20 ++++++++++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 21 insertions(+)