On 2019/09/03 18:02, Christoph Hellwig wrote: > 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. > OK. I will move the registration earlier in device_add_disk(), before the region registration. However, I would still like to keep the queue freeze to protect against buggy device drivers that call device_add_disk() with internal commands still going on. I do not think that there are any such driver, but just want to avoid problems. The queue freeze is also present for any user initiated elevator change, so in this respect, this is not any different and should not be a big problem. Thoughts ? -- Damien Le Moal Western Digital Research