block: ublk: improve handling device deletion
authorMing Lei <ming.lei@redhat.com>
Tue, 7 Feb 2023 15:07:00 +0000 (23:07 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 8 Feb 2023 01:53:51 +0000 (18:53 -0700)
commit0abe39dec065133e3f92a52219c3728fe7d7617f
tree2b37840e4af5c58455bc63528bf5a60825255de9
parentf37bf75ca73d523ebaa7ceb44c45d8ecd05374fe
block: ublk: improve handling device deletion

Inside ublk_ctrl_del_dev(), when the device is removed, we wait
until the device number is freed with holding global lock of
ublk_ctl_mutex, this way isn't friendly from user viewpoint:

1) if device is in-use, the current delete command hangs in
ublk_ctrl_del_dev(), and user can't break from the handling
because wait_event() is used

2) global lock is held, so any new device can't be added and
other old devices can't be removed.

Improve the deleting handling by the following way, suggested by
Nadav:

1) wait without holding the global lock

2) replace wait_event() with wait_event_interruptible()

Reported-by: Nadav Amit <nadav.amit@gmail.com>
Suggested-by: Nadav Amit <nadav.amit@gmail.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230207150700.545530-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c