On Thu, Sep 16, 2021 at 09:36:23AM +0800, Ming Lei wrote: > >From correctness viewpoint, we need to call blk_cleanup_queue > before releasing gendisk and after del_gendisk(). Now you have invented > blk_cleanup_disk(), do you plan to do the three in one helper? :-) No. In retrospective blk_cleanup_disk wan't the best idea for a few reasons. But at least it consolidated some of the code. > We don't have to put del_gendisk & blk_cleanup_queue together, I don't want all of it together. The important thing is that we have two different concepts: - the gendisk is required to do file system style I/O - a standalone request_queue can be used for passthrough I/O. > and it may cause other trouble at least for scsi disk since sd_shutdown() > follows del_gendisk() and has to be called before blk_cleanup_queue(). Yes. So we need to move the bits of blk_cleanup_queue that deal with the file system I/O state to del_gendisk, and keep blk_cleanup_queue for anything actually needed for the low-level queue. To take SCSI as the example. We can unload the sd/sr drivers and the queue needs to still be around and work for use with the sg driver. > BTW, you asked the reproducer of the issue, I just observed the issue > one or two time when running blktests block/009, but my scsi lifetime > bpftrace script does show that gendisk is released before blk_cleanup_queue(). Interesting. What were the symptoms in this case?