@@ -400,7 +400,7 @@ static void blk_mq_debugfs_tags_show(struct seq_file *m,
seq_printf(m, "nr_tags=%u\n", tags->nr_tags);
seq_printf(m, "nr_reserved_tags=%u\n", tags->nr_reserved_tags);
seq_printf(m, "active_queues=%d\n",
- READ_ONCE(tags->active_queues));
+ READ_ONCE(tags->ctl.active_queues));
seq_puts(m, "\nbitmap_tags:\n");
sbitmap_queue_show(&tags->bitmap_tags, m);
@@ -57,8 +57,8 @@ void __blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)
}
spin_lock_irq(&tags->lock);
- users = tags->active_queues + 1;
- WRITE_ONCE(tags->active_queues, users);
+ users = tags->ctl.active_queues + 1;
+ WRITE_ONCE(tags->ctl.active_queues, users);
blk_mq_update_wake_batch(tags, users);
spin_unlock_irq(&tags->lock);
}
@@ -94,8 +94,8 @@ void __blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)
}
spin_lock_irq(&tags->lock);
- users = tags->active_queues - 1;
- WRITE_ONCE(tags->active_queues, users);
+ users = tags->ctl.active_queues - 1;
+ WRITE_ONCE(tags->ctl.active_queues, users);
blk_mq_update_wake_batch(tags, users);
spin_unlock_irq(&tags->lock);
@@ -435,7 +435,7 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,
return true;
}
- users = READ_ONCE(hctx->tags->active_queues);
+ users = READ_ONCE(hctx->tags->ctl.active_queues);
if (!users)
return true;
@@ -727,13 +727,16 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
blk_opf_t opf, blk_mq_req_flags_t flags,
unsigned int hctx_idx);
+struct tag_sharing_ctl {
+ unsigned int active_queues;
+};
+
/*
* Tag address space map.
*/
struct blk_mq_tags {
unsigned int nr_tags;
unsigned int nr_reserved_tags;
- unsigned int active_queues;
struct sbitmap_queue bitmap_tags;
struct sbitmap_queue breserved_tags;
@@ -744,9 +747,12 @@ struct blk_mq_tags {
/*
* used to clear request reference in rqs[] before freeing one
- * request pool
+ * request pool, and to protect tag_sharing_ctl.
*/
spinlock_t lock;
+
+ /* used when tags is shared for multiple request_queue or hctx. */
+ struct tag_sharing_ctl ctl;
};
static inline struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags,