On Wed, Feb 08, 2023 at 07:35:14AM +0100, Christoph Hellwig wrote: > While del_gendisk ensures there is no outstanding I/O on the queue, > it can't prevent block layer users from building new I/O. > > This leads to a NULL ->root_blkg reference in bio_associate_blkg when > allocating a new bio on a shut down file system. Delay freeing the > blk-cgroup subsystems from del_gendisk until disk_release to make > sure the blkg and throttle information is still avaіlable for bio > submitters, even if those bios will immediately fail. > > This now can cause a case where disk_release is called on a disk > that hasn't been added. That's mostly harmless, except for a case > in blk_throttl_exit that now needs to check for a NULL ->td pointer. With this way, blkcg_init_disk() could be called before q->root_blkg is released in disk unbind & rebind use case, then memory leak? Thanks, Ming