[PATCH V2 10/13] block: add helper of disk_release_queue for release queue data for disk
Ming Lei
ming.lei at redhat.com
Sat Jan 22 03:10:51 PST 2022
Add one helper of disk_release_queue for releasing queue data for disk.
Signed-off-by: Ming Lei <ming.lei at redhat.com>
---
block/genhd.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 5bd7bcd6246e..a86027619683 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1085,6 +1085,20 @@ static const struct attribute_group *disk_attr_groups[] = {
NULL
};
+static void disk_release_queue(struct gendisk *disk)
+{
+ struct request_queue *q = disk->queue;
+
+ blk_mq_cancel_work_sync(q);
+
+ /*
+ * Remove all references to @q from the block cgroup controller before
+ * restoring @q->queue_lock to avoid that restoring this pointer causes
+ * e.g. blkcg_print_blkgs() to crash.
+ */
+ blkcg_exit_queue(q);
+}
+
/**
* disk_release - releases all allocated resources of the gendisk
* @dev: the device representing this disk
@@ -1106,19 +1120,12 @@ static void disk_release(struct device *dev)
might_sleep();
WARN_ON_ONCE(disk_live(disk));
- blk_mq_cancel_work_sync(disk->queue);
+ disk_release_queue(disk);
disk_release_events(disk);
kfree(disk->random);
xa_destroy(&disk->part_tbl);
- /*
- * Remove all references to @q from the block cgroup controller before
- * restoring @q->queue_lock to avoid that restoring this pointer causes
- * e.g. blkcg_print_blkgs() to crash.
- */
- blkcg_exit_queue(disk->queue);
-
disk->queue->disk = NULL;
blk_put_queue(disk->queue);
iput(disk->part0->bd_inode); /* frees the disk */
--
2.31.1
More information about the Linux-nvme
mailing list