Message ID | 20230301140611.163055-11-ming.lei@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | io_uring: add IORING_OP_FUSED_CMD | expand |
On 2023/3/1 22:06, Ming Lei wrote: > 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. > > Signed-off-by: Ming Lei <ming.lei@redhat.com> > --- Reviewed-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index c89ede1c9b22..2497b91b48ba 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1608,17 +1608,18 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) set_bit(GD_SUPPRESS_PART_SCAN, &disk->state); get_device(&ub->cdev_dev); + ub->dev_info.state = UBLK_S_DEV_LIVE; ret = add_disk(disk); if (ret) { /* * Has to drop the reference since ->free_disk won't be * called in case of add_disk failure. */ + ub->dev_info.state = UBLK_S_DEV_DEAD; ublk_put_device(ub); goto out_put_disk; } set_bit(UB_STATE_USED, &ub->state); - ub->dev_info.state = UBLK_S_DEV_LIVE; out_put_disk: if (ret) put_disk(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. Signed-off-by: Ming Lei <ming.lei@redhat.com> --- drivers/block/ublk_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)