]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: simplify disk shutdown
authorChristoph Hellwig <hch@lst.de>
Sun, 19 Jun 2022 06:05:51 +0000 (08:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 28 Jun 2022 12:30:26 +0000 (06:30 -0600)
Set the queue dying flag and call blk_mq_exit_queue from del_gendisk for
all disks that do not have separately allocated queues, and thus remove
the need to call blk_cleanup_queue for them.

Rename blk_cleanup_disk to blk_mq_destroy_queue to make it clear that
this function is intended only for separately allocated blk-mq queues.

This saves an extra queue freeze for devices without a separately
allocated queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20220619060552.1850436-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
34 files changed:
block/blk-core.c
block/blk-mq.c
block/blk-sysfs.c
block/blk.h
block/bsg-lib.c
block/genhd.c
drivers/block/ataflop.c
drivers/block/loop.c
drivers/block/mtip32xx/mtip32xx.c
drivers/block/rnbd/rnbd-clt.c
drivers/block/sx8.c
drivers/block/virtio_blk.c
drivers/block/z2ram.c
drivers/cdrom/gdrom.c
drivers/memstick/core/ms_block.c
drivers/memstick/core/mspro_block.c
drivers/mmc/core/block.c
drivers/mmc/core/queue.c
drivers/nvme/host/apple.c
drivers/nvme/host/core.c
drivers/nvme/host/fc.c
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/host/tcp.c
drivers/nvme/target/loop.c
drivers/s390/block/dasd.c
drivers/s390/block/dasd_genhd.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/sd.c
drivers/scsi/sr.c
drivers/ufs/core/ufshcd.c
include/linux/blk-mq.h
include/linux/blkdev.h

index 04029ffea031a2c88a158a71d97435246233b831..5ad7bd93077c8f9341e03c2df2cbf2626bea4f5c 100644 (file)
@@ -284,43 +284,6 @@ void blk_queue_start_drain(struct request_queue *q)
        wake_up_all(&q->mq_freeze_wq);
 }
 
-/**
- * blk_cleanup_queue - shutdown a request queue
- * @q: request queue to shutdown
- *
- * Mark @q DYING, drain all pending requests, mark @q DEAD, destroy and
- * put it.  All future requests will be failed immediately with -ENODEV.
- *
- * Context: can sleep
- */
-void blk_cleanup_queue(struct request_queue *q)
-{
-       /* cannot be called from atomic context */
-       might_sleep();
-
-       WARN_ON_ONCE(blk_queue_registered(q));
-
-       /* mark @q DYING, no new request or merges will be allowed afterwards */
-       blk_queue_flag_set(QUEUE_FLAG_DYING, q);
-       blk_queue_start_drain(q);
-
-       /*
-        * Drain all requests queued before DYING marking. Set DEAD flag to
-        * prevent that blk_mq_run_hw_queues() accesses the hardware queues
-        * after draining finished.
-        */
-       blk_freeze_queue(q);
-       blk_sync_queue(q);
-       if (queue_is_mq(q)) {
-               blk_mq_cancel_work_sync(q);
-               blk_mq_exit_queue(q);
-       }
-
-       /* @q is and will stay empty, shutdown and put */
-       blk_put_queue(q);
-}
-EXPORT_SYMBOL(blk_cleanup_queue);
-
 /**
  * blk_queue_enter() - try to increase q->q_usage_counter
  * @q: request queue pointer
index 92aae03103b74e4f489f3cc4e3ede889f7076f05..b1dbc4b2c2c970f41a0e13a4790697c4ef1ca167 100644 (file)
@@ -3902,7 +3902,7 @@ static struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set,
        q->queuedata = queuedata;
        ret = blk_mq_init_allocated_queue(set, q);
        if (ret) {
-               blk_cleanup_queue(q);
+               blk_put_queue(q);
                return ERR_PTR(ret);
        }
        return q;
@@ -3914,6 +3914,35 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
 }
 EXPORT_SYMBOL(blk_mq_init_queue);
 
+/**
+ * blk_mq_destroy_queue - shutdown a request queue
+ * @q: request queue to shutdown
+ *
+ * This shuts down a request queue allocated by blk_mq_init_queue() and drops
+ * the initial reference.  All future requests will failed with -ENODEV.
+ *
+ * Context: can sleep
+ */
+void blk_mq_destroy_queue(struct request_queue *q)
+{
+       WARN_ON_ONCE(!queue_is_mq(q));
+       WARN_ON_ONCE(blk_queue_registered(q));
+
+       might_sleep();
+
+       blk_queue_flag_set(QUEUE_FLAG_DYING, q);
+       blk_queue_start_drain(q);
+       blk_freeze_queue(q);
+
+       blk_sync_queue(q);
+       blk_mq_cancel_work_sync(q);
+       blk_mq_exit_queue(q);
+
+       /* @q is and will stay empty, shutdown and put */
+       blk_put_queue(q);
+}
+EXPORT_SYMBOL(blk_mq_destroy_queue);
+
 struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata,
                struct lock_class_key *lkclass)
 {
@@ -3926,13 +3955,23 @@ struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata,
 
        disk = __alloc_disk_node(q, set->numa_node, lkclass);
        if (!disk) {
-               blk_cleanup_queue(q);
+               blk_put_queue(q);
                return ERR_PTR(-ENOMEM);
        }
+       set_bit(GD_OWNS_QUEUE, &disk->state);
        return disk;
 }
 EXPORT_SYMBOL(__blk_mq_alloc_disk);
 
+struct gendisk *blk_mq_alloc_disk_for_queue(struct request_queue *q,
+               struct lock_class_key *lkclass)
+{
+       if (!blk_get_queue(q))
+               return NULL;
+       return __alloc_disk_node(q, NUMA_NO_NODE, lkclass);
+}
+EXPORT_SYMBOL(blk_mq_alloc_disk_for_queue);
+
 static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
                struct blk_mq_tag_set *set, struct request_queue *q,
                int hctx_idx, int node)
index 69e53d1a4f0e62c662b6486179e27ed764e2da1c..9b211e519de81c7ce681e45b54df059aad489d55 100644 (file)
@@ -755,11 +755,6 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)
  * decremented with blk_put_queue(). Once the refcount reaches 0 this function
  * is called.
  *
- * For drivers that have a request_queue on a gendisk and added with
- * __device_add_disk() the refcount to request_queue will reach 0 with
- * the last put_disk() called by the driver. For drivers which don't use
- * __device_add_disk() this happens with blk_cleanup_queue().
- *
  * Drivers exist which depend on the release of the request_queue to be
  * synchronous, it should not be deferred.
  *
index 8e79296ee97a2c37d4a0589e72388d67892e0242..1a0d3e6a4a6313c3b6203f36a10015b518592f29 100644 (file)
@@ -424,6 +424,9 @@ int bdev_resize_partition(struct gendisk *disk, int partno, sector_t start,
                sector_t length);
 void blk_drop_partitions(struct gendisk *disk);
 
+struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
+               struct lock_class_key *lkclass);
+
 int bio_add_hw_page(struct request_queue *q, struct bio *bio,
                struct page *page, unsigned int len, unsigned int offset,
                unsigned int max_sectors, bool *same_page);
index acfe1357bf6c4938ff1f463da74ed0a2c09d46ce..fd4cd5e6828266177cee98ba39181f24eacf28de 100644 (file)
@@ -324,7 +324,7 @@ void bsg_remove_queue(struct request_queue *q)
                        container_of(q->tag_set, struct bsg_set, tag_set);
 
                bsg_unregister_queue(bset->bd);
-               blk_cleanup_queue(q);
+               blk_mq_destroy_queue(q);
                blk_mq_free_tag_set(&bset->tag_set);
                kfree(bset);
        }
@@ -399,7 +399,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
 
        return q;
 out_cleanup_queue:
-       blk_cleanup_queue(q);
+       blk_mq_destroy_queue(q);
 out_queue:
        blk_mq_free_tag_set(set);
 out_tag_set:
index 278227ba1d531a561a45ef57f86b684edc6c138e..4d15f828c44988dd652af5ae4d37ed58946fd03f 100644 (file)
@@ -617,6 +617,8 @@ void del_gendisk(struct gendisk *disk)
         * Fail any new I/O.
         */
        set_bit(GD_DEAD, &disk->state);
+       if (test_bit(GD_OWNS_QUEUE, &disk->state))
+               blk_queue_flag_set(QUEUE_FLAG_DYING, q);
        set_capacity(disk, 0);
 
        /*
@@ -663,11 +665,16 @@ void del_gendisk(struct gendisk *disk)
        blk_mq_unquiesce_queue(q);
 
        /*
-        * Allow using passthrough request again after the queue is torn down.
+        * If the disk does not own the queue, allow using passthrough requests
+        * again.  Else leave the queue frozen to fail all I/O.
         */
-       blk_queue_flag_clear(QUEUE_FLAG_INIT_DONE, q);
-       __blk_mq_unfreeze_queue(q, true);
-
+       if (!test_bit(GD_OWNS_QUEUE, &disk->state)) {
+               blk_queue_flag_clear(QUEUE_FLAG_INIT_DONE, q);
+               __blk_mq_unfreeze_queue(q, true);
+       } else {
+               if (queue_is_mq(q))
+                       blk_mq_exit_queue(q);
+       }
 }
 EXPORT_SYMBOL(del_gendisk);
 
@@ -1338,9 +1345,6 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
 {
        struct gendisk *disk;
 
-       if (!blk_get_queue(q))
-               return NULL;
-
        disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
        if (!disk)
                goto out_put_queue;
@@ -1391,7 +1395,6 @@ out_put_queue:
        blk_put_queue(q);
        return NULL;
 }
-EXPORT_SYMBOL(__alloc_disk_node);
 
 struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass)
 {
@@ -1404,9 +1407,10 @@ struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass)
 
        disk = __alloc_disk_node(q, node, lkclass);
        if (!disk) {
-               blk_cleanup_queue(q);
+               blk_put_queue(q);
                return NULL;
        }
+       set_bit(GD_OWNS_QUEUE, &disk->state);
        return disk;
 }
 EXPORT_SYMBOL(__blk_alloc_disk);
@@ -1439,7 +1443,6 @@ EXPORT_SYMBOL(put_disk);
  */
 void blk_cleanup_disk(struct gendisk *disk)
 {
-       blk_cleanup_queue(disk->queue);
        put_disk(disk);
 }
 EXPORT_SYMBOL(blk_cleanup_disk);
index e232cc4fd444bf5f9a0e6efae8d1116ddd0137aa..c6e41ee18aaa28833862e5412c6e1c9d2d5300b3 100644 (file)
@@ -2045,7 +2045,6 @@ static void atari_floppy_cleanup(void)
                        if (!unit[i].disk[type])
                                continue;
                        del_gendisk(unit[i].disk[type]);
-                       blk_cleanup_queue(unit[i].disk[type]->queue);
                        put_disk(unit[i].disk[type]);
                }
                blk_mq_free_tag_set(&unit[i].tag_set);
index 084f9b8a0ba3c4b49fcfd6b579aed601d4009d14..cc608226c8c78c29fb93523e43ce9a60c24d66ad 100644 (file)
@@ -2057,7 +2057,6 @@ static void loop_remove(struct loop_device *lo)
 {
        /* Make this loop device unreachable from pathname. */
        del_gendisk(lo->lo_disk);
-       blk_cleanup_queue(lo->lo_disk->queue);
        blk_mq_free_tag_set(&lo->tag_set);
 
        mutex_lock(&loop_ctl_mutex);
index e7604b3bf8a75efcac269c9aa24c3db9408909df..1d0e0a9fdd7c2005f656230c25efa6b701ff5f03 100644 (file)
@@ -3565,7 +3565,6 @@ static int mtip_block_shutdown(struct driver_data *dd)
        if (test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag))
                del_gendisk(dd->disk);
 
-       blk_cleanup_queue(dd->queue);
        blk_mq_free_tag_set(&dd->tags);
        put_disk(dd->disk);
        return 0;
@@ -3914,7 +3913,6 @@ static void mtip_pci_remove(struct pci_dev *pdev)
                dev_info(&dd->pdev->dev, "device %s surprise removal\n",
                                                dd->disk->disk_name);
 
-       blk_cleanup_queue(dd->queue);
        blk_mq_free_tag_set(&dd->tags);
 
        /* De-initialize the protocol layer. */
index 409c76b81aed4613f57cb3f5cb14d4db3a331ae3..a4470374f54fc511a1658e21095781dd84512f63 100644 (file)
@@ -1755,7 +1755,7 @@ static void rnbd_destroy_sessions(void)
                list_for_each_entry_safe(dev, tn, &sess->devs_list, list) {
                        /*
                         * Here unmap happens in parallel for only one reason:
-                        * blk_cleanup_queue() takes around half a second, so
+                        * del_gendisk() takes around half a second, so
                         * on huge amount of devices the whole module unload
                         * procedure takes minutes.
                         */
index 63b4f6431d2e63f704ea35cc283ab8509cd05bb6..75057dbbcfbeabfb856bfe7577edb02e881be153 100644 (file)
@@ -1536,7 +1536,7 @@ err_out_free_majors:
                clear_bit(0, &carm_major_alloc);
        else if (host->major == 161)
                clear_bit(1, &carm_major_alloc);
-       blk_cleanup_queue(host->oob_q);
+       blk_mq_destroy_queue(host->oob_q);
        blk_mq_free_tag_set(&host->tag_set);
 err_out_dma_free:
        dma_free_coherent(&pdev->dev, CARM_SHM_SIZE, host->shm, host->shm_dma);
@@ -1570,7 +1570,7 @@ static void carm_remove_one (struct pci_dev *pdev)
                clear_bit(0, &carm_major_alloc);
        else if (host->major == 161)
                clear_bit(1, &carm_major_alloc);
-       blk_cleanup_queue(host->oob_q);
+       blk_mq_destroy_queue(host->oob_q);
        blk_mq_free_tag_set(&host->tag_set);
        dma_free_coherent(&pdev->dev, CARM_SHM_SIZE, host->shm, host->shm_dma);
        iounmap(host->mmio);
index 6fc7850c2b0a0cb0c6bcdd2392fbeef363d47350..cff1b6f6b0548a7960b9636bc1bd3f0889f22718 100644 (file)
@@ -1111,7 +1111,6 @@ static void virtblk_remove(struct virtio_device *vdev)
        flush_work(&vblk->config_work);
 
        del_gendisk(vblk->disk);
-       blk_cleanup_queue(vblk->disk->queue);
        blk_mq_free_tag_set(&vblk->tag_set);
 
        mutex_lock(&vblk->vdev_mutex);
index 7a6ed83481b8de4b793646c9777eaa74dd7eba70..18ad43d9933ec052cd28962d57f8650e8ad82e0b 100644 (file)
@@ -384,7 +384,6 @@ static void __exit z2_exit(void)
 
        for (i = 0; i < Z2MINOR_COUNT; i++) {
                del_gendisk(z2ram_gendisk[i]);
-               blk_cleanup_queue(z2ram_gendisk[i]->queue);
                put_disk(z2ram_gendisk[i]);
        }
        blk_mq_free_tag_set(&tag_set);
index 8e78b37d0f6a43fe1d012aa841495e1cc0352cb0..f4cc90ea6198e76a7f1948c2773677ff146a48ac 100644 (file)
@@ -831,7 +831,6 @@ probe_fail_no_mem:
 
 static int remove_gdrom(struct platform_device *devptr)
 {
-       blk_cleanup_queue(gd.gdrom_rq);
        blk_mq_free_tag_set(&gd.tag_set);
        free_irq(HW_EVENT_GDROM_CMD, &gd);
        free_irq(HW_EVENT_GDROM_DMA, &gd);
index 3993bdd4b519c33da6b740e2b625a1a18f8be556..ba7e7249a3db46b7fc22c86b8dd9926d7f2dc676 100644 (file)
@@ -2187,7 +2187,6 @@ static void msb_remove(struct memstick_dev *card)
 
        /* Remove the disk */
        del_gendisk(msb->disk);
-       blk_cleanup_queue(msb->queue);
        blk_mq_free_tag_set(&msb->tag_set);
        msb->queue = NULL;
 
index 725ba74ded308ab26e80fa2d6d4798690af853db..72e91c06c618bb35e54638b0202192f3e9013aa4 100644 (file)
@@ -1294,7 +1294,6 @@ static void mspro_block_remove(struct memstick_dev *card)
        del_gendisk(msb->disk);
        dev_dbg(&card->dev, "mspro block remove\n");
 
-       blk_cleanup_queue(msb->queue);
        blk_mq_free_tag_set(&msb->tag_set);
        msb->queue = NULL;
 
index f4a1281658db07bd0152c2f509ee095d4c3470e7..bda6c67ce93f4c7b541a824657552dbed2ab1574 100644 (file)
@@ -2509,7 +2509,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
        return md;
 
  err_cleanup_queue:
-       blk_cleanup_queue(md->disk->queue);
        blk_mq_free_tag_set(&md->queue.tag_set);
  err_kfree:
        kfree(md);
index fa5324ceeebe479b0546a0eace0d91fb107b37c9..f824cfdab75ac0da7816755b74fc25a972d063e4 100644 (file)
@@ -494,7 +494,6 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
        if (blk_queue_quiesced(q))
                blk_mq_unquiesce_queue(q);
 
-       blk_cleanup_queue(q);
        blk_mq_free_tag_set(&mq->tag_set);
 
        /*
index d702d7d60235dc0bcc51fb8ee38876c25e4b016d..2d23b7d41f7e6134f01c03e693a1b196fc336270 100644 (file)
@@ -1502,7 +1502,7 @@ static int apple_nvme_probe(struct platform_device *pdev)
 
        if (!blk_get_queue(anv->ctrl.admin_q)) {
                nvme_start_admin_queue(&anv->ctrl);
-               blk_cleanup_queue(anv->ctrl.admin_q);
+               blk_mq_destroy_queue(anv->ctrl.admin_q);
                anv->ctrl.admin_q = NULL;
                ret = -ENODEV;
                goto put_dev;
index b3d9c29aba1e6af1a9c9682e279cdabe4a8c5031..4e3a0f7bfc9c1cc0876948f7d22fe94fe957b11d 100644 (file)
@@ -4103,7 +4103,6 @@ static void nvme_ns_remove(struct nvme_ns *ns)
        if (!nvme_ns_head_multipath(ns->head))
                nvme_cdev_del(&ns->cdev, &ns->cdev_device);
        del_gendisk(ns->disk);
-       blk_cleanup_queue(ns->queue);
 
        down_write(&ns->ctrl->namespaces_rwsem);
        list_del_init(&ns->list);
index 3c778bb0c2944725ad321c5b5a33df33d516eabf..a96aa831684c353984b6083ae45e7429b96708bc 100644 (file)
@@ -2392,7 +2392,7 @@ nvme_fc_ctrl_free(struct kref *ref)
        unsigned long flags;
 
        if (ctrl->ctrl.tagset) {
-               blk_cleanup_queue(ctrl->ctrl.connect_q);
+               blk_mq_destroy_queue(ctrl->ctrl.connect_q);
                blk_mq_free_tag_set(&ctrl->tag_set);
        }
 
@@ -2402,8 +2402,8 @@ nvme_fc_ctrl_free(struct kref *ref)
        spin_unlock_irqrestore(&ctrl->rport->lock, flags);
 
        nvme_start_admin_queue(&ctrl->ctrl);
-       blk_cleanup_queue(ctrl->ctrl.admin_q);
-       blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+       blk_mq_destroy_queue(ctrl->ctrl.admin_q);
+       blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
        blk_mq_free_tag_set(&ctrl->admin_tag_set);
 
        kfree(ctrl->queues);
@@ -2953,7 +2953,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
 out_delete_hw_queues:
        nvme_fc_delete_hw_io_queues(ctrl);
 out_cleanup_blk_queue:
-       blk_cleanup_queue(ctrl->ctrl.connect_q);
+       blk_mq_destroy_queue(ctrl->ctrl.connect_q);
 out_free_tag_set:
        blk_mq_free_tag_set(&ctrl->tag_set);
        nvme_fc_free_io_queues(ctrl);
@@ -3642,9 +3642,9 @@ fail_ctrl:
        return ERR_PTR(-EIO);
 
 out_cleanup_admin_q:
-       blk_cleanup_queue(ctrl->ctrl.admin_q);
+       blk_mq_destroy_queue(ctrl->ctrl.admin_q);
 out_cleanup_fabrics_q:
-       blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+       blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
 out_free_admin_tag_set:
        blk_mq_free_tag_set(&ctrl->admin_tag_set);
 out_free_queues:
index d7b24ee1728599fed9b2e5a6b1ab6351de8b130a..247a74aba336e0afe9b8e121be7ca09950ddb7b7 100644 (file)
@@ -1760,7 +1760,7 @@ static void nvme_dev_remove_admin(struct nvme_dev *dev)
                 * queue to flush these to completion.
                 */
                nvme_start_admin_queue(&dev->ctrl);
-               blk_cleanup_queue(dev->ctrl.admin_q);
+               blk_mq_destroy_queue(dev->ctrl.admin_q);
                blk_mq_free_tag_set(&dev->admin_tagset);
        }
 }
index f2a5e1ea508a7af0f5f986b33f33a5668682f378..0fb7c8e7ab0bed9990c3d3a5636521e6f8e12b6a 100644 (file)
@@ -840,8 +840,8 @@ static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
                bool remove)
 {
        if (remove) {
-               blk_cleanup_queue(ctrl->ctrl.admin_q);
-               blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+               blk_mq_destroy_queue(ctrl->ctrl.admin_q);
+               blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
                blk_mq_free_tag_set(ctrl->ctrl.admin_tagset);
        }
        if (ctrl->async_event_sqe.data) {
@@ -935,10 +935,10 @@ out_stop_queue:
        nvme_cancel_admin_tagset(&ctrl->ctrl);
 out_cleanup_queue:
        if (new)
-               blk_cleanup_queue(ctrl->ctrl.admin_q);
+               blk_mq_destroy_queue(ctrl->ctrl.admin_q);
 out_cleanup_fabrics_q:
        if (new)
-               blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+               blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
 out_free_tagset:
        if (new)
                blk_mq_free_tag_set(ctrl->ctrl.admin_tagset);
@@ -957,7 +957,7 @@ static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl,
                bool remove)
 {
        if (remove) {
-               blk_cleanup_queue(ctrl->ctrl.connect_q);
+               blk_mq_destroy_queue(ctrl->ctrl.connect_q);
                blk_mq_free_tag_set(ctrl->ctrl.tagset);
        }
        nvme_rdma_free_io_queues(ctrl);
@@ -1012,7 +1012,7 @@ out_wait_freeze_timed_out:
 out_cleanup_connect_q:
        nvme_cancel_tagset(&ctrl->ctrl);
        if (new)
-               blk_cleanup_queue(ctrl->ctrl.connect_q);
+               blk_mq_destroy_queue(ctrl->ctrl.connect_q);
 out_free_tag_set:
        if (new)
                blk_mq_free_tag_set(ctrl->ctrl.tagset);
index bb67538d241b657dec9ee4bac33029920c493d9d..b81942fa5f959b64904622c2b335c97d678b7c54 100644 (file)
@@ -1885,7 +1885,7 @@ static void nvme_tcp_destroy_io_queues(struct nvme_ctrl *ctrl, bool remove)
 {
        nvme_tcp_stop_io_queues(ctrl);
        if (remove) {
-               blk_cleanup_queue(ctrl->connect_q);
+               blk_mq_destroy_queue(ctrl->connect_q);
                blk_mq_free_tag_set(ctrl->tagset);
        }
        nvme_tcp_free_io_queues(ctrl);
@@ -1940,7 +1940,7 @@ out_wait_freeze_timed_out:
 out_cleanup_connect_q:
        nvme_cancel_tagset(ctrl);
        if (new)
-               blk_cleanup_queue(ctrl->connect_q);
+               blk_mq_destroy_queue(ctrl->connect_q);
 out_free_tag_set:
        if (new)
                blk_mq_free_tag_set(ctrl->tagset);
@@ -1953,8 +1953,8 @@ static void nvme_tcp_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove)
 {
        nvme_tcp_stop_queue(ctrl, 0);
        if (remove) {
-               blk_cleanup_queue(ctrl->admin_q);
-               blk_cleanup_queue(ctrl->fabrics_q);
+               blk_mq_destroy_queue(ctrl->admin_q);
+               blk_mq_destroy_queue(ctrl->fabrics_q);
                blk_mq_free_tag_set(ctrl->admin_tagset);
        }
        nvme_tcp_free_admin_queue(ctrl);
@@ -2012,10 +2012,10 @@ out_stop_queue:
        nvme_cancel_admin_tagset(ctrl);
 out_cleanup_queue:
        if (new)
-               blk_cleanup_queue(ctrl->admin_q);
+               blk_mq_destroy_queue(ctrl->admin_q);
 out_cleanup_fabrics_q:
        if (new)
-               blk_cleanup_queue(ctrl->fabrics_q);
+               blk_mq_destroy_queue(ctrl->fabrics_q);
 out_free_tagset:
        if (new)
                blk_mq_free_tag_set(ctrl->admin_tagset);
index 59024af2da2e3d22edb5148f4d31dcbcc87768ff..0f5c77e22a0a9b0bd62fcd7bea3a535b6cd015fb 100644 (file)
@@ -266,8 +266,8 @@ static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl)
        if (!test_and_clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags))
                return;
        nvmet_sq_destroy(&ctrl->queues[0].nvme_sq);
-       blk_cleanup_queue(ctrl->ctrl.admin_q);
-       blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+       blk_mq_destroy_queue(ctrl->ctrl.admin_q);
+       blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
        blk_mq_free_tag_set(&ctrl->admin_tag_set);
 }
 
@@ -283,7 +283,7 @@ static void nvme_loop_free_ctrl(struct nvme_ctrl *nctrl)
        mutex_unlock(&nvme_loop_ctrl_mutex);
 
        if (nctrl->tagset) {
-               blk_cleanup_queue(ctrl->ctrl.connect_q);
+               blk_mq_destroy_queue(ctrl->ctrl.connect_q);
                blk_mq_free_tag_set(&ctrl->tag_set);
        }
        kfree(ctrl->queues);
@@ -410,9 +410,9 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)
 
 out_cleanup_queue:
        clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags);
-       blk_cleanup_queue(ctrl->ctrl.admin_q);
+       blk_mq_destroy_queue(ctrl->ctrl.admin_q);
 out_cleanup_fabrics_q:
-       blk_cleanup_queue(ctrl->ctrl.fabrics_q);
+       blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
 out_free_tagset:
        blk_mq_free_tag_set(&ctrl->admin_tag_set);
 out_free_sq:
@@ -554,7 +554,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)
        return 0;
 
 out_cleanup_connect_q:
-       blk_cleanup_queue(ctrl->ctrl.connect_q);
+       blk_mq_destroy_queue(ctrl->ctrl.connect_q);
 out_free_tagset:
        blk_mq_free_tag_set(&ctrl->tag_set);
 out_destroy_queues:
index ba6d787896606d093183c1b0ad1eec5c9fdba2d7..e8489331f12b8e0e2df88059b51aef971a2b96af 100644 (file)
@@ -3280,7 +3280,7 @@ static int dasd_alloc_queue(struct dasd_block *block)
 static void dasd_free_queue(struct dasd_block *block)
 {
        if (block->request_queue) {
-               blk_cleanup_queue(block->request_queue);
+               blk_mq_destroy_queue(block->request_queue);
                blk_mq_free_tag_set(&block->tag_set);
                block->request_queue = NULL;
        }
index a7a33ebf4bbe93c3e878b3ca8eb9b8bc9f468cd7..5a83f0a39901b3816d978224a5673384d4ce340d 100644 (file)
@@ -41,8 +41,8 @@ int dasd_gendisk_alloc(struct dasd_block *block)
        if (base->devindex >= DASD_PER_MAJOR)
                return -EBUSY;
 
-       gdp = __alloc_disk_node(block->request_queue, NUMA_NO_NODE,
-                               &dasd_bio_compl_lkclass);
+       gdp = blk_mq_alloc_disk_for_queue(block->request_queue,
+                                         &dasd_bio_compl_lkclass);
        if (!gdp)
                return -ENOMEM;
 
index 6ffc9e4258a8052c0b05083a86361033185620c0..cdf0056582d5feb1a73aac8620ccbdb75f05eef7 100644 (file)
@@ -163,7 +163,7 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, bool unbusy)
         * Requeue this command.  It will go before all other commands
         * that are already in the queue. Schedule requeue work under
         * lock such that the kblockd_schedule_work() call happens
-        * before blk_cleanup_queue() finishes.
+        * before blk_mq_destroy_queue() finishes.
         */
        cmd->result = 0;
 
@@ -424,9 +424,9 @@ static void scsi_starved_list_run(struct Scsi_Host *shost)
                 * it and the queue.  Mitigate by taking a reference to the
                 * queue and never touching the sdev again after we drop the
                 * host lock.  Note: if __scsi_remove_device() invokes
-                * blk_cleanup_queue() before the queue is run from this
+                * blk_mq_destroy_queue() before the queue is run from this
                 * function then blk_run_queue() will return immediately since
-                * blk_cleanup_queue() marks the queue with QUEUE_FLAG_DYING.
+                * blk_mq_destroy_queue() marks the queue with QUEUE_FLAG_DYING.
                 */
                slq = sdev->request_queue;
                if (!blk_get_queue(slq))
index 43949798a2e47531245b8799c30fb42c2ec7d61f..aa70d9282161d5be2412531ecacab68c0c82ebcc 100644 (file)
@@ -1475,7 +1475,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
        scsi_device_set_state(sdev, SDEV_DEL);
        mutex_unlock(&sdev->state_mutex);
 
