On Tue, Oct 18, 2022 at 04:00:36PM +0800, Yu Kuai wrote: > 1) in del_gendisk: (add a new api kobject_put_and_test) > > if (kobject_put_and_test(bd_holder_dir/slave_dir)) > bd_holder_dir/slave_dir = NULL; > > 2) in bd_link_disk_holder, get bd_holder_dir first: > > if (!kobject_get_unless_zero(bd_holder_dir)) > return -ENODEV; > ... > bd_find_holder_disk() > > Do you think this is ok? I'm not quite sure what the point is. If you want to really clean this up a good thing would be to remove the delayed holder registration entirely and just do them in dm after add_disk and remove them before del_gendisk. I've been wanting to do that a few times but always gave up due to the mess in dm.