Block patches
Subsystems (3)
The following changes since commit 05d50ba2d4668d43a835c5a502efdec9b92646e6:
Merge tag 'migration-20230427-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-04-28 08:35:06 +0100)
are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to d3c760be786571d83d5cea01953e543df4d76f51:
docs/zoned-storage:add zoned emulation use case (2023-04-28 08:34:07 -0400)
----------------------------------------------------------------
Pull request
This pull request contains Sam Li's virtio-blk zoned storage work. These patches were dropped from my previous block pull request due to CI failures.
----------------------------------------------------------------
Sam Li (17):
block/block-common: add zoned device structs block/file-posix: introduce helper functions for sysfs attributes block/block-backend: add block layer APIs resembling Linux
ZonedBlockDevice ioctls
block/raw-format: add zone operations to pass through requests
block: add zoned BlockDriver check to block layer
iotests: test new zone operations
block: add some trace events for new block layer APIs docs/zoned-storage: add zoned device documentation
file-posix: add tracking of the zone write pointers
block: introduce zone append write for zoned devices
qemu-iotests: test zone append operation
block: add some trace events for zone append
include: update virtio_blk headers to v6.3-rc1
virtio-blk: add zoned storage emulation for zoned devices
block: add accounting for zone append operation
virtio-blk: add some trace events for zoned emulation docs/zoned-storage:add zoned emulation use case
docs/devel/index-api.rst | 1 + docs/devel/zoned-storage.rst | 62 ++ qapi/block-core.json | 68 +- qapi/block.json | 4 + meson.build | 4 + include/block/accounting.h | 1 + include/block/block-common.h | 57 ++ include/block/block-io.h | 13 + include/block/block_int-common.h | 37 + include/block/raw-aio.h | 8 +- include/standard-headers/drm/drm_fourcc.h | 12 + include/standard-headers/linux/ethtool.h | 48 +- include/standard-headers/linux/fuse.h | 45 +- include/standard-headers/linux/pci_regs.h | 1 + include/standard-headers/linux/vhost_types.h | 2 + include/standard-headers/linux/virtio_blk.h | 105 +++ include/sysemu/block-backend-io.h | 27 + linux-headers/asm-arm64/kvm.h | 1 + linux-headers/asm-x86/kvm.h | 34 +- linux-headers/linux/kvm.h | 9 + linux-headers/linux/vfio.h | 15 +- linux-headers/linux/vhost.h | 8 + block.c | 19 + block/block-backend.c | 198 ++++++ block/file-posix.c | 696 +++++++++++++++++-- block/io.c | 68 ++ block/io_uring.c | 4 + block/linux-aio.c | 3 + block/qapi-sysemu.c | 11 + block/qapi.c | 18 + block/raw-format.c | 26 + hw/block/virtio-blk-common.c | 2 + hw/block/virtio-blk.c | 405 +++++++++++ hw/virtio/virtio-qmp.c | 2 + qemu-io-cmds.c | 224 ++++++ block/trace-events | 4 + docs/system/qemu-block-drivers.rst.inc | 6 + hw/block/trace-events | 7 + tests/qemu-iotests/tests/zoned | 105 +++ tests/qemu-iotests/tests/zoned.out | 69 ++ 40 files changed, 2361 insertions(+), 68 deletions(-) create mode 100644 docs/devel/zoned-storage.rst create mode 100755 tests/qemu-iotests/tests/zoned create mode 100644 tests/qemu-iotests/tests/zoned.out
Signature · 1 line
2.40.0
[PULL 01/17] block/block-common: add zoned device structs
From: Sam Li <[email protected]>
Message-id: [email protected]
Message-id: [email protected] [Adjust commit message prefix as suggested by Philippe Mathieu-Daudé <[email protected]>.
--Stefan]
--- include/block/block-common.h | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
include/block/block-common.h +43 -0
@@ -75,6 +75,49 @@ typedef struct BlockDriver BlockDriver;typedef struct BdrvChild BdrvChild ;typedef struct BdrvChildClass BdrvChildClass ; +typedef enum BlockZoneOp { +BLK_ZO_OPEN , +BLK_ZO_CLOSE , +BLK_ZO_FINISH , +BLK_ZO_RESET , +}BlockZoneOp ; + +typedef enum BlockZoneModel { +BLK_Z_NONE =0x0 ,/* Regular block device */ +BLK_Z_HM =0x1 ,/* Host-managed zoned block device */ +BLK_Z_HA =0x2 ,/* Host-aware zoned block device */ +}BlockZoneModel ; + +typedef enum BlockZoneState { +BLK_ZS_NOT_WP =0x0 , +BLK_ZS_EMPTY =0x1 , +BLK_ZS_IOPEN =0x2 , +BLK_ZS_EOPEN =0x3 , +BLK_ZS_CLOSED =0x4 , +BLK_ZS_RDONLY =0xD , +BLK_ZS_FULL =0xE , +BLK_ZS_OFFLINE =0xF , +}BlockZoneState ; + +typedef enum BlockZoneType { +BLK_ZT_CONV =0x1 ,/* Conventional random writes supported */ +BLK_ZT_SWR =0x2 ,/* Sequential writes required */ +BLK_ZT_SWP =0x3 ,/* Sequential writes preferred */ +}BlockZoneType ; + +/* +* Zone descriptor data structure. +* Provides information on a zone with all position and size values in bytes. +*/ +typedef struct BlockZoneDescriptor { +uint64_t start; +uint64_t length; +uint64_t cap; +uint64_t wp; +BlockZoneType type; +BlockZoneState state; +}BlockZoneDescriptor ; + typedef struct BlockDriverInfo { /* in bytes, 0 if irrelevant */ int cluster_size;
Signature · 1 line
2.40.0
[PULL 02/17] block/file-posix: introduce helper functions for sysfs attributes
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Use get_sysfs_str_val() to get the string value of device zoned model. Then get_sysfs_zoned_model() can convert it to BlockZoneModel type of QEMU.
Use get_sysfs_long_val() to get the long value of zoned device information.
Message-id: [email protected]
Message-id: [email protected] [Adjust commit message prefix as suggested by Philippe Mathieu-Daudé <[email protected]>.
--Stefan]
--- include/block/block_int-common.h | 3 + block/file-posix.c | 139 ++++++++++++++++++++++--------- 2 files changed, 104 insertions(+), 38 deletions(-)
include/block/block_int-common.h +3 -0
@@ -861,6 +861,9 @@ typedef struct BlockLimits {* an explicit monitor command to load the disk inside the guest). */ bool has_variable_length; + +/* device zone model */ +BlockZoneModel zoned; } BlockLimits;typedef struct BdrvOpBlocker BdrvOpBlocker ;
block/file-posix.c +101 -38
166 lines not on this page · raw message
Signature · 1 line
2.40.0
[PULL 03/17] block/block-backend: add block layer APIs resembling Linux ZonedBlockDevice ioctls
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Add zoned device option to host_device BlockDriver. It will be presented only for zoned host block devices. By adding zone management operations to the host_block_device BlockDriver, users can use the new block layer APIs including Report Zone and four zone management operations
(open, close, finish, reset, reset_all).
Qemu-io uses the new APIs to perform 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 -n driver=host_device, filename=/dev/nullb0 -c "zrp offset nr_zones"
Message-id: [email protected]
Message-id: [email protected] [Adjust commit message prefix as suggested by Philippe Mathieu-Daudé <[email protected]> and remove spurious ret = -errno in raw_co_zone_mgmt().
--Stefan]
--- meson.build | 4 + include/block/block-io.h | 9 + include/block/block_int-common.h | 21 ++ include/block/raw-aio.h | 6 +- include/sysemu/block-backend-io.h | 18 ++ block/block-backend.c | 137 +++++++++++++ block/file-posix.c | 313 +++++++++++++++++++++++++++++- block/io.c | 41 ++++ qemu-io-cmds.c | 149 ++++++++++++++ 9 files changed, 695 insertions(+), 3 deletions(-)
meson.build +4 -0
@@ -1966,6 +1966,7 @@ config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed()) # has_header config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h')) config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h')) +config_host_data.set('CONFIG_BLKZONED', cc.has_header('linux/blkzoned.h')) config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h')) config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h')) config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
@@ -2052,6 +2053,9 @@ config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID', config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM', cc.has_member('struct stat', 'st_atim', prefix: '#include <sys/stat.h>')) +config_host_data.set('HAVE_BLK_ZONE_REP_CAPACITY', + cc.has_member('struct blk_zone', 'capacity', + prefix: '#include <linux/blkzoned.h>')) # has_type config_host_data.set('CONFIG_IOVEC',
include/block/block-io.h +9 -0
@@ -111,6 +111,15 @@ int coroutine_fn GRAPH_RDLOCK bdrv_co_flush(BlockDriverState *bs); int coroutine_fn GRAPH_RDLOCK bdrv_co_pdiscard(BdrvChild *child, int64_t offset,int64_t bytes); +/* Report zone information of zone block device. */ +int coroutine_fn GRAPH_RDLOCK bdrv_co_zone_report(BlockDriverState *bs, +int64_t offset, +unsigned int *nr_zones, +BlockZoneDescriptor *zones); +int coroutine_fn GRAPH_RDLOCK bdrv_co_zone_mgmt(BlockDriverState *bs, +BlockZoneOp op, +int64_t offset,int64_t len); +bool bdrv_can_write_zeroes_with_unmap (BlockDriverState *bs); int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map,
include/block/block_int-common.h +21 -0
@@ -712,6 +712,12 @@ struct BlockDriver { int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_load_vmstate)(BlockDriverState *bs,QEMUIOVector *qiov,int64_t pos); + int coroutine_fn (*bdrv_co_zone_report)(BlockDriverState *bs, +int64_t offset,unsigned int *nr_zones, +BlockZoneDescriptor *zones); + int coroutine_fn (*bdrv_co_zone_mgmt)(BlockDriverState *bs, BlockZoneOp op, +int64_t offset,int64_t len); +/* removable device specific */ bool coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_is_inserted)( BlockDriverState *bs);
@@ -864,6 +870,21 @@ typedef struct BlockLimits {/* device zone model */ BlockZoneModel zoned; + +/* zone size expressed in bytes */ +uint32_t zone_size; + +/* total number of zones */ +uint32_t nr_zones; + +/* maximum sectors of a zone append write operation */ +int64_t max_append_sectors; + +/* maximum number of open zones */ +int64_t max_open_zones; + +/* maximum number of active zones */ +int64_t max_active_zones; } BlockLimits;typedef struct BdrvOpBlocker BdrvOpBlocker ;
include/block/raw-aio.h +5 -1
@@ -28,6 +28,8 @@#define QEMU_AIO_WRITE_ZEROES 0x0020#define QEMU_AIO_COPY_RANGE 0x0040#define QEMU_AIO_TRUNCATE 0x0080 +#define QEMU_AIO_ZONE_REPORT 0x0100 +#define QEMU_AIO_ZONE_MGMT 0x0200#define QEMU_AIO_TYPE_MASK \ (QEMU_AIO_READ | \ QEMU_AIO_WRITE | \
@@ -36,7 +38,9 @@ QEMU_AIO_DISCARD | \ QEMU_AIO_WRITE_ZEROES | \ QEMU_AIO_COPY_RANGE | \ - QEMU_AIO_TRUNCATE) + QEMU_AIO_TRUNCATE | \ + QEMU_AIO_ZONE_REPORT | \ + QEMU_AIO_ZONE_MGMT)/* AIO flags */ #define QEMU_AIO_MISALIGNED 0x1000
include/sysemu/block-backend-io.h +18 -0
@@ -46,6 +46,13 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset, BlockCompletionFunc *cb, void *opaque);BlockAIOCB *blk_aio_flush (BlockBackend *blk,BlockCompletionFunc *cb,void *opaque); +BlockAIOCB *blk_aio_zone_report (BlockBackend *blk,int64_t offset, +unsigned int *nr_zones, +BlockZoneDescriptor *zones, +BlockCompletionFunc *cb,void *opaque); +BlockAIOCB *blk_aio_zone_mgmt (BlockBackend *blk,BlockZoneOp op, +int64_t offset,int64_t len, +BlockCompletionFunc *cb,void *opaque);BlockAIOCB *blk_aio_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes,BlockCompletionFunc *cb,void *opaque);void blk_aio_cancel_async (BlockAIOCB *acb);
@@ -191,6 +198,17 @@ int co_wrapper_mixed blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,int64_t bytes,BdrvRequestFlags flags); +int coroutine_fn blk_co_zone_report(BlockBackend *blk, int64_t offset, +unsigned int *nr_zones, +BlockZoneDescriptor *zones); +int co_wrapper_mixed blk_zone_report(BlockBackend *blk, int64_t offset, +unsigned int *nr_zones, +BlockZoneDescriptor *zones); +int coroutine_fn blk_co_zone_mgmt(BlockBackend *blk, BlockZoneOp op, +int64_t offset,int64_t len); +int co_wrapper_mixed blk_zone_mgmt(BlockBackend *blk, BlockZoneOp op, +int64_t offset,int64_t len); + int co_wrapper_mixed blk_pdiscard(BlockBackend *blk, int64_t offset,int64_t bytes); int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,
block/block-backend.c +137 -0
143 lines not on this page · raw message
block/file-posix.c +311 -2
375 lines not on this page · raw message
block/io.c +41 -0
47 lines not on this page · raw message
qemu-io-cmds.c +149 -0
161 lines not on this page · raw message
Signature · 1 line
2.40.0
[PULL 05/17] block: add zoned BlockDriver check to block layer
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Putting zoned/non-zoned BlockDrivers on top of each other is not allowed.
Message-id: [email protected]
Message-id: [email protected] [Adjust commit message prefix as suggested by Philippe Mathieu-Daudé <[email protected]> and clarify that the check is about zoned BlockDrivers.
--Stefan]
--- include/block/block_int-common.h | 5 +++++ block.c | 19 +++++++++++++++++++ block/file-posix.c | 12 ++++++++++++ block/raw-format.c | 1 + 4 files changed, 37 insertions(+)
include/block/block_int-common.h +5 -0
@@ -137,6 +137,11 @@ struct BlockDriver {*/ bool is_format; +/* +* Set to true if the BlockDriver supports zoned children. +*/ +bool supports_zoned_children; +/* * Drivers not implementing bdrv_parse_filename nor bdrv_open should have * this field set to true, except ones that are defined only by their
block.c +19 -0
@@ -7967,6 +7967,25 @@ void bdrv_add_child(BlockDriverState *parent_bs, BlockDriverState *child_bs,return ; } +/* +* Non-zoned block drivers do not follow zoned storage constraints +* (i.e. sequential writes to zones). Refuse mixing zoned and non-zoned +* drivers in a graph. +*/ +if (!parent_bs->drv->supports_zoned_children && + child_bs->bl.zoned ==BLK_Z_HM ) { +/* +* The host-aware model allows zoned storage constraints and random +* write. Allow mixing host-aware and non-zoned drivers. Using +* host-aware device as a regular device. +*/ +error_setg (errp,"Cannot add a %s child to a %s parent" , + child_bs->bl.zoned ==BLK_Z_HM ?"zoned" :"non-zoned" , + parent_bs->drv->supports_zoned_children ? +"support zoned children" :"not support zoned children" ); +return ; + } +if (!QLIST_EMPTY (&child_bs->parents)) {error_setg (errp,"The node %s already has a parent" , child_bs->node_name);
block/file-posix.c +12 -0
@@ -776,6 +776,18 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, goto fail; } } +#ifdef CONFIG_BLKZONED +/* +* The kernel page cache does not reliably work for writes to SWR zones +* of zoned block device because it can not guarantee the order of writes. +*/ +if ((bs->bl.zoned !=BLK_Z_NONE ) && + (!(s->open_flags &O_DIRECT ))) { +error_setg (errp,"The driver supports zoned devices, and it requires " +"cache.direct=on, which was not specified." ); +return -EINVAL ;/* No host kernel page cache */ + } +#endif if (S_ISBLK (st.st_mode)) {#ifdef __linux__
block/raw-format.c +1 -0
@@ -623,6 +623,7 @@ static void raw_child_perm(BlockDriverState *bs, BdrvChild *c,BlockDriver bdrv_raw = { .format_name ="raw" , .instance_size =sizeof (BDRVRawState), + .supports_zoned_children = true, .bdrv_probe = &raw_probe, .bdrv_reopen_prepare = &raw_reopen_prepare, .bdrv_reopen_commit = &raw_reopen_commit,
Signature · 1 line
2.40.0
[PULL 04/17] block/raw-format: add zone operations to pass through requests
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
raw-format driver usually sits on top of file-posix driver. It needs to pass through requests of zone commands.
Message-id: [email protected]
Message-id: [email protected] [Adjust commit message prefix as suggested by Philippe Mathieu-Daudé <[email protected]>.
--Stefan]
--- block/raw-format.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
block/raw-format.c +17 -0
@@ -317,6 +317,21 @@ raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)return bdrv_co_pdiscard (bs->file, offset, bytes); } +static int coroutine_fn GRAPH_RDLOCK +raw_co_zone_report (BlockDriverState *bs,int64_t offset, +unsigned int *nr_zones, +BlockZoneDescriptor *zones) +{ +return bdrv_co_zone_report (bs->file->bs, offset, nr_zones, zones); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_zone_mgmt (BlockDriverState *bs,BlockZoneOp op, +int64_t offset,int64_t len) +{ +return bdrv_co_zone_mgmt (bs->file->bs, op, offset, len); +} + static int64_t coroutine_fn GRAPH_RDLOCKraw_co_getlength (BlockDriverState *bs) {
@@ -619,6 +634,8 @@ BlockDriver bdrv_raw = { .bdrv_co_pwritev = &raw_co_pwritev, .bdrv_co_pwrite_zeroes = &raw_co_pwrite_zeroes, .bdrv_co_pdiscard = &raw_co_pdiscard, + .bdrv_co_zone_report = &raw_co_zone_report, + .bdrv_co_zone_mgmt = &raw_co_zone_mgmt, .bdrv_co_block_status = &raw_co_block_status, .bdrv_co_copy_range_from = &raw_co_copy_range_from, .bdrv_co_copy_range_to = &raw_co_copy_range_to,
Signature · 1 line
2.40.0
[PULL 07/17] block: add some trace events for new block layer APIs
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Message-id: [email protected]
Message-id: [email protected]
--- block/file-posix.c | 3 +++ block/trace-events | 2 ++ 2 files changed, 5 insertions(+)
block/file-posix.c +3 -0
@@ -3271,6 +3271,7 @@ static int coroutine_fn raw_co_zone_report(BlockDriverState *bs, int64_t offset, }, }; +trace_zbd_zone_report (bs, *nr_zones, offset >>BDRV_SECTOR_BITS );return raw_thread_pool_submit (handle_aiocb_zone_report, &acb); }#endif
@@ -3337,6 +3338,8 @@ static int coroutine_fn raw_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op, }, }; +trace_zbd_zone_mgmt (bs, op_name, offset >>BDRV_SECTOR_BITS , + len >>BDRV_SECTOR_BITS ); ret =raw_thread_pool_submit (handle_aiocb_zone_mgmt, &acb);if (ret !=0 ) {error_report ("ioctl %s failed %d" , op_name, ret);
block/trace-events +2 -0
@@ -209,6 +209,8 @@ file_FindEjectableOpticalMedia(const char *media) "Matching using %s" file_setup_cdrom(const char *partition) "Using %s as optical disc" file_hdev_is_sg(int type, int version) "SG device found: type=%d, version=%d" file_flush_fdatasync_failed(int err) "errno %d" +zbd_zone_report(void *bs, unsigned int nr_zones, int64_t sector) "bs %p report %d zones starting at sector offset 0x%" PRIx64 "" +zbd_zone_mgmt(void *bs, const char *op_name, int64_t sector, int64_t len) "bs %p %s starts at sector offset 0x%" PRIx64 " over a range of 0x%" PRIx64 " sectors" # ssh.c sftp_error(const char *op, const char *ssh_err, int ssh_err_code, int sftp_err_code) "%s failed: %s (libssh error code: %d, sftp error code: %d)"
Signature · 1 line
2.40.0
[PULL 08/17] docs/zoned-storage: add zoned device documentation
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Add the documentation about the zoned device support to virtio-blk emulation.
Message-id: [email protected]
Message-id: [email protected] [Add index-api.rst to fix "zoned-storage.rst:document isn't included in any toctree" error and fix pre-formatted command-line indentation. --Stefan]
--- docs/devel/index-api.rst | 1 + docs/devel/zoned-storage.rst | 43 ++++++++++++++++++++++++++ docs/system/qemu-block-drivers.rst.inc | 6 ++++ 3 files changed, 50 insertions(+) create mode 100644 docs/devel/zoned-storage.rst
docs/devel/index-api.rst +1 -0
@@ -12,3 +12,4 @@ generated from in-code annotations to function prototypes. memory modules ui + zoned-storage
docs/devel/zoned-storage.rst new file +43 -0
43 lines not on this page · raw message
docs/system/qemu-block-drivers.rst.inc +6 -0
@@ -430,6 +430,12 @@ Hard disks you may corrupt your host data (use the ``-snapshot`` command line option or modify the device permissions accordingly). +Zoned block devices + Zoned block devices can be passed through to the guest if the emulated storage + controller supports zoned storage. Use ``--blockdev host_device, + node-name=drive0,filename=/dev/nullb0,cache.direct=on`` to pass through + ``/dev/nullb0`` as ``drive0``. + Windows ^^^^^^^
Signature · 1 line
2.40.0
[PULL 06/17] iotests: test new zone operations
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
The new block layer APIs of zoned block devices can be tested by:
$ tests/qemu-iotests/check zoned Run each zone operation on a newly created null_blk device and see whether it outputs the same zone information.
Message-id: [email protected]
Message-id: [email protected] [Adjust commit message prefix as suggested by Philippe Mathieu-Daudé <[email protected]>.
--Stefan]
--- tests/qemu-iotests/tests/zoned | 89 ++++++++++++++++++++++++++++++ tests/qemu-iotests/tests/zoned.out | 53 ++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100755 tests/qemu-iotests/tests/zoned create mode 100644 tests/qemu-iotests/tests/zoned.out
tests/qemu-iotests/tests/zoned new file +89 -0
@@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# +# Test zone management operations. +# + +seq="$(basename $0)" +echo "QA output created by $seq" +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + sudo -n rmmod null_blk +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ../common.rc +. ../common.filter +. ../common.qemu + +# This test only runs on Linux hosts with raw image files. +_supported_fmt raw +_supported_proto file +_supported_os Linux + +sudo -n true || \ + _notrun 'Password-less sudo required' + +IMG="--image-opts -n driver=host_device,filename=/dev/nullb0" +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT + +echo "Testing a null_blk device:" +echo "case 1: if the operations work" +sudo -n modprobe null_blk nr_devices=1 zoned=1 +sudo -n chmod 0666 /dev/nullb0 + +echo "(1) report the first zone:" +$QEMU_IO $IMG -c "zrp 0 1" +echo +echo "report the first 10 zones" +$QEMU_IO $IMG -c "zrp 0 10" +echo +echo "report the last zone:" +$QEMU_IO $IMG -c "zrp 0x3e70000000 2" # 0x3e70000000 / 512 = 0x1f380000 +echo +echo +echo "(2) opening the first zone" +$QEMU_IO $IMG -c "zo 0 268435456" # 268435456 / 512 = 524288 +echo "report after:" +$QEMU_IO $IMG -c "zrp 0 1" +echo +echo "opening the second zone" +$QEMU_IO $IMG -c "zo 268435456 268435456" # +echo "report after:" +$QEMU_IO $IMG -c "zrp 268435456 1" +echo +echo "opening the last zone" +$QEMU_IO $IMG -c "zo 0x3e70000000 268435456" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0x3e70000000 2" +echo +echo +echo "(3) closing the first zone" +$QEMU_IO $IMG -c "zc 0 268435456" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0 1" +echo +echo "closing the last zone" +$QEMU_IO $IMG -c "zc 0x3e70000000 268435456" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0x3e70000000 2" +echo +echo +echo "(4) finishing the second zone" +$QEMU_IO $IMG -c "zf 268435456 268435456" +echo "After finishing a zone:" +$QEMU_IO $IMG -c "zrp 268435456 1" +echo +echo +echo "(5) resetting the second zone" +$QEMU_IO $IMG -c "zrs 268435456 268435456" +echo "After resetting a zone:" +$QEMU_IO $IMG -c "zrp 268435456 1" + +# success, all done +echo "*** done" +rm -f $seq.full +status=0
tests/qemu-iotests/tests/zoned.out new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.40.0
[PULL 09/17] file-posix: add tracking of the zone write pointers
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Since Linux doesn't have a user API to issue zone append operations to zoned devices from user space, the file-posix driver is modified to add zone append emulation using regular writes. To do this, the file-posix driver tracks the wp location of all zones of the device. It uses an array of uint64_t. The most significant bit of each wp location indicates if the zone type is conventional zones.
The zones wp can be changed due to the following operations issued:
- zone reset: change the wp to the start offset of that zone
- zone finish: change to the end location of that zone
- write to a zone
- zone append
Message-id: [email protected] [Fix errno propagation from handle_aiocb_zone_mgmt() --Stefan]
--- include/block/block-common.h | 14 +++ include/block/block_int-common.h | 5 + block/file-posix.c | 178 ++++++++++++++++++++++++++++++- 3 files changed, 193 insertions(+), 4 deletions(-)
include/block/block-common.h +14 -0
@@ -118,6 +118,14 @@ typedef struct BlockZoneDescriptor {BlockZoneState state; } BlockZoneDescriptor; +/* +* Track write pointers of a zone in bytes. +*/ +typedef struct BlockZoneWps { +CoMutex colock; +uint64_t wp[]; +}BlockZoneWps ; + typedef struct BlockDriverInfo { /* in bytes, 0 if irrelevant */ int cluster_size;
@@ -240,6 +248,12 @@ typedef enum {#define BDRV_SECTOR_BITS 9#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS) +/* +* Get the first most significant bit of wp. If it is zero, then +* the zone type is SWR. +*/ +#define BDRV_ZT_IS_CONV (wp) (wp & (1ULL << 63)) +#define BDRV_REQUEST_MAX_SECTORS MIN_CONST(SIZE_MAX >> BDRV_SECTOR_BITS, \ INT_MAX >> BDRV_SECTOR_BITS)#define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS)
include/block/block_int-common.h +5 -0
@@ -890,6 +890,8 @@ typedef struct BlockLimits {/* maximum number of active zones */ int64_t max_active_zones; + +int64_t write_granularity; } BlockLimits;typedef struct BdrvOpBlocker BdrvOpBlocker ;
@@ -1251,6 +1253,9 @@ struct BlockDriverState {CoMutex bsc_modify_lock;/* Always non-NULL, but must only be dereferenced under an RCU read guard */ BdrvBlockStatusCache *block_status_cache; + +/* array of write pointers' location of each zone in the zoned device. */ +BlockZoneWps *wps; };struct BlockBackendRootState {
block/file-posix.c +174 -4
249 lines not on this page · raw message
Signature · 1 line
2.40.0
[PULL 10/17] block: introduce zone append write for zoned devices
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
A zone append command is a write operation that specifies the first logical block of a zone as the write position. When writing to a zoned block device using zone append, the byte offset of the call may point at any position within the zone to which the data is being appended. Upon completion the device will respond with the position where the data has been written in the zone.
Message-id: [email protected]
--- include/block/block-io.h | 4 ++ include/block/block_int-common.h | 3 ++ include/block/raw-aio.h | 4 +- include/sysemu/block-backend-io.h | 9 +++++ block/block-backend.c | 61 +++++++++++++++++++++++++++++++ block/file-posix.c | 58 +++++++++++++++++++++++++---- block/io.c | 27 ++++++++++++++ block/io_uring.c | 4 ++ block/linux-aio.c | 3 ++ block/raw-format.c | 8 ++++ 10 files changed, 173 insertions(+), 8 deletions(-)
include/block/block-io.h +4 -0
@@ -119,6 +119,10 @@ int coroutine_fn GRAPH_RDLOCK bdrv_co_zone_report(BlockDriverState *bs, int coroutine_fn GRAPH_RDLOCK bdrv_co_zone_mgmt(BlockDriverState *bs,BlockZoneOp op,int64_t offset,int64_t len); +int coroutine_fn GRAPH_RDLOCK bdrv_co_zone_append(BlockDriverState *bs, +int64_t *offset, +QEMUIOVector *qiov, +BdrvRequestFlags flags);bool bdrv_can_write_zeroes_with_unmap (BlockDriverState *bs); int bdrv_block_status(BlockDriverState *bs, int64_t offset,
include/block/block_int-common.h +3 -0
@@ -722,6 +722,9 @@ struct BlockDriver { BlockZoneDescriptor *zones); int coroutine_fn (*bdrv_co_zone_mgmt)(BlockDriverState *bs, BlockZoneOp op,int64_t offset,int64_t len); + int coroutine_fn (*bdrv_co_zone_append)(BlockDriverState *bs, +int64_t *offset,QEMUIOVector *qiov, +BdrvRequestFlags flags);/* removable device specific */ bool coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_is_inserted)(
include/block/raw-aio.h +3 -1
@@ -30,6 +30,7 @@#define QEMU_AIO_TRUNCATE 0x0080#define QEMU_AIO_ZONE_REPORT 0x0100#define QEMU_AIO_ZONE_MGMT 0x0200 +#define QEMU_AIO_ZONE_APPEND 0x0400#define QEMU_AIO_TYPE_MASK \ (QEMU_AIO_READ | \ QEMU_AIO_WRITE | \
@@ -40,7 +41,8 @@ QEMU_AIO_COPY_RANGE | \ QEMU_AIO_TRUNCATE | \ QEMU_AIO_ZONE_REPORT | \ - QEMU_AIO_ZONE_MGMT) + QEMU_AIO_ZONE_MGMT | \ + QEMU_AIO_ZONE_APPEND)/* AIO flags */ #define QEMU_AIO_MISALIGNED 0x1000
include/sysemu/block-backend-io.h +9 -0
@@ -53,6 +53,9 @@ BlockAIOCB *blk_aio_zone_report(BlockBackend *blk, int64_t offset,BlockAIOCB *blk_aio_zone_mgmt (BlockBackend *blk,BlockZoneOp op,int64_t offset,int64_t len,BlockCompletionFunc *cb,void *opaque); +BlockAIOCB *blk_aio_zone_append (BlockBackend *blk,int64_t *offset, +QEMUIOVector *qiov,BdrvRequestFlags flags, +BlockCompletionFunc *cb,void *opaque);BlockAIOCB *blk_aio_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes,BlockCompletionFunc *cb,void *opaque);void blk_aio_cancel_async (BlockAIOCB *acb);
@@ -208,6 +211,12 @@ int coroutine_fn blk_co_zone_mgmt(BlockBackend *blk, BlockZoneOp op, int64_t offset, int64_t len); int co_wrapper_mixed blk_zone_mgmt(BlockBackend *blk, BlockZoneOp op,int64_t offset,int64_t len); +int coroutine_fn blk_co_zone_append(BlockBackend *blk, int64_t *offset, +QEMUIOVector *qiov, +BdrvRequestFlags flags); +int co_wrapper_mixed blk_zone_append(BlockBackend *blk, int64_t *offset, +QEMUIOVector *qiov, +BdrvRequestFlags flags); int co_wrapper_mixed blk_pdiscard(BlockBackend *blk, int64_t offset,int64_t bytes);
block/block-backend.c +61 -0
73 lines not on this page · raw message
block/file-posix.c +51 -7
119 lines not on this page · raw message
block/io.c +27 -0
@@ -3156,6 +3156,33 @@ out:return co.ret; } +int coroutine_fn bdrv_co_zone_append(BlockDriverState *bs, int64_t *offset, +QEMUIOVector *qiov, +BdrvRequestFlags flags) +{ +int ret; +BlockDriver *drv = bs->drv; +CoroutineIOCompletion co = { + .coroutine =qemu_coroutine_self (), + }; +IO_CODE (); + + ret =bdrv_check_qiov_request (*offset, qiov->size, qiov,0 ,NULL ); +if (ret <0 ) { +return ret; + } + +bdrv_inc_in_flight (bs); +if (!drv || !drv->bdrv_co_zone_append || bs->bl.zoned ==BLK_Z_NONE ) { + co.ret = -ENOTSUP ; + goto out; + } + co.ret = drv->bdrv_co_zone_append (bs, offset, qiov, flags); +out: +bdrv_dec_in_flight (bs); +return co.ret; +} +void *qemu_blockalign (BlockDriverState *bs,size_t size) {IO_CODE ();
block/io_uring.c +4 -0
@@ -350,6 +350,10 @@ static int luring_do_submit(int fd, LuringAIOCB *luringcb, LuringState *s,io_uring_prep_writev (sqes, fd, luringcb->qiov->iov, luringcb->qiov->niov, offset);break ; +case QEMU_AIO_ZONE_APPEND : +io_uring_prep_writev (sqes, fd, luringcb->qiov->iov, + luringcb->qiov->niov, offset); +break ;case QEMU_AIO_READ :io_uring_prep_readv (sqes, fd, luringcb->qiov->iov, luringcb->qiov->niov, offset);
block/linux-aio.c +3 -0
@@ -394,6 +394,9 @@ static int laio_do_submit(int fd, struct qemu_laiocb *laiocb, off_t offset,case QEMU_AIO_WRITE :io_prep_pwritev (iocbs, fd, qiov->iov, qiov->niov, offset);break ; +case QEMU_AIO_ZONE_APPEND : +io_prep_pwritev (iocbs, fd, qiov->iov, qiov->niov, offset); +break ;case QEMU_AIO_READ :io_prep_preadv (iocbs, fd, qiov->iov, qiov->niov, offset);break ;
block/raw-format.c +8 -0
@@ -332,6 +332,13 @@ raw_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op,return bdrv_co_zone_mgmt (bs->file->bs, op, offset, len); } +static int coroutine_fn GRAPH_RDLOCK +raw_co_zone_append (BlockDriverState *bs,int64_t *offset,QEMUIOVector *qiov, +BdrvRequestFlags flags) +{ +return bdrv_co_zone_append (bs->file->bs, offset, qiov, flags); +} + static int64_t coroutine_fn GRAPH_RDLOCKraw_co_getlength (BlockDriverState *bs) {
@@ -637,6 +644,7 @@ BlockDriver bdrv_raw = { .bdrv_co_pdiscard = &raw_co_pdiscard, .bdrv_co_zone_report = &raw_co_zone_report, .bdrv_co_zone_mgmt = &raw_co_zone_mgmt, + .bdrv_co_zone_append = &raw_co_zone_append, .bdrv_co_block_status = &raw_co_block_status, .bdrv_co_copy_range_from = &raw_co_copy_range_from, .bdrv_co_copy_range_to = &raw_co_copy_range_to,
Signature · 1 line
2.40.0
[PULL 12/17] block: add some trace events for zone append
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Message-id: [email protected]
--- block/file-posix.c | 3 +++ block/trace-events | 2 ++ 2 files changed, 5 insertions(+)
block/file-posix.c +3 -0
@@ -2517,6 +2517,8 @@ out:if (!BDRV_ZT_IS_CONV (*wp)) {if (type &QEMU_AIO_ZONE_APPEND ) { *s->offset = *wp; +trace_zbd_zone_append_complete (bs, *s->offset + >>BDRV_SECTOR_BITS ); }/* Advance the wp if needed */ if (offset + bytes > *wp) {
@@ -3558,6 +3560,7 @@ static int coroutine_fn raw_co_zone_append(BlockDriverState *bs, len += iov_len; } +trace_zbd_zone_append (bs, *offset >>BDRV_SECTOR_BITS );return raw_co_prw (bs, *offset, len, qiov,QEMU_AIO_ZONE_APPEND ); }#endif
block/trace-events +2 -0
@@ -211,6 +211,8 @@ file_hdev_is_sg(int type, int version) "SG device found: type=%d, version=%d" file_flush_fdatasync_failed(int err) "errno %d" zbd_zone_report(void *bs, unsigned int nr_zones, int64_t sector) "bs %p report %d zones starting at sector offset 0x%" PRIx64 "" zbd_zone_mgmt(void *bs, const char *op_name, int64_t sector, int64_t len) "bs %p %s starts at sector offset 0x%" PRIx64 " over a range of 0x%" PRIx64 " sectors" +zbd_zone_append(void *bs, int64_t sector) "bs %p append at sector offset 0x%" PRIx64 "" +zbd_zone_append_complete(void *bs, int64_t sector) "bs %p returns append sector 0x%" PRIx64 "" # ssh.c sftp_error(const char *op, const char *ssh_err, int ssh_err_code, int sftp_err_code) "%s failed: %s (libssh error code: %d, sftp error code: %d)"
Signature · 1 line
2.40.0
[PULL 11/17] qemu-iotests: test zone append operation
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
The patch tests zone append writes by reporting the zone wp after the completion of the call. "zap -p" option can print the sector offset value after completion, which should be the start sector where the append write begins.
Message-id: [email protected]
--- qemu-io-cmds.c | 75 ++++++++++++++++++++++++++++++ tests/qemu-iotests/tests/zoned | 16 +++++++ tests/qemu-iotests/tests/zoned.out | 16 +++++++ 3 files changed, 107 insertions(+)
qemu-io-cmds.c +75 -0
@@ -1874,6 +1874,80 @@ static const cmdinfo_t zone_reset_cmd = { .oneline = "reset a zone write pointer in zone block device", }; +static int do_aio_zone_append (BlockBackend *blk,QEMUIOVector *qiov, +int64_t *offset,int flags,int *total) +{ +int async_ret =NOT_DONE ; + +blk_aio_zone_append (blk, offset, qiov, flags, aio_rw_done, &async_ret); +while (async_ret ==NOT_DONE ) { +main_loop_wait (false); + } + + *total = qiov->size; +return async_ret <0 ? async_ret :1 ; +} + +static int zone_append_f (BlockBackend *blk,int argc,char **argv) +{ +int ret; +bool pflag = false; +int flags =0 ; +int total =0 ; +int64_t offset; +char *buf; +int c, nr_iov; +int pattern =0xcd ; +QEMUIOVector qiov; + +if (optind > argc -3 ) { +return -EINVAL ; + } + +if ((c =getopt (argc, argv,"p" )) !=-1 ) { + pflag = true; + } + + offset =cvtnum (argv[optind]); +if (offset <0 ) { +print_cvtnum_err (offset, argv[optind]); +return offset; + } + optind++; + nr_iov = argc - optind; + buf =create_iovec (blk, &qiov, &argv[optind], nr_iov, pattern, + flags &BDRV_REQ_REGISTERED_BUF ); +if (buf ==NULL ) { +return -EINVAL ; + } + ret =do_aio_zone_append (blk, &qiov, &offset, flags, &total); +if (ret <0 ) { +printf ("zone append failed: %s\n" ,strerror (-ret)); + goto out; + } + +if (pflag) { +printf ("After zap done, the append sector is 0x%" PRIx64"\n" , +tosector (offset)); + } + +out: +qemu_io_free (blk, buf, qiov.size, + flags &BDRV_REQ_REGISTERED_BUF ); +qemu_iovec_destroy (&qiov); +return ret; +} + +static const cmdinfo_t zone_append_cmd = { + .name ="zone_append" , + .altname ="zap" , + .cfunc = zone_append_f, + .argmin =3 , + .argmax =4 , + .args ="offset len [len..]" , + .oneline ="append write a number of bytes at a specified offset" , +}; +static int truncate_f (BlockBackend *blk,int argc,char **argv);static const cmdinfo_t truncate_cmd = { .name ="truncate" ,
@@ -2672,6 +2746,7 @@ static void __attribute((constructor)) init_qemuio_commands(void)qemuio_add_command (&zone_close_cmd);qemuio_add_command (&zone_finish_cmd);qemuio_add_command (&zone_reset_cmd); +qemuio_add_command (&zone_append_cmd);qemuio_add_command (&truncate_cmd);qemuio_add_command (&length_cmd);qemuio_add_command (&info_cmd);
tests/qemu-iotests/tests/zoned +16 -0
@@ -82,6 +82,22 @@ echo "(5) resetting the second zone" $QEMU_IO $IMG -c "zrs 268435456 268435456" echo "After resetting a zone:" $QEMU_IO $IMG -c "zrp 268435456 1" +echo +echo +echo "(6) append write" # the physical block size of the device is 4096 +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" +echo "After appending the first zone firstly:" +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" +echo "After appending the first zone secondly:" +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000" +echo "After appending the second zone firstly:" +$QEMU_IO $IMG -c "zrp 268435456 1" +$QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000" +echo "After appending the second zone secondly:" +$QEMU_IO $IMG -c "zrp 268435456 1" # success, all done echo "*** done"
tests/qemu-iotests/tests/zoned.out +16 -0
@@ -50,4 +50,20 @@ start: 0x80000, len 0x80000, cap 0x80000, wptr 0x100000, zcond:14, [type: 2] (5) resetting the second zone After resetting a zone: start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80000, zcond:1, [type: 2] + + +(6) append write +start: 0x0, len 0x80000, cap 0x80000, wptr 0x0, zcond:1, [type: 2] +After zap done, the append sector is 0x0 +After appending the first zone firstly: +start: 0x0, len 0x80000, cap 0x80000, wptr 0x18, zcond:2, [type: 2] +After zap done, the append sector is 0x18 +After appending the first zone secondly: +start: 0x0, len 0x80000, cap 0x80000, wptr 0x30, zcond:2, [type: 2] +After zap done, the append sector is 0x80000 +After appending the second zone firstly: +start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80018, zcond:2, [type: 2] +After zap done, the append sector is 0x80018 +After appending the second zone secondly: +start: 0x80000, len 0x80000, cap 0x80000, wptr 0x80030, zcond:2, [type: 2] *** done
Signature · 1 line
2.40.0
[PULL 13/17] include: update virtio_blk headers to v6.3-rc1
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Use scripts/update-linux-headers.sh to update headers to 6.3-rc1.
[Reran scripts/update-linux-headers.sh on Linux v6.3. The only change was the use of __virtioXX types instead of uintXX_t. --Stefan]
Message-Id: <[email protected]>
--- include/standard-headers/drm/drm_fourcc.h | 12 +++ include/standard-headers/linux/ethtool.h | 48 ++++++++- include/standard-headers/linux/fuse.h | 45 +++++++- include/standard-headers/linux/pci_regs.h | 1 + include/standard-headers/linux/vhost_types.h | 2 + include/standard-headers/linux/virtio_blk.h | 105 +++++++++++++++++++ linux-headers/asm-arm64/kvm.h | 1 + linux-headers/asm-x86/kvm.h | 34 +++++- linux-headers/linux/kvm.h | 9 ++ linux-headers/linux/vfio.h | 15 +-- linux-headers/linux/vhost.h | 8 ++ 11 files changed, 270 insertions(+), 10 deletions(-)
include/standard-headers/drm/drm_fourcc.h +12 -0
@@ -87,6 +87,18 @@ extern "C" {* * The authoritative list of format modifier codes is found in * `include/uapi/drm/drm_fourcc.h` +* +* Open Source User Waiver +* ----------------------- +* +* Because this is the authoritative source for pixel formats and modifiers +* referenced by GL, Vulkan extensions and other standards and hence used both +* by open source and closed source driver stacks, the usual requirement for an +* upstream in-kernel or open source userspace user does not apply. +* +* To ensure, as much as feasible, compatibility across stacks and avoid +* confusion with incompatible enumerations stakeholders for all relevant driver +* stacks should approve additions. */ #define fourcc_code (a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
include/standard-headers/linux/ethtool.h +47 -1
72 lines not on this page · raw message
include/standard-headers/linux/fuse.h +44 -1
79 lines not on this page · raw message
include/standard-headers/linux/pci_regs.h +1 -0
@@ -693,6 +693,7 @@#define PCI_EXP_LNKCTL2_TX_MARGIN 0x0380/* Transmit Margin */ #define PCI_EXP_LNKCTL2_HASD 0x0020/* HW Autonomous Speed Disable */ #define PCI_EXP_LNKSTA2 0x32/* Link Status 2 */ +#define PCI_EXP_LNKSTA2_FLIT 0x0400/* Flit Mode Status */ #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 0x32/* end of v2 EPs w/ link */ #define PCI_EXP_SLTCAP2 0x34/* Slot Capabilities 2 */ #define PCI_EXP_SLTCAP2_IBPD 0x00000001/* In-band PD Disable Supported */
include/standard-headers/linux/vhost_types.h +2 -0
@@ -163,5 +163,7 @@ struct vhost_vdpa_iova_range {#define VHOST_BACKEND_F_IOTLB_ASID 0x3/* Device can be suspended */ #define VHOST_BACKEND_F_SUSPEND 0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5#endif
include/standard-headers/linux/virtio_blk.h +105 -0
133 lines not on this page · raw message
linux-headers/asm-arm64/kvm.h +1 -0
@@ -109,6 +109,7 @@ struct kvm_regs {#define KVM_ARM_VCPU_SVE 4/* enable SVE for this CPU */ #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5/* VCPU uses address authentication */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6/* VCPU uses generic authentication */ +#define KVM_ARM_VCPU_HAS_EL2 7/* Support nested virtualization */ struct kvm_vcpu_init {__u32 target;
linux-headers/asm-x86/kvm.h +32 -2
@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/ioctl.h> +#include <linux/stddef.h> #define KVM_PIO_PAGE_OFFSET 1#define KVM_COALESCED_MMIO_PAGE_OFFSET 2
@@ -505,8 +506,8 @@ struct kvm_nested_state {* KVM_{GET,PUT}_NESTED_STATE ioctl values. */ union { -struct kvm_vmx_nested_state_data vmx[0 ]; -struct kvm_svm_nested_state_data svm[0 ]; + __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx); + __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm); } data; };
@@ -523,6 +524,35 @@ struct kvm_pmu_event_filter {#define KVM_PMU_EVENT_ALLOW 0#define KVM_PMU_EVENT_DENY 1 +#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0) +#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) + +/* +* Masked event layout. +* Bits Description +* ---- ----------- +* 7:0 event select (low bits) +* 15:8 umask match +* 31:16 unused +* 35:32 event select (high bits) +* 36:54 unused +* 55 exclude bit +* 63:56 umask mask +*/ + +#define KVM_PMU_ENCODE_MASKED_ENTRY (event_select, mask, match, exclude) \ + (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | \ + (((mask) & 0xFFULL) << 56) | \ + (((match) & 0xFFULL) << 8) | \ + ((__u64)(!!(exclude)) << 55)) + +#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \ + (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8)) +#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) +/* for KVM_{GET,SET,HAS}_DEVICE_ATTR */ #define KVM_VCPU_TSC_CTRL 0/* control group for the timestamp counter (TSC) */ #define KVM_VCPU_TSC_OFFSET 0/* attribute for the TSC offset */
linux-headers/linux/kvm.h +9 -0
@@ -581,6 +581,8 @@ struct kvm_s390_mem_op {struct {__u8 ar;/* the access register number */ __u8 key;/* access key, ignored if flag unset */ +__u8 pad1[6 ];/* ignored */ +__u64 old_addr;/* ignored if cmpxchg flag unset */ };__u32 sida_offset;/* offset into the sida */ __u8 reserved[32 ];/* ignored */
@@ -593,11 +595,17 @@ struct kvm_s390_mem_op {#define KVM_S390_MEMOP_SIDA_WRITE 3#define KVM_S390_MEMOP_ABSOLUTE_READ 4#define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 +#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6 +/* flags for kvm_s390_mem_op->flags */ #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)#define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)#define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) +/* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */ +#define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0) +#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1) +/* for KVM_INTERRUPT */ struct kvm_interrupt {/* in */
@@ -1173,6 +1181,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 +#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226#ifdef KVM_CAP_IRQ_ROUTING
linux-headers/linux/vfio.h +9 -6
@@ -49,7 +49,11 @@/* Supports VFIO_DMA_UNMAP_FLAG_ALL */ #define VFIO_UNMAP_ALL 9 -/* Supports the vaddr flag for DMA map and unmap */ +/* +* Supports the vaddr flag for DMA map and unmap. Not supported for mediated +* devices, so this capability is subject to change as groups are added or +* removed. +*/ #define VFIO_UPDATE_VADDR 10/*
@@ -1343,8 +1347,7 @@ struct vfio_iommu_type1_info_dma_avail {* Map process virtual addresses to IO virtual addresses using the * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required. * -* If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova, and -* unblock translation of host virtual addresses in the iova range. The vaddr +* If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova. The vaddr * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. To * maintain memory consistency within the user application, the updated vaddr * must address the same memory object as originally mapped. Failure to do so
@@ -1395,9 +1398,9 @@ struct vfio_bitmap {* must be 0. This cannot be combined with the get-dirty-bitmap flag. * * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host -* virtual addresses in the iova range. Tasks that attempt to translate an -* iova's vaddr will block. DMA to already-mapped pages continues. This -* cannot be combined with the get-dirty-bitmap flag. +* virtual addresses in the iova range. DMA to already-mapped pages continues. +* Groups may not be added to the container while any addresses are invalid. +* This cannot be combined with the get-dirty-bitmap flag. */ struct vfio_iommu_type1_dma_unmap {__u32 argsz;
linux-headers/linux/vhost.h +8 -0
@@ -180,4 +180,12 @@*/ #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) +/* Resume a device so it can resume processing virtqueue requests +* +* After the return of this ioctl the device will have restored all the +* necessary states and it is fully operational to continue processing the +* virtqueue descriptors. +*/ +#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) +#endif
Signature · 1 line
2.40.0
[PULL 14/17] virtio-blk: add zoned storage emulation for zoned devices
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
This patch extends virtio-blk emulation to handle zoned device commands by calling the new block layer APIs to perform zoned device I/O on behalf of the guest. It supports Report Zone, four zone oparations (open, close, finish, reset), and Append Zone.
The VIRTIO_BLK_F_ZONED feature bit will only be set if the host does support zoned block devices. Regular block devices(conventional zones) will not be set.
The guest os can use blktests, fio to test those commands on zoned devices. Furthermore, using zonefs to test zone append write is also supported.
Message-Id: <[email protected]>
--- hw/block/virtio-blk-common.c | 2 + hw/block/virtio-blk.c | 389 +++++++++++++++++++++++++++++++++++ hw/virtio/virtio-qmp.c | 2 + 3 files changed, 393 insertions(+)
hw/block/virtio-blk-common.c +2 -0
@@ -29,6 +29,8 @@ static const VirtIOFeature feature_sizes[] = { .end = endof(struct virtio_blk_config, discard_sector_alignment)}, {.flags = 1ULL << VIRTIO_BLK_F_WRITE_ZEROES, .end = endof(struct virtio_blk_config, write_zeroes_may_unmap)}, + {.flags = 1ULL << VIRTIO_BLK_F_ZONED, + .end = endof(struct virtio_blk_config, zoned)}, {} };
hw/block/virtio-blk.c +389 -0
437 lines not on this page · raw message
hw/virtio/virtio-qmp.c +2 -0
@@ -176,6 +176,8 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = { "VIRTIO_BLK_F_DISCARD: Discard command supported"),FEATURE_ENTRY (VIRTIO_BLK_F_WRITE_ZEROES , \"VIRTIO_BLK_F_WRITE_ZEROES: Write zeroes command supported" ), +FEATURE_ENTRY (VIRTIO_BLK_F_ZONED , \ +"VIRTIO_BLK_F_ZONED: Zoned block devices" ), #ifndef VIRTIO_BLK_NO_LEGACYFEATURE_ENTRY (VIRTIO_BLK_F_BARRIER , \ "VIRTIO_BLK_F_BARRIER: Request barriers supported"),
Signature · 1 line
2.40.0
[PULL 15/17] block: add accounting for zone append operation
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Taking account of the new zone append write operation for zoned devices, BLOCK_ACCT_ZONE_APPEND enum is introduced as other I/O request type (read, write, flush).
Message-Id: <[email protected]>
--- qapi/block-core.json | 68 ++++++++++++++++++++++++++++++++------ qapi/block.json | 4 +++ include/block/accounting.h | 1 + block/qapi-sysemu.c | 11 ++++++ block/qapi.c | 18 ++++++++++ hw/block/virtio-blk.c | 4 +++ 6 files changed, 95 insertions(+), 11 deletions(-)
qapi/block-core.json +57 -11
@@ -849,6 +849,10 @@ # @min_wr_latency_ns: Minimum latency of write operations in the # defined interval, in nanoseconds. # +# @min_zone_append_latency_ns: Minimum latency of zone append operations +# in the defined interval, in nanoseconds +# (since 8.1) +# # @min_flush_latency_ns: Minimum latency of flush operations in the # defined interval, in nanoseconds. #
@@ -858,6 +862,10 @@ # @max_wr_latency_ns: Maximum latency of write operations in the # defined interval, in nanoseconds. # +# @max_zone_append_latency_ns: Maximum latency of zone append operations +# in the defined interval, in nanoseconds +# (since 8.1) +# # @max_flush_latency_ns: Maximum latency of flush operations in the # defined interval, in nanoseconds. #
@@ -867,6 +875,10 @@ # @avg_wr_latency_ns: Average latency of write operations in the # defined interval, in nanoseconds. # +# @avg_zone_append_latency_ns: Average latency of zone append operations +# in the defined interval, in nanoseconds +# (since 8.1) +# # @avg_flush_latency_ns: Average latency of flush operations in the # defined interval, in nanoseconds. #
@@ -876,15 +888,23 @@ # @avg_wr_queue_depth: Average number of pending write operations # in the defined interval. # +# @avg_zone_append_queue_depth: Average number of pending zone append +# operations in the defined interval +# (since 8.1). +# # Since: 2.5 ## { 'struct': 'BlockDeviceTimedStats', 'data': { 'interval_length': 'int', 'min_rd_latency_ns': 'int', 'max_rd_latency_ns': 'int', 'avg_rd_latency_ns': 'int', 'min_wr_latency_ns': 'int', 'max_wr_latency_ns': 'int', - 'avg_wr_latency_ns': 'int', 'min_flush_latency_ns': 'int', - 'max_flush_latency_ns': 'int', 'avg_flush_latency_ns': 'int', - 'avg_rd_queue_depth': 'number', 'avg_wr_queue_depth': 'number' } } + 'avg_wr_latency_ns': 'int', 'min_zone_append_latency_ns': 'int', + 'max_zone_append_latency_ns': 'int', + 'avg_zone_append_latency_ns': 'int', + 'min_flush_latency_ns': 'int', 'max_flush_latency_ns': 'int', + 'avg_flush_latency_ns': 'int', 'avg_rd_queue_depth': 'number', + 'avg_wr_queue_depth': 'number', + 'avg_zone_append_queue_depth': 'number' } } ## # @BlockDeviceStats:
@@ -895,12 +915,18 @@ # # @wr_bytes: The number of bytes written by the device. # +# @zone_append_bytes: The number of bytes appended by the zoned devices +# (since 8.1) +# # @unmap_bytes: The number of bytes unmapped by the device (Since 4.2) # # @rd_operations: The number of read operations performed by the device. # # @wr_operations: The number of write operations performed by the device. # +# @zone_append_operations: The number of zone append operations performed +# by the zoned devices (since 8.1) +# # @flush_operations: The number of cache flush operations performed by the # device (since 0.15) #
@@ -911,6 +937,9 @@ # # @wr_total_time_ns: Total time spent on writes in nanoseconds (since 0.15). # +# @zone_append_total_time_ns: Total time spent on zone append writes +# in nanoseconds (since 8.1) +# # @flush_total_time_ns: Total time spent on cache flushes in nanoseconds # (since 0.15). #
@@ -928,6 +957,9 @@ # @wr_merged: Number of write requests that have been merged into another # request (Since 2.3). # +# @zone_append_merged: Number of zone append requests that have been merged +# into another request (since 8.1) +# # @unmap_merged: Number of unmap requests that have been merged into another # request (Since 4.2) #
@@ -941,6 +973,10 @@ # @failed_wr_operations: The number of failed write operations # performed by the device (Since 2.5) # +# @failed_zone_append_operations: The number of failed zone append write +# operations performed by the zoned devices +# (since 8.1) +# # @failed_flush_operations: The number of failed flush operations # performed by the device (Since 2.5) #
@@ -953,6 +989,9 @@ # @invalid_wr_operations: The number of invalid write operations # performed by the device (Since 2.5) # +# @invalid_zone_append_operations: The number of invalid zone append operations +# performed by the zoned device (since 8.1) +# # @invalid_flush_operations: The number of invalid flush operations # performed by the device (Since 2.5) #
@@ -972,27 +1011,34 @@ # # @wr_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0) # +# @zone_append_latency_histogram: @BlockLatencyHistogramInfo. (since 8.1) +# # @flush_latency_histogram: @BlockLatencyHistogramInfo. (Since 4.0) # # Since: 0.14 ## { 'struct': 'BlockDeviceStats', - 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'unmap_bytes' : 'int', - 'rd_operations': 'int', 'wr_operations': 'int', + 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'zone_append_bytes': 'int', + 'unmap_bytes' : 'int', 'rd_operations': 'int', + 'wr_operations': 'int', 'zone_append_operations': 'int', 'flush_operations': 'int', 'unmap_operations': 'int', 'rd_total_time_ns': 'int', 'wr_total_time_ns': 'int', - 'flush_total_time_ns': 'int', 'unmap_total_time_ns': 'int', - 'wr_highest_offset': 'int', - 'rd_merged': 'int', 'wr_merged': 'int', 'unmap_merged': 'int', - '*idle_time_ns': 'int', + 'zone_append_total_time_ns': 'int', 'flush_total_time_ns': 'int', + 'unmap_total_time_ns': 'int', 'wr_highest_offset': 'int', + 'rd_merged': 'int', 'wr_merged': 'int', 'zone_append_merged': 'int', + 'unmap_merged': 'int', '*idle_time_ns': 'int', 'failed_rd_operations': 'int', 'failed_wr_operations': 'int', - 'failed_flush_operations': 'int', 'failed_unmap_operations': 'int', - 'invalid_rd_operations': 'int', 'invalid_wr_operations': 'int', + 'failed_zone_append_operations': 'int', + 'failed_flush_operations': 'int', + 'failed_unmap_operations': 'int', 'invalid_rd_operations': 'int', + 'invalid_wr_operations': 'int', + 'invalid_zone_append_operations': 'int', 'invalid_flush_operations': 'int', 'invalid_unmap_operations': 'int', 'account_invalid': 'bool', 'account_failed': 'bool', 'timed_stats': ['BlockDeviceTimedStats'], '*rd_latency_histogram': 'BlockLatencyHistogramInfo', '*wr_latency_histogram': 'BlockLatencyHistogramInfo', + '*zone_append_latency_histogram': 'BlockLatencyHistogramInfo', '*flush_latency_histogram': 'BlockLatencyHistogramInfo' } } ##
qapi/block.json +4 -0
@@ -525,6 +525,9 @@ # @boundaries-write: list of interval boundary values for write latency # histogram. # +# @boundaries-zap: list of interval boundary values for zone append write +# latency histogram. +# # @boundaries-flush: list of interval boundary values for flush latency # histogram. #
@@ -573,5 +576,6 @@ '*boundaries': ['uint64'], '*boundaries-read': ['uint64'], '*boundaries-write': ['uint64'], + '*boundaries-zap': ['uint64'], '*boundaries-flush': ['uint64'] }, 'allow-preconfig': true }
include/block/accounting.h +1 -0
@@ -37,6 +37,7 @@ enum BlockAcctType {BLOCK_ACCT_READ ,BLOCK_ACCT_WRITE ,BLOCK_ACCT_FLUSH , +BLOCK_ACCT_ZONE_APPEND ,BLOCK_ACCT_UNMAP , BLOCK_MAX_IOTYPE, };
block/qapi-sysemu.c +11 -0
@@ -517,6 +517,7 @@ void qmp_block_latency_histogram_set( bool has_boundaries, uint64List *boundaries, bool has_boundaries_read, uint64List *boundaries_read, bool has_boundaries_write, uint64List *boundaries_write, + bool has_boundaries_append, uint64List *boundaries_append, bool has_boundaries_flush, uint64List *boundaries_flush, Error **errp) {
@@ -557,6 +558,16 @@ void qmp_block_latency_histogram_set( } } +if (has_boundaries || has_boundaries_append) { + ret =block_latency_histogram_set ( + stats,BLOCK_ACCT_ZONE_APPEND , + has_boundaries_append ? boundaries_append : boundaries); +if (ret) { +error_setg (errp,"Device '%s' set append write boundaries fail" , id); +return ; + } + } +if (has_boundaries || has_boundaries_flush) { ret = block_latency_histogram_set( stats, BLOCK_ACCT_FLUSH,
block/qapi.c +18 -0
@@ -533,27 +533,36 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) ds->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ ]; ds->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE ]; + ds->zone_append_bytes = stats->nr_bytes[BLOCK_ACCT_ZONE_APPEND ]; ds->unmap_bytes = stats->nr_bytes[BLOCK_ACCT_UNMAP ]; ds->rd_operations = stats->nr_ops[BLOCK_ACCT_READ ]; ds->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE ]; + ds->zone_append_operations = stats->nr_ops[BLOCK_ACCT_ZONE_APPEND ]; ds->unmap_operations = stats->nr_ops[BLOCK_ACCT_UNMAP ]; ds->failed_rd_operations = stats->failed_ops[BLOCK_ACCT_READ ]; ds->failed_wr_operations = stats->failed_ops[BLOCK_ACCT_WRITE ]; + ds->failed_zone_append_operations = + stats->failed_ops[BLOCK_ACCT_ZONE_APPEND ]; ds->failed_flush_operations = stats->failed_ops[BLOCK_ACCT_FLUSH ]; ds->failed_unmap_operations = stats->failed_ops[BLOCK_ACCT_UNMAP ]; ds->invalid_rd_operations = stats->invalid_ops[BLOCK_ACCT_READ ]; ds->invalid_wr_operations = stats->invalid_ops[BLOCK_ACCT_WRITE ]; + ds->invalid_zone_append_operations = + stats->invalid_ops[BLOCK_ACCT_ZONE_APPEND ]; ds->invalid_flush_operations = stats->invalid_ops[BLOCK_ACCT_FLUSH ]; ds->invalid_unmap_operations = stats->invalid_ops[BLOCK_ACCT_UNMAP ]; ds->rd_merged = stats->merged[BLOCK_ACCT_READ ]; ds->wr_merged = stats->merged[BLOCK_ACCT_WRITE ]; + ds->zone_append_merged = stats->merged[BLOCK_ACCT_ZONE_APPEND ]; ds->unmap_merged = stats->merged[BLOCK_ACCT_UNMAP ]; ds->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH ]; ds->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE ]; + ds->zone_append_total_time_ns = + stats->total_time_ns[BLOCK_ACCT_ZONE_APPEND ]; ds->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ ]; ds->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH ]; ds->unmap_total_time_ns = stats->total_time_ns[BLOCK_ACCT_UNMAP ];
@@ -571,6 +580,7 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)TimedAverage *rd = &ts->latency[BLOCK_ACCT_READ ];TimedAverage *wr = &ts->latency[BLOCK_ACCT_WRITE ]; +TimedAverage *zap = &ts->latency[BLOCK_ACCT_ZONE_APPEND ];TimedAverage *fl = &ts->latency[BLOCK_ACCT_FLUSH ]; dev_stats->interval_length = ts->interval_length;
@@ -583,6 +593,10 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) dev_stats->max_wr_latency_ns =timed_average_max (wr); dev_stats->avg_wr_latency_ns =timed_average_avg (wr); + dev_stats->min_zone_append_latency_ns =timed_average_min (zap); + dev_stats->max_zone_append_latency_ns =timed_average_max (zap); + dev_stats->avg_zone_append_latency_ns =timed_average_avg (zap); + dev_stats->min_flush_latency_ns =timed_average_min (fl); dev_stats->max_flush_latency_ns =timed_average_max (fl); dev_stats->avg_flush_latency_ns =timed_average_avg (fl);
@@ -591,6 +605,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)block_acct_queue_depth (ts,BLOCK_ACCT_READ ); dev_stats->avg_wr_queue_depth =block_acct_queue_depth (ts,BLOCK_ACCT_WRITE ); + dev_stats->avg_zone_append_queue_depth = +block_acct_queue_depth (ts,BLOCK_ACCT_ZONE_APPEND );QAPI_LIST_PREPEND (ds->timed_stats, dev_stats); }
@@ -600,6 +616,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_READ]); ds->wr_latency_histogram =bdrv_latency_histogram_stats (&hgram[BLOCK_ACCT_WRITE ]); + ds->zone_append_latency_histogram + =bdrv_latency_histogram_stats (&hgram[BLOCK_ACCT_ZONE_APPEND ]); ds->flush_latency_histogram =bdrv_latency_histogram_stats (&hgram[BLOCK_ACCT_FLUSH ]); }
hw/block/virtio-blk.c +4 -0
@@ -919,6 +919,10 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq *req, data->in_num = in_num; data->zone_append_data.offset = offset;qemu_iovec_init_external (&req->qiov, out_iov, out_num); + +block_acct_start (blk_get_stats (s->blk), &req->acct, len, +BLOCK_ACCT_ZONE_APPEND ); +blk_aio_zone_append (s->blk, &data->zone_append_data.offset, &req->qiov,0 , virtio_blk_zone_append_complete, data);return 0 ;
Signature · 1 line
2.40.0
[PULL 16/17] virtio-blk: add some trace events for zoned emulation
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Message-Id: <[email protected]>
--- hw/block/virtio-blk.c | 12 ++++++++++++ hw/block/trace-events | 7 +++++++ 2 files changed, 19 insertions(+)
hw/block/virtio-blk.c +12 -0
@@ -676,6 +676,7 @@ static void virtio_blk_zone_report_complete(void *opaque, int ret)int64_t nz = data->zone_report_data.nr_zones;int8_t err_status =VIRTIO_BLK_S_OK ; +trace_virtio_blk_zone_report_complete (vdev, req, nz, ret);if (ret) { err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ; goto out;
@@ -792,6 +793,8 @@ static void virtio_blk_handle_zone_report(VirtIOBlockReq *req, nr_zones = (req->in_len -sizeof (struct virtio_blk_inhdr ) -sizeof (struct virtio_blk_zone_report )) /sizeof (struct virtio_blk_zone_descriptor ); +trace_virtio_blk_handle_zone_report (vdev, req, + offset >>BDRV_SECTOR_BITS , nr_zones); zone_size =sizeof (BlockZoneDescriptor) * nr_zones; data =g_malloc (sizeof (ZoneCmdData));
@@ -814,7 +817,9 @@ static void virtio_blk_zone_mgmt_complete(void *opaque, int ret) {VirtIOBlockReq *req = opaque;VirtIOBlock *s = req->dev; +VirtIODevice *vdev =VIRTIO_DEVICE (s);int8_t err_status =VIRTIO_BLK_S_OK ; +trace_virtio_blk_zone_mgmt_complete (vdev, req,ret);if (ret) { err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ;
@@ -841,6 +846,8 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op)/* Entire drive capacity */ offset =0 ; len = capacity; +trace_virtio_blk_handle_zone_reset_all (vdev, req,0 , + bs->total_sectors); }else {if (bs->bl.zone_size > capacity - offset) {/* The zoned device allows the last smaller zone. */
@@ -848,6 +855,9 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op) }else { len = bs->bl.zone_size; } +trace_virtio_blk_handle_zone_mgmt (vdev, req, op, + offset >>BDRV_SECTOR_BITS , + len >>BDRV_SECTOR_BITS ); }if (!check_zoned_request (s, offset, len, false, &err_status)) {
@@ -888,6 +898,7 @@ static void virtio_blk_zone_append_complete(void *opaque, int ret) err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ; goto out; } +trace_virtio_blk_zone_append_complete (vdev, req, append_sector, ret); out:aio_context_acquire (blk_get_aio_context (s->conf.conf.blk));
@@ -909,6 +920,7 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq *req,int64_t offset =virtio_ldq_p (vdev, &req->out.sector) <<BDRV_SECTOR_BITS ;int64_t len =iov_size (out_iov, out_num); +trace_virtio_blk_handle_zone_append (vdev, req, offset >>BDRV_SECTOR_BITS );if (!check_zoned_request (s, offset, len, true, &err_status)) { goto out; }
hw/block/trace-events +7 -0
@@ -44,9 +44,16 @@ pflash_write_unknown(const char *name, uint8_t cmd) "%s: unknown command 0x%02x" # virtio-blk.c virtio_blk_req_complete(void *vdev, void *req, int status) "vdev %p req %p status %d" virtio_blk_rw_complete(void *vdev, void *req, int ret) "vdev %p req %p ret %d" +virtio_blk_zone_report_complete(void *vdev, void *req, unsigned int nr_zones, int ret) "vdev %p req %p nr_zones %u ret %d" +virtio_blk_zone_mgmt_complete(void *vdev, void *req, int ret) "vdev %p req %p ret %d" +virtio_blk_zone_append_complete(void *vdev, void *req, int64_t sector, int ret) "vdev %p req %p, append sector 0x%" PRIx64 " ret %d" virtio_blk_handle_write(void *vdev, void *req, uint64_t sector, size_t nsectors) "vdev %p req %p sector %"PRIu64" nsectors %zu" virtio_blk_handle_read(void *vdev, void *req, uint64_t sector, size_t nsectors) "vdev %p req %p sector %"PRIu64" nsectors %zu" virtio_blk_submit_multireq(void *vdev, void *mrb, int start, int num_reqs, uint64_t offset, size_t size, bool is_write) "vdev %p mrb %p start %d num_reqs %d offset %"PRIu64" size %zu is_write %d" +virtio_blk_handle_zone_report(void *vdev, void *req, int64_t sector, unsigned int nr_zones) "vdev %p req %p sector 0x%" PRIx64 " nr_zones %u" +virtio_blk_handle_zone_mgmt(void *vdev, void *req, uint8_t op, int64_t sector, int64_t len) "vdev %p req %p op 0x%x sector 0x%" PRIx64 " len 0x%" PRIx64 "" +virtio_blk_handle_zone_reset_all(void *vdev, void *req, int64_t sector, int64_t len) "vdev %p req %p sector 0x%" PRIx64 " cap 0x%" PRIx64 "" +virtio_blk_handle_zone_append(void *vdev, void *req, int64_t sector) "vdev %p req %p, append sector 0x%" PRIx64 "" # hd-geometry.c hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS %d %d %d"
Signature · 1 line
2.40.0
[PULL 17/17] docs/zoned-storage:add zoned emulation use case
In reply to Stefan HajnocziFrom: Sam Li <[email protected]>
Add the documentation about the example of using virtio-blk driver to pass the zoned block devices through to the guest.
[Fix rST syntax
--Stefan]
Message-Id: <[email protected]>
--- docs/devel/zoned-storage.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
docs/devel/zoned-storage.rst +19 -0
@@ -41,3 +41,22 @@ APIs for zoned storage emulation or testing. For example, to test zone_report on a null_blk device using qemu-io is:: $ path/to/qemu-io --image-opts -n driver=host_device,filename=/dev/nullb0 -c "zrp offset nr_zones" + +To expose the host's zoned block device through virtio-blk, the command line +can be (includes the -device parameter):: + + -blockdev node-name=drive0,driver=host_device,filename=/dev/nullb0,cache.direct=on \ + -device virtio-blk-pci,drive=drive0 + +Or only use the -drive parameter:: + + -driver driver=host_device,file=/dev/nullb0,if=virtio,cache.direct=on + +Additionally, QEMU has several ways of supporting zoned storage, including: +(1) Using virtio-scsi: --device scsi-block allows for the passing through of +SCSI ZBC devices, enabling the attachment of ZBC or ZAC HDDs to QEMU. +(2) PCI device pass-through: While NVMe ZNS emulation is available for testing +purposes, it cannot yet pass through a zoned device from the host. To pass on +the NVMe ZNS device to the guest, use VFIO PCI pass the entire NVMe PCI adapter +through to the guest. Likewise, an HDD HBA can be passed on to QEMU all HDDs +attached to the HBA.
Signature · 1 line
2.40.0
Quoted 10 lines · Stefan Hajnoczi
The following changes since commit
05d50ba2d4668d43a835c5a502efdec9b92646e6:Merge tag 'migration-20230427-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-04-28 08:35:06 +0100)are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to
d3c760be786571d83d5cea01953e543df4d76f51:
Quoted 7 lines
docs/zoned-storage:add zoned emulation use case (2023-04-28 08:34:07 -0400)----------------------------------------------------------------
Pull requestThis pull request contains Sam Li's virtio-blk zoned storage work. These patches were dropped from my previous block pull request due to CI failures.
More CI build failures, e.g.
https://gitlab.com/qemu-project/qemu/-/jobs/4202086013#L1720
https://gitlab.com/qemu-project/qemu/-/jobs/4202085995#L4088
r~
Quoted 13 lines · Richard Henderson
Quoted 12 lines · Stefan Hajnoczi
The following changes since commit
05d50ba2d4668d43a835c5a502efdec9b92646e6:Merge tag 'migration-20230427-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-04-28 08:35:06 +0100)are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to
d3c760be786571d83d5cea01953e543df4d76f51:docs/zoned-storage:add zoned emulation use case (2023-04-28 08:34:07 -0400)
Quoted 8 lines
Quoted 5 lines
----------------------------------------------------------------
Pull requestThis pull request contains Sam Li's virtio-blk zoned storage work. These patches were dropped from my previous block pull request due to CI failures.
More CI build failures, e.g.
Hi Sam,
There are some more CI failures.
This Ubuntu 20.04 on s390x CI job failed because <linux/blkzoned.h> is missing Linux commit e876df1fe0ad ("block: add zone open, close and finish ioctl support"):
../block/file-posix.c: In function ‘raw_co_zone_mgmt’:
../block/file-posix.c:3472:14: error: ‘BLKOPENZONE’ undeclared (first use in this function)
3472 | zo = BLKOPENZONE;
| ^~~~~~~~~~~
../block/file-posix.c:3472:14: note: each undeclared identifier is reported only once for each function it appears in
../block/file-posix.c:3476:14: error: ‘BLKCLOSEZONE’ undeclared (first use in this function); did you mean ‘BLKRESETZONE’?
3476 | zo = BLKCLOSEZONE;
| ^~~~~~~~~~~~
| BLKRESETZONE
../block/file-posix.c:3480:14: error: ‘BLKFINISHZONE’ undeclared (first use in this function)
3480 | zo = BLKFINISHZONE;
| ^~~~~~~~~~~~~Older kernels didn't have these ioctls. I don't think it makes sense to enable file-posix zoned functionality without these ioctls.
I suggest changing the CONFIG_BLKZONED check in meson.build from:
config_host_data.set('CONFIG_BLKZONED', cc.has_header('linux/blkzoned.h'))
to:
config_host_data.set('CONFIG_BLKZONED', cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE'))
The <linux/asm/kvm.h> header file started using __DECLARE_FLEX_ARRAY() and QEMU doesn't have that macro:
linux-headers/asm/kvm.h:509:3: error: expected specifier-qualifier-list before '__DECLARE_FLEX_ARRAY'
509 | __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx);
| ^~~~~~~~~~~~~~~~~~~~You could update the sed command in scripts/update-linux-headers.sh to convert __DECLARE_FLEX_ARRAY(type, field) into type field[] or import the Linux macro definition of __DECLARE_FLEX_ARRAY().
Another failure is
https://gitlab.com/qemu-project/qemu/-/jobs/4202085991 where qemu-iotests is failing because the output has changed due to the addition of zoned fields to block stats.
Another failure is
https://gitlab.com/qemu-project/qemu/-/jobs/4202086041 where qemu-system-ppc seems to segfault.
You can find the CI results here: https://gitlab.com/qemu-project/qemu/-/pipelines/852908752
You can run the GitLab CI yourself like this:
$ git push -o ci.variable=QEMU_CI=2 your_gitlab_repo HEAD
Stefan