-       blk_cleanup_queue(sdev->request_queue);
+       blk_mq_destroy_queue(sdev->request_queue);
        cancel_work_sync(&sdev->requeue_work);
 
        if (sdev->host->hostt->slave_destroy)
index a1a2ac09066fdb8a57114c61d1207090de9754fd..cb587e488601c3317314bec79913f40ef4695e34 100644 (file)
@@ -3440,8 +3440,8 @@ static int sd_probe(struct device *dev)
        if (!sdkp)
                goto out;
 
-       gd = __alloc_disk_node(sdp->request_queue, NUMA_NO_NODE,
-                              &sd_bio_compl_lkclass);
+       gd = blk_mq_alloc_disk_for_queue(sdp->request_queue,
+                                        &sd_bio_compl_lkclass);
        if (!gd)
                goto out_free;
 
index 32d3b8274f14850206ab6a70ff23f10061bab15e..a278b739d0c5fc1712d35337e9e406fd0c8948bc 100644 (file)
@@ -624,8 +624,8 @@ static int sr_probe(struct device *dev)
        if (!cd)
                goto fail;
 
-       disk = __alloc_disk_node(sdev->request_queue, NUMA_NO_NODE,
-                                &sr_bio_compl_lkclass);
+       disk = blk_mq_alloc_disk_for_queue(sdev->request_queue,
+                                          &sr_bio_compl_lkclass);
        if (!disk)
                goto fail_free;
        mutex_init(&cd->lock);
index ce86d1b790c058ba6ac579d14e69258bf4b51a16..91d8852daaa94b3629af8b3c6d1f0d33ba5ead1c 100644 (file)
@@ -9487,7 +9487,7 @@ void ufshcd_remove(struct ufs_hba *hba)
        ufs_bsg_remove(hba);
        ufshpb_remove(hba);
        ufs_sysfs_remove_nodes(hba->dev);
-       blk_cleanup_queue(hba->tmf_queue);
+       blk_mq_destroy_queue(hba->tmf_queue);
        blk_mq_free_tag_set(&hba->tmf_tag_set);
        scsi_remove_host(hba->host);
        /* disable interrupts */
@@ -9783,7 +9783,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
        return 0;
 
 free_tmf_queue:
-       blk_cleanup_queue(hba->tmf_queue);
+       blk_mq_destroy_queue(hba->tmf_queue);
 free_tmf_tag_set:
        blk_mq_free_tag_set(&hba->tmf_tag_set);
 out_remove_scsi_host:
index e2d9daf7e8dd0b6ff21a8b0eb879cb40a5d14322..0fd96e92c6c650cfcddabf6fbb2cd869d504cacb 100644 (file)
@@ -686,10 +686,13 @@ struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata,
                                                                        \
        __blk_mq_alloc_disk(set, queuedata, &__key);                    \
 })
+struct gendisk *blk_mq_alloc_disk_for_queue(struct request_queue *q,
+               struct lock_class_key *lkclass);
 struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);
 int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
                struct request_queue *q);
 void blk_mq_unregister_dev(struct device *, struct request_queue *);
+void blk_mq_destroy_queue(struct request_queue *);
 
 int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
 int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
index f4632f4fe8848f0bda61a414033dac3cabd3571d..530eeccffda395cfb1b7d9c3f6066570dc86a925 100644 (file)
@@ -148,6 +148,7 @@ struct gendisk {
 #define GD_NATIVE_CAPACITY             3
 #define GD_ADDED                       4
 #define GD_SUPPRESS_PART_SCAN          5
+#define GD_OWNS_QUEUE                  6
 
        struct mutex open_mutex;        /* open/close mutex */
        unsigned open_partitions;       /* number of open partitions */
@@ -815,8 +816,6 @@ static inline u64 sb_bdev_nr_blocks(struct super_block *sb)
 
 int bdev_disk_changed(struct gendisk *disk, bool invalidate);
 
-struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
-               struct lock_class_key *lkclass);
 void put_disk(struct gendisk *disk);
 struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass);
 
@@ -933,7 +932,6 @@ static inline unsigned int blk_chunk_sectors_left(sector_t offset,
 /*
  * Access functions for manipulating queue properties
  */
-extern void blk_cleanup_queue(struct request_queue *);
 void blk_queue_bounce_limit(struct request_queue *q, enum blk_bounce limit);
 extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
 extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int);