mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
block: ublk_drv: mark device as LIVE before adding disk
IO can be started before add_disk() returns, such as reading parititon table,
then the monitor work should work for making forward progress.
So mark device as LIVE before adding disk, meantime change to
DEAD if add_disk() fails.
Fixed: 71f28f3136
("ublk_drv: add io_uring based userspace block driver")
Reviewed-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230318141231.55562-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
8f0d196e4d
commit
4985e7b2c0
1 changed files with 2 additions and 1 deletions
|
@ -1602,17 +1602,18 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
|
||||||
set_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
|
set_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
|
||||||
|
|
||||||
get_device(&ub->cdev_dev);
|
get_device(&ub->cdev_dev);
|
||||||
|
ub->dev_info.state = UBLK_S_DEV_LIVE;
|
||||||
ret = add_disk(disk);
|
ret = add_disk(disk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/*
|
/*
|
||||||
* Has to drop the reference since ->free_disk won't be
|
* Has to drop the reference since ->free_disk won't be
|
||||||
* called in case of add_disk failure.
|
* called in case of add_disk failure.
|
||||||
*/
|
*/
|
||||||
|
ub->dev_info.state = UBLK_S_DEV_DEAD;
|
||||||
ublk_put_device(ub);
|
ublk_put_device(ub);
|
||||||
goto out_put_disk;
|
goto out_put_disk;
|
||||||
}
|
}
|
||||||
set_bit(UB_STATE_USED, &ub->state);
|
set_bit(UB_STATE_USED, &ub->state);
|
||||||
ub->dev_info.state = UBLK_S_DEV_LIVE;
|
|
||||||
out_put_disk:
|
out_put_disk:
|
||||||
if (ret)
|
if (ret)
|
||||||
put_disk(disk);
|
put_disk(disk);
|
||||||
|
|
Loading…
Reference in a new issue