]> git.baikalelectronics.ru Git - kernel.git/commit
dm: track per-add_disk holder relations in DM
authorChristoph Hellwig <hch@lst.de>
Tue, 15 Nov 2022 14:10:50 +0000 (22:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:12 +0000 (13:32 +0100)
commite657d8efc3cfb4d3b875b2a9698edd108b170ecd
treed4ecbfe1d2568dae099a49c9273524ee27020553
parent8f77aacb1cf669a74d77d287c70f67ce23c20335
dm: track per-add_disk holder relations in DM

[ Upstream commit 850af5d876bb2ea777a9d08c3e00082e41bafcf9 ]

dm is a bit special in that it opens the underlying devices.  Commit
b163a39cc64d ("dm: delay registering the gendisk") tried to accommodate
that by allowing to add the holder to the list before add_gendisk and
then just add them to sysfs once add_disk is called.  But that leads to
really odd lifetime problems and error handling problems as we can't
know the state of the kobjects and don't unwind properly.  To fix this
switch to just registering all existing table_devices with the holder
code right after add_disk, and remove them before calling del_gendisk.

Fixes: b163a39cc64d ("dm: delay registering the gendisk")
Reported-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Link: https://lore.kernel.org/r/20221115141054.1051801-7-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm.c