Commit 334335d2 authored by Omar Sandoval's avatar Omar Sandoval Committed by Jens Axboe

block: warn if sharing request queue across gendisks

Now that the remaining drivers have been converted to one request queue
per gendisk, let's warn if a request queue gets registered more than
once. This will catch future drivers which might do it inadvertently or
any old drivers that I may have missed.
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent d3cfb2a0
...@@ -871,6 +871,11 @@ int blk_register_queue(struct gendisk *disk) ...@@ -871,6 +871,11 @@ int blk_register_queue(struct gendisk *disk)
if (WARN_ON(!q)) if (WARN_ON(!q))
return -ENXIO; return -ENXIO;
WARN_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags),
"%s is registering an already registered queue\n",
kobject_name(&dev->kobj));
queue_flag_set_unlocked(QUEUE_FLAG_REGISTERED, q);
/* /*
* SCSI probing may synchronously create and destroy a lot of * SCSI probing may synchronously create and destroy a lot of
* request_queues for non-existent devices. Shutting down a fully * request_queues for non-existent devices. Shutting down a fully
...@@ -931,6 +936,8 @@ void blk_unregister_queue(struct gendisk *disk) ...@@ -931,6 +936,8 @@ void blk_unregister_queue(struct gendisk *disk)
if (WARN_ON(!q)) if (WARN_ON(!q))
return; return;
queue_flag_clear_unlocked(QUEUE_FLAG_REGISTERED, q);
if (q->mq_ops) if (q->mq_ops)
blk_mq_unregister_dev(disk_to_dev(disk), q); blk_mq_unregister_dev(disk_to_dev(disk), q);
......
...@@ -617,6 +617,7 @@ struct request_queue { ...@@ -617,6 +617,7 @@ struct request_queue {
#define QUEUE_FLAG_STATS 27 /* track rq completion times */ #define QUEUE_FLAG_STATS 27 /* track rq completion times */
#define QUEUE_FLAG_RESTART 28 /* queue needs restart at completion */ #define QUEUE_FLAG_RESTART 28 /* queue needs restart at completion */
#define QUEUE_FLAG_POLL_STATS 29 /* collecting stats for hybrid polling */ #define QUEUE_FLAG_POLL_STATS 29 /* collecting stats for hybrid polling */
#define QUEUE_FLAG_REGISTERED 30 /* queue has been registered to a disk */
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
(1 << QUEUE_FLAG_STACKABLE) | \ (1 << QUEUE_FLAG_STACKABLE) | \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment