On Wed, Aug 28, 2019 at 11:29:45AM +0900, Damien Le Moal wrote: > When elevator_init_mq() is called from blk_mq_init_allocated_queue(), > the only information known about the device is the number of hardware > queues as the block device scan by the device driver is not completed > yet. The device type and the device required features are not set yet, > preventing to correctly choose the default elevator most suitable for > the device. > > This currently affects all multi-queue zoned block devices which default > to the "none" elevator instead of the required "mq-deadline" elevator. > These drives currently include host-managed SMR disks connected to a > smartpqi HBA and null_blk block devices with zoned mode enabled. > Upcoming NVMe Zoned Namespace devices will also be affected. > > Fix this by moving the execution of elevator_init_mq() from > blk_mq_init_allocated_queue() into __device_add_disk() to allow for the > device driver to probe the device characteristics and set attributes > of the device request queue prior to the elevator initialization. > > Also to make sure that the elevator initialization is never done while > requests are in-flight (there should be none when the device driver > calls device_add_disk()), freeze and quiesce the device request queue > before executing blk_mq_init_sched(). So the disk can be accessed from userspace or partition probing once we registered the region. Based on that I think it would be better if we set the elevator a little earlier before that happens. With that we shouldn't have to freeze the queue.