diff options
author | Mike Snitzer <snitzer@redhat.com> | 2018-01-08 22:01:13 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-01-15 10:41:38 -0500 |
commit | fa70d2e2c4a0a54ced98260c6a176cc94c876d27 (patch) | |
tree | 76c502acc8e87e03abc499aedd78150ce8703641 /block/genhd.c | |
parent | 667257e8b2988c0183ba23e2bcd6900e87961606 (diff) |
block: allow gendisk's request_queue registration to be deferred
Since I can remember DM has forced the block layer to allow the
allocation and initialization of the request_queue to be distinct
operations. Reason for this is block/genhd.c:add_disk() has requires
that the request_queue (and associated bdi) be tied to the gendisk
before add_disk() is called -- because add_disk() also deals with
exposing the request_queue via blk_register_queue().
DM's dynamic creation of arbitrary device types (and associated
request_queue types) requires the DM device's gendisk be available so
that DM table loads can establish a master/slave relationship with
subordinate devices that are referenced by loaded DM tables -- using
bd_link_disk_holder(). But until these DM tables, and their associated
subordinate devices, are known DM cannot know what type of request_queue
it needs -- nor what its queue_limits should be.
This chicken and egg scenario has created all manner of problems for DM
and, at times, the block layer.
Summary of changes:
- Add device_add_disk_no_queue_reg() and add_disk_no_queue_reg() variant
that drivers may use to add a disk without also calling
blk_register_queue(). Driver must call blk_register_queue() once its
request_queue is fully initialized.
- Return early from blk_unregister_queue() if QUEUE_FLAG_REGISTERED
is not set. It won't be set if driver used add_disk_no_queue_reg()
but driver encounters an error and must del_gendisk() before calling
blk_register_queue().
- Export blk_register_queue().
These changes allow DM to use add_disk_no_queue_reg() to anchor its
gendisk as the "master" for master/slave relationships DM must establish
with subordinate devices referenced in DM tables that get loaded. Once
all "slave" devices for a DM device are known its request_queue can be
properly initialized and then advertised via sysfs -- important
improvement being that no request_queue resource initialization
performed by blk_register_queue() is missed for DM devices anymore.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/block/genhd.c b/block/genhd.c index 00620e01e043..88a53c188cb7 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -629,16 +629,18 @@ exit: | |||
629 | } | 629 | } |
630 | 630 | ||
631 | /** | 631 | /** |
632 | * device_add_disk - add partitioning information to kernel list | 632 | * __device_add_disk - add disk information to kernel list |
633 | * @parent: parent device for the disk | 633 | * @parent: parent device for the disk |
634 | * @disk: per-device partitioning information | 634 | * @disk: per-device partitioning information |
635 | * @register_queue: register the queue if set to true | ||
635 | * | 636 | * |
636 | * This function registers the partitioning information in @disk | 637 | * This function registers the partitioning information in @disk |
637 | * with the kernel. | 638 | * with the kernel. |
638 | * | 639 | * |
639 | * FIXME: error handling | 640 | * FIXME: error handling |
640 | */ | 641 | */ |
641 | void device_add_disk(struct device *parent, struct gendisk *disk) | 642 | static void __device_add_disk(struct device *parent, struct gendisk *disk, |
643 | bool register_queue) | ||
642 | { | 644 | { |
643 | dev_t devt; | 645 | dev_t devt; |
644 | int retval; | 646 | int retval; |
@@ -682,7 +684,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk) | |||
682 | exact_match, exact_lock, disk); | 684 | exact_match, exact_lock, disk); |
683 | } | 685 | } |
684 | register_disk(parent, disk); | 686 | register_disk(parent, disk); |
685 | blk_register_queue(disk); | 687 | if (register_queue) |
688 | blk_register_queue(disk); | ||
686 | 689 | ||
687 | /* | 690 | /* |
688 | * Take an extra ref on queue which will be put on disk_release() | 691 | * Take an extra ref on queue which will be put on disk_release() |
@@ -693,8 +696,19 @@ void device_add_disk(struct device *parent, struct gendisk *disk) | |||
693 | disk_add_events(disk); | 696 | disk_add_events(disk); |
694 | blk_integrity_add(disk); | 697 | blk_integrity_add(disk); |
695 | } | 698 | } |
699 | |||
700 | void device_add_disk(struct device *parent, struct gendisk *disk) | ||
701 | { | ||
702 | __device_add_disk(parent, disk, true); | ||
703 | } | ||
696 | EXPORT_SYMBOL(device_add_disk); | 704 | EXPORT_SYMBOL(device_add_disk); |
697 | 705 | ||
706 | void device_add_disk_no_queue_reg(struct device *parent, struct gendisk *disk) | ||
707 | { | ||
708 | __device_add_disk(parent, disk, false); | ||
709 | } | ||
710 | EXPORT_SYMBOL(device_add_disk_no_queue_reg); | ||
711 | |||
698 | void del_gendisk(struct gendisk *disk) | 712 | void del_gendisk(struct gendisk *disk) |
699 | { | 713 | { |
700 | struct disk_part_iter piter; | 714 | struct disk_part_iter piter; |