* [PATCH] block: ublk_drv: mark device as LIVE before adding disk
@ 2023-03-18 14:12 Ming Lei
2023-03-18 14:32 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2023-03-18 14:12 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei, Ziyang Zhang
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: 71f28f3136af ("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>
---
drivers/block/ublk_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index d1d1c8d606c8..fb5a557afde8 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -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);
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);
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block: ublk_drv: mark device as LIVE before adding disk
2023-03-18 14:12 [PATCH] block: ublk_drv: mark device as LIVE before adding disk Ming Lei
@ 2023-03-18 14:32 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-03-18 14:32 UTC (permalink / raw)
To: Ming Lei; +Cc: linux-block, Ziyang Zhang
On Sat, 18 Mar 2023 22:12:31 +0800, 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.
>
>
> [...]
Applied, thanks!
[1/1] block: ublk_drv: mark device as LIVE before adding disk
commit: 4985e7b2c002eb4c5c794a1d3acd91b82c89a0fd
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-18 14:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-18 14:12 [PATCH] block: ublk_drv: mark device as LIVE before adding disk Ming Lei
2023-03-18 14:32 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox