mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
block: bd_link_disk_holder() should hold on to holder_dir
The new implementation of bd_link_disk_holder() added by 49731baa41
(block: restore multiple bd_link_disk_holder() support) didn't get an
extra reference for the holder_dir kobject of the slave bdev; however,
bdev kills holder_dir on removal, not release, so if the slave bdev is
removed while there are holder links, the holder_dir will be destroyed
while there still are holder links, which leads to oops later when
bd_unlink_disk_order() tries to remove those links.
Make bd_link_disk_holder() grab an extra reference for the slave's
holder_dir and put it in bd_unlink_disk_holder().
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: "Hawrylewicz Czarnowski, Przemyslaw" <przemyslaw.hawrylewicz.czarnowski@intel.com>
Tested-by: "Hawrylewicz Czarnowski, Przemyslaw" <przemyslaw.hawrylewicz.czarnowski@intel.com>
Cc: Neil Brown <neilb@suse.de>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8074b26f67
commit
e7407d1619
@ -873,6 +873,11 @@ int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk)
|
||||
ret = add_symlink(bdev->bd_part->holder_dir, &disk_to_dev(disk)->kobj);
|
||||
if (ret)
|
||||
goto out_del;
|
||||
/*
|
||||
* bdev could be deleted beneath us which would implicitly destroy
|
||||
* the holder directory. Hold on to it.
|
||||
*/
|
||||
kobject_get(bdev->bd_part->holder_dir);
|
||||
|
||||
list_add(&holder->list, &bdev->bd_holder_disks);
|
||||
goto out_unlock;
|
||||
@ -909,6 +914,7 @@ void bd_unlink_disk_holder(struct block_device *bdev, struct gendisk *disk)
|
||||
del_symlink(disk->slave_dir, &part_to_dev(bdev->bd_part)->kobj);
|
||||
del_symlink(bdev->bd_part->holder_dir,
|
||||
&disk_to_dev(disk)->kobj);
|
||||
kobject_put(bdev->bd_part->holder_dir);
|
||||
list_del_init(&holder->list);
|
||||
kfree(holder);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user