Skip to content

Commit 4985e7b

Browse files
Ming Leiaxboe
authored andcommitted
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: 71f28f3 ("ublk_drv: add io_uring based userspace block driver") Reviewed-by: Ziyang Zhang <[email protected]> Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 8f0d196 commit 4985e7b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/block/ublk_drv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,17 +1602,18 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
16021602
set_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
16031603

16041604
get_device(&ub->cdev_dev);
1605+
ub->dev_info.state = UBLK_S_DEV_LIVE;
16051606
ret = add_disk(disk);
16061607
if (ret) {
16071608
/*
16081609
* Has to drop the reference since ->free_disk won't be
16091610
* called in case of add_disk failure.
16101611
*/
1612+
ub->dev_info.state = UBLK_S_DEV_DEAD;
16111613
ublk_put_device(ub);
16121614
goto out_put_disk;
16131615
}
16141616
set_bit(UB_STATE_USED, &ub->state);
1615-
ub->dev_info.state = UBLK_S_DEV_LIVE;
16161617
out_put_disk:
16171618
if (ret)
16181619
put_disk(disk);

0 commit comments

Comments
 (0)