Skip to contentSkip to conversation

qemu-io: add zoned block device operations.

RFC Superseded Sam Li 2 participants 2 messages Aug 1, 2022 Block layer

v5 of 20 Superseded Latest is v20 →

lore
Share & tools
lore

Sam Li

author
#0 lore raw

RFC v5 9/11 qemu-io: add zoned block device operations.

Add zoned storage commands of the device: zone_report(zrp), zone_open(zo), zone_close(zc), zone_reset(zrs), zone_finish(zf).

For example, to test zone_report, use following command:

$ ./build/qemu-io --image-opts driver=zoned_host_device, filename=/dev/nullb0
-c "zrp offset nr_zones"
---
 block/io.c     |  24 ++-------
 qemu-io-cmds.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 20 deletions(-)
block/io.c +4 -20
index a4625fb0e1..de9ec1d740 100644
@@ -3209,19 +3209,11 @@ int bdrv_co_zone_report(BlockDriverState *bs, int64_t offset,
     IO_CODE();
 
     bdrv_inc_in_flight(bs);
-    if (!drv || (!drv->bdrv_co_zone_report)) {
+    if (!drv || !drv->bdrv_co_zone_report) {
         co.ret = -ENOTSUP;
         goto out;
     }
-
-    if (drv->bdrv_co_zone_report) {
-        co.ret = drv->bdrv_co_zone_report(bs, offset, nr_zones, zones);
-    } else {
-        co.ret = -ENOTSUP;
-        goto out;
-        qemu_coroutine_yield();
-    }
-
+    co.ret = drv->bdrv_co_zone_report(bs, offset, nr_zones, zones);
 out:
     bdrv_dec_in_flight(bs);
     return co.ret;
@@ -3237,19 +3229,11 @@ int bdrv_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op,
     IO_CODE();
 
     bdrv_inc_in_flight(bs);
-    if (!drv || (!drv->bdrv_co_zone_mgmt)) {
+    if (!drv || !drv->bdrv_co_zone_mgmt) {
         co.ret = -ENOTSUP;
         goto out;
     }
-
-    if (drv->bdrv_co_zone_mgmt) {
-        co.ret = drv->bdrv_co_zone_mgmt(bs, op, offset, len);
-    } else {
-        co.ret = -ENOTSUP;
-        goto out;
-        qemu_coroutine_yield();
-    }
-
+    co.ret = drv->bdrv_co_zone_mgmt(bs, op, offset, len);
 out:
     bdrv_dec_in_flight(bs);
     return co.ret;
qemu-io-cmds.c +144 -0

156 lines not on this page · raw message

Signature · 1 line
2.37.1
Reviewed-by on v5 9/11
#1 lore raw
Quoted 52 lines · Sam Li

Add zoned storage commands of the device: zone_report(zrp), zone_open(zo), zone_close(zc), zone_reset(zrs), zone_finish(zf).

For example, to test zone_report, use following command:

$ ./build/qemu-io --image-opts driver=zoned_host_device, filename=/dev/nullb0
-c "zrp offset nr_zones"
---
 block/io.c     |  24 ++-------
 qemu-io-cmds.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 20 deletions(-)
block/io.c +3 -14
index a4625fb0e1..de9ec1d740 100644
@@ -3209,19 +3209,11 @@ int bdrv_co_zone_report(BlockDriverState *bs, int64_t offset,
     IO_CODE();
 
     bdrv_inc_in_flight(bs);
-    if (!drv || (!drv->bdrv_co_zone_report)) {
+    if (!drv || !drv->bdrv_co_zone_report) {
         co.ret = -ENOTSUP;
         goto out;
     }
-
-    if (drv->bdrv_co_zone_report) {
-        co.ret = drv->bdrv_co_zone_report(bs, offset, nr_zones, zones);
-    } else {
-        co.ret = -ENOTSUP;
-        goto out;
-        qemu_coroutine_yield();
-    }
-
+    co.ret = drv->bdrv_co_zone_report(bs, offset, nr_zones, zones);
 out:
     bdrv_dec_in_flight(bs);
     return co.ret;
@@ -3237,19 +3229,11 @@ int bdrv_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op,
     IO_CODE();
 
     bdrv_inc_in_flight(bs);
-    if (!drv || (!drv->bdrv_co_zone_mgmt)) {
+    if (!drv || !drv->bdrv_co_zone_mgmt) {
         co.ret = -ENOTSUP;
         goto out;
     }
-
-    if (drv->bdrv_co_zone_mgmt) {
-        co.ret = drv->bdrv_co_zone_mgmt(bs, op, offset, len);

block/io.c int bdrv_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op, · line 3239

Quoted 10 lines
block/io.c +1 -6
-    } else {
-        co.ret = -ENOTSUP;
-        goto out;
-        qemu_coroutine_yield();
-    }
-
+    co.ret = drv->bdrv_co_zone_mgmt(bs, op, offset, len);
 out:
     bdrv_dec_in_flight(bs);
     return co.ret;

Please squash these changes into the earlier patch that introduced these functions.

Otherwise: