Xiubo Li cad4448dfc nbd: fix possible sysfs duplicate warning
[ Upstream commit 862488105b84ca744b3d8ff131e0fcfe10644be1 ]

1. nbd_put takes the mutex and drops nbd->ref to 0. It then does
idr_remove and drops the mutex.

2. nbd_genl_connect takes the mutex. idr_find/idr_for_each fails
to find an existing device, so it does nbd_dev_add.

3. just before the nbd_put could call nbd_dev_remove or not finished
totally, but if nbd_dev_add try to add_disk, we can hit:

debugfs: Directory 'nbd1' with parent 'block' already present!

This patch will make sure all the disk add/remove stuff are done
by holding the nbd_index_mutex lock.

Reported-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-06 13:06:07 +01:00
..
2019-09-06 10:21:57 +02:00
2019-09-21 07:17:14 +02:00
2018-05-11 15:08:03 -06:00
2018-06-12 16:19:22 -07:00
2017-02-20 12:16:15 +01:00
2017-08-18 08:45:29 -06:00
2018-11-13 11:08:20 -08:00
2018-06-12 16:19:22 -07:00