On Sat, Apr 23, 2022 at 06:29:37PM +0200, Christoph Hellwig wrote: > On Sat, Apr 23, 2022 at 10:39:52PM +0800, Ming Lei wrote: > > q->debugfs_dir is used by blk-mq debugfs and blktrace. The dentry is > > created when adding disk, and removed when releasing request queue. > > > > There is small window between releasing disk and releasing request > > queue, and during the period, one disk with same name may be created > > and added, so debugfs_create_dir() may complain with "Directory XXXXX > > with parent 'block' already present!" > > > > Fixes the issue by moving debugfs_create_dir() into blk_alloc_queue(), > > and the dir name is named with q->id from beginning, and switched to > > disk name when adding disk, and finally changed to q->id in disk_release(). > > As said before I very much think this is going in the wrong direction. So far I'd suggest to keep q->debugfs_dir inside request queue, another goodness is that we can use it for exposing non-blk qeueue's debug info, and there is request queue without gendisk attached. > > As the debugfs directory use the name of the gendisk, the lifetime rules > should simply match those of the gendisk. If anyone wants to trace > SCSI commands sent before probing the gendisk or after removing it > they can use blktrace on the /dev/sg node. Not sure blktrace can trace on /dev/sg since blktrace works on block_device. Thanks, Ming