Prepare for checking whether or not a request queue is frozen from the hot path with a minimal performance overhead. Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- block/blk-core.c | 1 + block/blk-mq.c | 1 + include/linux/blkdev.h | 2 ++ 3 files changed, 4 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index fdac48aec5ef..001a4ac997ae 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -376,6 +376,7 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref) struct request_queue *q = container_of(ref, struct request_queue, q_usage_counter); + blk_queue_flag_set(QUEUE_FLAG_FROZEN, q); wake_up_all(&q->mq_freeze_wq); } diff --git a/block/blk-mq.c b/block/blk-mq.c index 0c61492724d2..7919607c1aeb 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -218,6 +218,7 @@ bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic) WARN_ON_ONCE(q->mq_freeze_depth < 0); if (!q->mq_freeze_depth) { percpu_ref_resurrect(&q->q_usage_counter); + blk_queue_flag_clear(QUEUE_FLAG_FROZEN, q); wake_up_all(&q->mq_freeze_wq); } unfreeze = blk_unfreeze_check_owner(q); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a51f92b6c340..77b9067d621a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -641,6 +641,7 @@ enum { QUEUE_FLAG_INIT_DONE, /* queue is initialized */ QUEUE_FLAG_STATS, /* track IO start and completion times */ QUEUE_FLAG_REGISTERED, /* queue has been registered to a disk */ + QUEUE_FLAG_FROZEN, /* queue has been frozen */ QUEUE_FLAG_QUIESCED, /* queue has been quiesced */ QUEUE_FLAG_RQ_ALLOC_TIME, /* record rq->alloc_time_ns */ QUEUE_FLAG_HCTX_ACTIVE, /* at least one blk-mq hctx is active */ @@ -676,6 +677,7 @@ void blk_queue_flag_clear(unsigned int flag, struct request_queue *q); #define blk_noretry_request(rq) \ ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ REQ_FAILFAST_DRIVER)) +#define blk_queue_frozen(q) test_bit(QUEUE_FLAG_FROZEN, &(q)->queue_flags) #define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags) #define blk_queue_pm_only(q) atomic_read(&(q)->pm_only) #define blk_queue_registered(q) test_bit(QUEUE_FLAG_REGISTERED, &(q)->queue_flags)