dm: make sure create and remove dm device won't race with open and close table
authorYu Kuai <yukuai3@huawei.com>
Tue, 15 Nov 2022 14:10:49 +0000 (22:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:12 +0000 (13:32 +0100)
commitce65ef11d37e8342f17e7c822c43a2ff9317c016
tree4bba954f8c07d1f192c43f38a2d576541f7e03ef
parent365c351efd4a34c139dcb40fd6519f1521d94db0
dm: make sure create and remove dm device won't race with open and close table

[ Upstream commit d563792c8933a810d28ce0f2831f0726c2b15a31 ]

open_table_device() and close_table_device() is protected by
table_devices_lock, hence use it to protect add_disk() and
del_gendisk().

Prepare to track per-add_disk holder relations in dm.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20221115141054.1051801-6-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 1a581b721699 ("dm: track per-add_disk holder relations in DM")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm.c