Skip to content

Commit 6783811

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: better split mq vs non-mq code in add_disk_fwnode
Add a big conditional for blk-mq vs not mq at the beginning of add_disk_fwnode so that elevator_init_mq is only called for blk-mq disks, and add checks that the right methods or set or not set based on the queue type. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent b7175e2 commit 6783811

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

block/genhd.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -400,21 +400,23 @@ int __must_check add_disk_fwnode(struct device *parent, struct gendisk *disk,
400400
struct device *ddev = disk_to_dev(disk);
401401
int ret;
402402

403-
/* Only makes sense for bio-based to set ->poll_bio */
404-
if (queue_is_mq(disk->queue) && disk->fops->poll_bio)
405-
return -EINVAL;
406-
407-
/*
408-
* The disk queue should now be all set with enough information about
409-
* the device for the elevator code to pick an adequate default
410-
* elevator if one is needed, that is, for devices requesting queue
411-
* registration.
412-
*/
413-
elevator_init_mq(disk->queue);
403+
if (queue_is_mq(disk->queue)) {
404+
/*
405+
* ->submit_bio and ->poll_bio are bypassed for blk-mq drivers.
406+
*/
407+
if (disk->fops->submit_bio || disk->fops->poll_bio)
408+
return -EINVAL;
414409

415-
/* Mark bdev as having a submit_bio, if needed */
416-
if (disk->fops->submit_bio)
410+
/*
411+
* Initialize the I/O scheduler code and pick a default one if
412+
* needed.
413+
*/
414+
elevator_init_mq(disk->queue);
415+
} else {
416+
if (!disk->fops->submit_bio)
417+
return -EINVAL;
417418
bdev_set_flag(disk->part0, BD_HAS_SUBMIT_BIO);
419+
}
418420

419421
/*
420422
* If the driver provides an explicit major number it also must provide

0 commit comments

Comments
 (0)