Add full zoned storage emulation to the qcow2 driver
Subsystems (2)
v19 cover Add full zoned storage emulation to the qcow2 driver
This patch series adds a new extension - zoned format - to the qcow2 driver, allowing full zoned storage emulation on a qcow2 image file. A user can attach such an image to a guest and have it appear as a host-managed zoned block device.
The zoned format is opt-in through a new qcow2 header extension that pins the zone geometry. Behind the extension is a dedicated zoned metadata region that stores one 8-byte write pointer (WP) per zone. The extension is gated by an incompatible bit, so an older qcow2 implementation cannot accidentally open the image.
Each write pointer is routed through the write pointer cache, a Qcow2Cache object. The write pointer cache is written to disk after the qcow2 metadata is written, thus guaranteeing that the write pointer is updated after the corresponding data is written.
Zone states are in memory. Read-only and offline states are device-internal events, which are not modelled in qcow2 emulation for simplicity. The other zone states (closed, empty, full) can be inferred from write pointer values, persistent across QEMU reboots. The open states are kept in memory using open zone lists.
To create a qcow2 file with the zoned format:
qemu-img create -f qcow2 zbc.qcow2 \
-o size=768M \
-o zone.size=64M \
-o zone.capacity=64M \
-o zone.conventional_zones=0 \
-o zone.max_open_zones=6 \
-o zone.max_active_zones=8 \
-o zone.mode=host-managedThen attach it to a guest via the QEMU command line:
-blockdev node-name=drive1,driver=qcow2,file.driver=file,file.filename=zbc.qcow2 \
-device virtio-blk-pci,drive=drive1 \Tested with blktests, fio, zbd_state (an internal test suite) and zonefs, comparing a zoned qcow2 image attached via virtio-blk with zloop, null_blk and scsi_debug (passed/failed/skipped):
+--------------------+----------+---------+-----------+---------+
| Testrun | blktests | fio | zbd_state | zonefs |
+--------------------+----------+---------+-----------+---------+
| zloop | 9/0/10 | 57/0/18 | 29/0/8 | 113/0/0 |
| null_blk | 9/0/10 | 57/0/18 | 29/0/8 | 113/0/0 |
| scsi_debug | 10/0/12 | 61/0/14 | 29/0/8 | 113/0/0 |
| virtio-blk + qcow2 | 9/0/10 | 57/0/18 | 29/0/8 | 113/0/0 |
+--------------------+----------+---------+-----------+---------+The last two patches are not used by the qcow2 driver. Both Daejun Park's zoned UFS series and an upcoming series that adds zoned support to ATA depend on this series, and both also require these two patches, so they are included here, to avoid both series needing to carry them separately as dependencies.
Git branch can be found at:
https://github.com/floatious/qemu/tree/qcow2-v19
v18->v19:
- Do not allow to resize a qcow2 zoned image. Shrinking the image is not possible in a simple way because of the write pointers. Extending the image is theoretically possible, but would add complexity. Could be implemented in the future if anyone has a use case for it. Reported by Daejun Park.
- Write zeroes does not update the cached write pointers. This is an existing bug even in file-posix, so it is not a new bug introduced by the qcow2 zoned support. Add a new patch 1 that uses the regular write path for write zeroes. (In qcow2, zone resets will still use write zeroes, since it calls qcow2_co_pwrite_zeroes() directly.) Reported by Daejun Park.
Niklas Cassel (6):
block: write zeroes to a host managed device through the write path
block: define errnos for zone protocol errors
qcow2: validate the write pointer table when opening an image
virtio-blk: report zone errors with their zone status codes
block: add accessors for the zone model, capacity and open zone limit
scsi: add the sense codes of zoned block devices
Sam Li (5):
docs/qcow2: add the zoned format feature
qcow2: add configurations for zoned format extension
qcow2: do not flush when a cache dependency is already set
qcow2: add zoned emulation capability
iotests: test the zoned format feature for qcow2 file
MAINTAINERS | 1 + block/block-backend.c | 33 + block/io.c | 23 +- block/qcow2-cache.c | 11 +- block/qcow2-refcount.c | 18 + block/qcow2.c | 1736 ++++++++++++++++- block/qcow2.h | 86 +- block/trace-events | 10 + docs/interop/qcow2.rst | 115 +- docs/system/qemu-block-drivers.rst.inc | 44 + hw/block/block.c | 7 + hw/block/virtio-blk.c | 49 +- include/block/block-common.h | 17 + include/block/block-io.h | 6 + include/block/block_int-common.h | 12 + include/qemu/osdep.h | 6 + include/scsi/utils.h | 6 + include/system/block-backend-io.h | 3 + qapi/block-core.json | 86 +- scsi/utils.c | 15 + tests/qemu-iotests/031.out | 8 +- tests/qemu-iotests/036.out | 4 +- tests/qemu-iotests/061.out | 14 +- tests/qemu-iotests/082.out | 108 + tests/qemu-iotests/303.out | 4 +- tests/qemu-iotests/tests/qcow2-encryption.out | 4 +- tests/qemu-iotests/tests/zoned | 9 + tests/qemu-iotests/tests/zoned-qcow2 | 379 ++++ tests/qemu-iotests/tests/zoned-qcow2.out | 267 +++ tests/qemu-iotests/tests/zoned.out | 12 + 30 files changed, 3042 insertions(+), 51 deletions(-) create mode 100755 tests/qemu-iotests/tests/zoned-qcow2 create mode 100644 tests/qemu-iotests/tests/zoned-qcow2.out
base-commit: 29760efaf96bbe5928f8111881eddbf5ac06439e
Signature · 1 line
2.56.1
PATCH v19 1/11 block: write zeroes to a host managed device through the write path
On a host managed zoned device, a write zeroes request moves the write pointer, like a write. For a write zeroes request, however, file-posix does not update the copy of the write pointer that it keeps for zone appends, so the next zone append, also after a zero write that detect-zeroes converts, fails with EIO.
Write the zeroes through the write path of the driver instead, which updates the write pointer, and extend the zoned test.
--- block/io.c | 10 +++++++--- tests/qemu-iotests/tests/zoned | 9 +++++++++ tests/qemu-iotests/tests/zoned.out | 12 ++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-)
block/io.c +7 -3
@@ -1918,15 +1918,19 @@ bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, } ret = -ENOTSUP ; -/* First try the efficient write zeroes operation */ -if (drv->bdrv_co_pwrite_zeroes) { +/* +* First try the efficient write zeroes operation, except on a host +* managed zoned device, where only the write path checks and moves +* the write pointer: there, the zeroes are written as data below. +*/ +if (drv->bdrv_co_pwrite_zeroes && bs->bl.zoned !=BLK_Z_HM ) { ret = drv->bdrv_co_pwrite_zeroes (bs, offset, num, flags & bs->supported_zero_flags);if (ret != -ENOTSUP && (flags &BDRV_REQ_FUA ) && !(bs->supported_zero_flags &BDRV_REQ_FUA )) { need_flush = true; } - }else { + }else if (!drv->bdrv_co_pwrite_zeroes) {assert (!bs->supported_zero_flags); }
tests/qemu-iotests/tests/zoned +9 -0
@@ -99,6 +99,15 @@ $QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000" echo "After appending the second zone secondly:" $QEMU_IO $IMG -c "zrp 268435456 1" +echo +echo "(7) append write after a zero write" +$QEMU_IO $IMG -c "write -z 536870912 0x1000" -c "zap -p 536870912 0x1000" \ + -c "zrp 536870912 1" | _filter_qemu_io +echo +echo "(8) append write after a zero write with detect-zeroes" +$QEMU_IO $IMG,detect-zeroes=on -c "write -P 0 805306368 0x1000" \ + -c "zap -p 805306368 0x1000" -c "zrp 805306368 1" | _filter_qemu_io + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/tests/zoned.out +12 -0
@@ -66,4 +66,16 @@ 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] + +(7) append write after a zero write +wrote 4096/4096 bytes at offset 536870912 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +After zap done, the append sector is 0x100008 +start: 0x100000, len 0x80000, cap 0x80000, wptr 0x100010, zcond:2, [type: 2] + +(8) append write after a zero write with detect-zeroes +wrote 4096/4096 bytes at offset 805306368 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +After zap done, the append sector is 0x180008 +start: 0x180000, len 0x80000, cap 0x80000, wptr 0x180010, zcond:2, [type: 2] *** done
Signature · 1 line
2.56.1
PATCH v19 2/11 docs/qcow2: add the zoned format feature
In reply to Niklas CasselFrom: Sam Li <[email protected]>
Add the specs for the zoned format feature of the qcow2 driver. The qcow2 file then can emulate real zoned devices, either passed through by virtio-blk device or NVMe ZNS drive to the guest given zoned information.
--- docs/system/qemu-block-drivers.rst.inc | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
docs/system/qemu-block-drivers.rst.inc +44 -0
@@ -172,6 +172,50 @@ This section describes each format and the options that are supported for it. filename`` to check if the NOCOW flag is set or not (Capital 'C' is NOCOW flag). + .. option:: zone.mode + + If this is set to ``host-managed``, the image is an emulated zoned + block device. This option is only valid for emulated zoned device files. + + .. option:: zone.size + + The size of a zone in bytes. The device is divided into zones of this + size with the exception of the last zone, which may be smaller. + Defaults to ``256 MiB``. + + .. option:: zone.capacity + + The initial capacity value, in bytes, for all zones. The capacity must + be less than or equal to zone size. If the last zone is smaller, then + its capacity is capped. Defaults to ``zone.size``. + + The zone capacity is per zone and may be different between zones in real + devices. QCow2 sets all zones to the same capacity. + + .. option:: zone.conventional_zones + + The number of conventional zones of the zoned device. Defaults to ``0`` + (all zones are sequential-write-required). + + .. option:: zone.max_active_zones + + The maximum allowed active zones (zones in the implicit open, explicit + open, or closed state). + + The max active zones must be less or equal to the number of SWR + (sequential write required) zones of the device. Defaults to ``0``, + meaning no limit. + + .. option:: zone.max_open_zones + + The maximum allowed open zones (zones in the implicit open or explicit + open state). The max open zones must not be larger than the max active + zones. Defaults to ``zone.max_active_zones`` if that is set, otherwise + ``0`` (no limit). + + If the limits of open zones or active zones are equal to the number of + SWR zones, then it is the same as having no limits. + .. program:: image-formats .. option:: qed
Signature · 1 line
2.56.1
PATCH v19 3/11 qcow2: add configurations for zoned format extension
In reply to Niklas CasselFrom: Sam Li <[email protected]>
To configure the zoned format feature on the qcow2 driver, it requires settings as: the device size, zone model, zone size, zone capacity, number of conventional zones, limits on zone resources (max open zones and max active zones).
To create a qcow2 image with zoned format feature, use command like this:
qemu-img create -f qcow2 zbc.qcow2 -o size=768M \
-o zone.size=64M -o zone.capacity=64M -o zone.conventional_zones=0 \
-o zone.max_open_zones=6 -o zone.max_active_zones=8 \
-o zone.mode=host-managed
--- block/io.c | 13 +- block/qcow2.c | 344 +++++++++++++++++- block/qcow2.h | 29 +- docs/interop/qcow2.rst | 115 +++++- hw/block/block.c | 7 + include/block/block-io.h | 6 + include/block/block_int-common.h | 12 + qapi/block-core.json | 86 ++++- tests/qemu-iotests/031.out | 8 +- tests/qemu-iotests/036.out | 4 +- tests/qemu-iotests/061.out | 14 +- tests/qemu-iotests/082.out | 108 ++++++ tests/qemu-iotests/303.out | 4 +- tests/qemu-iotests/tests/qcow2-encryption.out | 4 +- 14 files changed, 727 insertions(+), 27 deletions(-)
block/io.c +10 -3
@@ -3406,13 +3406,20 @@ bool bdrv_zone_is_conv(BlockDriverState *bs, uint32_t index)return BDRV_ZT_IS_CONV (bs->wps->wp[index]); } +uint64_t bdrv_zone_writable_end (BlockDriverState *bs,uint32_t index) +{ +uint64_t writable =MIN_NON_ZERO (bs->bl.zone_capacity, bs->bl.zone_size); +IO_CODE (); + +return MIN ((uint64_t )index * bs->bl.zone_size + writable, + (uint64_t )bs->total_sectors <<BDRV_SECTOR_BITS ); +} +bool bdrv_zone_is_full (BlockDriverState *bs,uint32_t index) { -uint64_t zone_end =MIN ((uint64_t )(index +1 ) * bs->bl.zone_size, - (uint64_t )bs->total_sectors <<BDRV_SECTOR_BITS );IO_CODE (); -return bs->wps->wp[index] >= zone_end; +return bs->wps->wp[index] >=bdrv_zone_writable_end (bs, index); }void *qemu_blockalign (BlockDriverState *bs,size_t size)
block/qcow2.c +341 -3
458 lines not on this page · raw message
block/qcow2.h +28 -1
@@ -129,6 +129,11 @@#define DEFAULT_CLUSTER_SIZE 65536 +#define DEFAULT_ZONE_SIZE (256 * MiB) + +#define QCOW2_Z_NONE 0/* Regular block device */ +#define QCOW2_Z_HM 1/* Host-managed zoned block device */ +#define QCOW2_OPT_DATA_FILE "data-file"#define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"#define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
@@ -237,6 +242,22 @@ typedef struct Qcow2CryptoHeaderExtension {uint64_t length; }QEMU_PACKED Qcow2CryptoHeaderExtension; +/* Maximum number of zones a zoned image can have. */ +#define QCOW2_MAX_NR_ZONES (1U << 20) + +typedef struct Qcow2ZonedHeaderExtension { +/* Zoned device attributes */ +uint8_t zoned; +uint8_t reserved[3 ]; +uint32_t nr_zones; +uint64_t zone_size; +uint64_t zone_capacity; +uint64_t zonedmeta_offset; +uint32_t conventional_zones; +uint32_t max_active_zones; +uint32_t max_open_zones; +} QEMU_PACKED Qcow2ZonedHeaderExtension; + typedef struct Qcow2UnknownHeaderExtension { uint32_t magic; uint32_t len;
@@ -257,17 +278,20 @@ enum {QCOW2_INCOMPAT_DATA_FILE_BITNR =2 ,QCOW2_INCOMPAT_COMPRESSION_BITNR =3 ,QCOW2_INCOMPAT_EXTL2_BITNR =4 , +QCOW2_INCOMPAT_ZONED_FORMAT_BITNR =5 ,QCOW2_INCOMPAT_DIRTY =1 <<QCOW2_INCOMPAT_DIRTY_BITNR ,QCOW2_INCOMPAT_CORRUPT =1 <<QCOW2_INCOMPAT_CORRUPT_BITNR ,QCOW2_INCOMPAT_DATA_FILE =1 <<QCOW2_INCOMPAT_DATA_FILE_BITNR ,QCOW2_INCOMPAT_COMPRESSION =1 <<QCOW2_INCOMPAT_COMPRESSION_BITNR ,QCOW2_INCOMPAT_EXTL2 =1 <<QCOW2_INCOMPAT_EXTL2_BITNR , +QCOW2_INCOMPAT_ZONED_FORMAT =1 <<QCOW2_INCOMPAT_ZONED_FORMAT_BITNR ,QCOW2_INCOMPAT_MASK =QCOW2_INCOMPAT_DIRTY |QCOW2_INCOMPAT_CORRUPT |QCOW2_INCOMPAT_DATA_FILE |QCOW2_INCOMPAT_COMPRESSION - | QCOW2_INCOMPAT_EXTL2, + |QCOW2_INCOMPAT_EXTL2 + | QCOW2_INCOMPAT_ZONED_FORMAT, };/* Compatible feature bits */
@@ -426,6 +450,9 @@ typedef struct BDRVQcow2State {* is to convert the image with the desired compression type set. */ Qcow2CompressionType compression_type; + +/* States of zoned device */ +Qcow2ZonedHeaderExtension zoned_header; } BDRVQcow2State; typedef struct Qcow2COWRegion {
docs/interop/qcow2.rst +114 -1
133 lines not on this page · raw message
hw/block/block.c +7 -0
@@ -238,6 +238,13 @@ bool blkconf_check_zoned_geometry(BlockConf *conf, Error **errp)return false; } +if (!QEMU_IS_ALIGNED (bs->bl.zone_capacity, wg)) { +error_setg (errp,"zone capacity %" PRIu64" is not a multiple of the " +"zone write granularity %" PRIu32, + bs->bl.zone_capacity, wg); +return false; + } +/* * A write pointer that is not a multiple of the write granularity does not * fall on a logical block boundary, so the guest can neither read nor write
include/block/block-io.h +6 -0
@@ -134,6 +134,12 @@ uint32_t bdrv_zone_index(BlockDriverState *bs, uint64_t offset);* bdrv_zone_is_full() this does not need the write pointer lock. */ bool bdrv_zone_is_conv (BlockDriverState *bs,uint32_t index); +/* +* The offset at which the writable part of a zone ends. That is a zone +* capacity beyond the start of the zone, except for a last zone that the +* capacity of the device cuts short. +*/ +uint64_t bdrv_zone_writable_end (BlockDriverState *bs,uint32_t index);/* * True when the write pointer of a zone has reached the end of the writable * part of that zone, so that nothing more can be written to it until it is
include/block/block_int-common.h +12 -0
@@ -57,6 +57,12 @@#define BLOCK_OPT_COMPRESSION_TYPE "compression_type"#define BLOCK_OPT_EXTL2 "extended_l2"#define BLOCK_OPT_KEEP_DATA_FILE "keep_data_file" +#define BLOCK_OPT_ZONE_MODEL "zone.mode" +#define BLOCK_OPT_ZONE_SIZE "zone.size" +#define BLOCK_OPT_ZONE_CAPACITY "zone.capacity" +#define BLOCK_OPT_CONVENTIONAL_ZONES "zone.conventional_zones" +#define BLOCK_OPT_MAX_ACTIVE_ZONES "zone.max_active_zones" +#define BLOCK_OPT_MAX_OPEN_ZONES "zone.max_open_zones"#define BLOCK_PROBE_BUF_SIZE 512
@@ -911,6 +917,12 @@ typedef struct BlockLimits {*/ uint32_t zone_size_bits; +/* +* The number of usable logical blocks within the zone, expressed +* in bytes. A zone capacity is smaller or equal to the zone size. +*/ +uint64_t zone_capacity; +/* total number of zones */ uint32_t nr_zones;
qapi/block-core.json +84 -2
116 lines not on this page · raw message
tests/qemu-iotests/031.out +4 -4
@@ -117,7 +117,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> Header extension:
@@ -150,7 +150,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> Header extension:
@@ -164,7 +164,7 @@ No errors were found on the image. magic 0x514649fb version 3 -backing_file_offset 0x240 +backing_file_offset 0x270 backing_file_size 0x17 cluster_bits 16 size 67108864
@@ -188,7 +188,7 @@ data 'host_device' Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> Header extension:
tests/qemu-iotests/036.out +2 -2
@@ -26,7 +26,7 @@ compatible_features [] autoclear_features [63] Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary>
@@ -38,7 +38,7 @@ compatible_features [] autoclear_features [] Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> *** done
tests/qemu-iotests/061.out +7 -7
@@ -26,7 +26,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> magic 0x514649fb
@@ -84,7 +84,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> magic 0x514649fb
@@ -140,7 +140,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> ERROR cluster 5 refcount=0 reference=1
@@ -195,7 +195,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> magic 0x514649fb
@@ -264,7 +264,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> read 65536/65536 bytes at offset 44040192
@@ -326,7 +326,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> ERROR cluster 5 refcount=0 reference=1
@@ -355,7 +355,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> read 131072/131072 bytes at offset 0
tests/qemu-iotests/082.out +108 -0
216 lines not on this page · raw message
tests/qemu-iotests/303.out +2 -2
@@ -47,7 +47,7 @@ header_length 112 Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> Header extension:
@@ -133,7 +133,7 @@ wrote 1048576/1048576 bytes at offset 7340032 { "name": "Feature table", "magic": 1745090647, - "length": 384, + "length": 432, "data_str": "<binary>" }, {
tests/qemu-iotests/tests/qcow2-encryption.out +2 -2
@@ -10,7 +10,7 @@ data <binary> Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> image: TEST_DIR/t.IMGFMT
@@ -24,7 +24,7 @@ No errors were found on the image. Header extension: magic 0x6803f857 (Feature table) -length 384 +length 432 data <binary> qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Missing CRYPTO header for crypt method 2
Signature · 1 line
2.56.1
PATCH v19 4/11 block: define errnos for zone protocol errors
In reply to Niklas CasselA block driver that emulates zones (e.g. qcow2 with the zoned format feature) rejects requests that violate the zone protocol, and the device model has to report each of these to the guest with the matching zone error (ZAC/ZBC sense data, virtio-blk zone status codes, ...). It can only do so if each condition comes with an errno of its own, rather than a generic one such as EIO.
Define one for each condition:
BLK_ZE_UNALIGNED_WRITE ESPIPE write not at the write pointer BLK_ZE_BOUNDARY ERANGE write past the zone capacity BLK_ZE_OPEN_RESOURCE ETOOMANYREFS open zone limit reached BLK_ZE_ACTIVE_RESOURCE EOVERFLOW active zone limit reached BLK_ZE_FULL EXFULL write to a full zone
ETOOMANYREFS and EOVERFLOW are what Linux returns for BLK_STS_ZONE_OPEN_RESOURCE and BLK_STS_ZONE_ACTIVE_RESOURCE, so a host zoned device used through file-posix already reports the same values. For the boundary case, ERANGE is used rather than EFBIG, which the host file system can legitimately return for an image file.
A write that is not at the write pointer gets ESPIPE, which file and block device I/O never return, rather than EINVAL, which a zoned driver also uses for invalid requests such as an invalid zone state transition. So a device model can map each of these errnos to its zone error without having to know which request failed.
A full zone has no write pointer, and ZAC, ZBC, NVMe ZNS and virtio-blk all report a write to a full zone differently from a write that is not at the write pointer, so it gets its own errno, EXFULL.
ETOOMANYREFS is not POSIX and EXFULL is Linux-specific, so provide fallbacks for hosts that lack them.
--- include/block/block-common.h | 17 +++++++++++++++++ include/qemu/osdep.h | 6 ++++++ 2 files changed, 23 insertions(+)
include/block/block-common.h +17 -0
@@ -125,6 +125,23 @@ typedef struct BlockZoneDescriptor {BlockZoneState state; } BlockZoneDescriptor; +/* +* Errors that zoned block drivers report for zone protocol violations, as +* positive errno values (drivers return them negated). Each condition has an +* errno of its own that zoned block drivers do not return for anything else, +* so that device models can report the matching zone error to the guest +* whichever request failed. In particular, EINVAL is not used, as it also +* reports invalid requests, such as an invalid zone state transition. The +* zone resource errors are the errnos Linux uses for BLK_STS_ZONE_OPEN_RESOURCE +* and BLK_STS_ZONE_ACTIVE_RESOURCE, so a host zoned device accessed through +* file-posix reports the same values. +*/ +#define BLK_ZE_UNALIGNED_WRITE ESPIPE/* write not at write pointer */ +#define BLK_ZE_BOUNDARY ERANGE/* write past zone capacity */ +#define BLK_ZE_OPEN_RESOURCE ETOOMANYREFS/* open zone limit reached */ +#define BLK_ZE_ACTIVE_RESOURCE EOVERFLOW/* active zone limit reached */ +#define BLK_ZE_FULL EXFULL/* write to a full zone */ +/* * Track write pointers of a zone in bytes. */
include/qemu/osdep.h +6 -0
@@ -353,6 +353,12 @@ void QEMU_ERROR("code path is reachable")#if !defined(ESHUTDOWN )#define ESHUTDOWN 4099#endif +#if !defined(ETOOMANYREFS ) +#define ETOOMANYREFS 4100 +#endif +#if !defined(EXFULL ) +#define EXFULL 4101 +#endif #define RETRY_ON_EINTR (expr) \ (__extension__ \
Signature · 1 line
2.56.1
PATCH v19 5/11 qcow2: do not flush when a cache dependency is already set
In reply to Niklas CasselFrom: Sam Li <[email protected]>
qcow2_cache_set_dependency() flushes the dependency cache whenever that one has a dependency of its own, even if the dependency to set is already in place. Return early in that case, which avoids a synchronous flush for a caller that keeps setting the same dependency.
This is safe: flushing a cache flushes its dependency first, so a chain is still written in order. With only the L2 table and refcount block caches, the early return never skips a flush, as a chain needs a third cache, such as the write pointer cache of a zoned image.
--- block/qcow2-cache.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
block/qcow2-cache.c +10 -1
@@ -275,14 +275,23 @@ int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, {int ret; +/* +* If the dependency graph is unchanged, nothing to do. This avoids +* a synchronous flush on every call below. +*/ +if (c->depends == dependency) { +return 0 ; + } +if (dependency->depends) { +/* Flatten any chain on the dependency side as a cycle-breaker. */ ret =qcow2_cache_flush_dependency (bs, dependency);if (ret <0 ) {return ret; } } -if (c->depends && (c->depends != dependency)) { +if (c->depends) { ret =qcow2_cache_flush_dependency (bs, c);if (ret <0 ) {return ret;
Signature · 1 line
2.56.1
PATCH v19 6/11 qcow2: add zoned emulation capability
In reply to Niklas CasselFrom: Sam Li <[email protected]>
By adding zone operations and zoned metadata, the zoned emulation capability enables full emulation support of zoned device using a qcow2 file. The zoned device metadata includes zone type, zoned device state and write pointer (WP) of each zone, which is stored to an array of unsigned integers.
WP accessor (qcow2_rw_wp_at) routes reads and writes of an 8-byte WP slot through the write pointer cache. The write pointer cache is written to disk after the qcow2 metadata is written, thus guaranteeing that the write pointer is updated after the corresponding data is written. Per-completion cache flush is deferred. The WP cluster reaches disk on the next flush.
Each zone of a zoned device makes state transitions following the zone state machine. The zone state machine mainly describes five states, IMPLICIT OPEN, EXPLICIT OPEN, FULL, EMPTY and CLOSED. READ ONLY and OFFLINE states will generally be affected by device internal events. The operations on zones cause corresponding state changing.
Zoned devices have limits on zone resources, which put constraints on write operations on zones. It is managed by active zone queues following LRU policy.
--- block/qcow2-refcount.c | 18 + block/qcow2.c | 1301 +++++++++++++++++++++++++++++++++++++++- block/qcow2.h | 57 ++ block/trace-events | 10 + 4 files changed, 1382 insertions(+), 4 deletions(-)
block/qcow2-refcount.c +18 -0
@@ -1239,6 +1239,13 @@ int qcow2_write_caches(BlockDriverState *bs) } } +if (s->wp_cache) { + ret =qcow2_cache_write (bs, s->wp_cache); +if (ret <0 ) { +return ret; + } + } +return 0 ; }
@@ -2304,6 +2311,17 @@ calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, } } +/* zoned metadata */ +if (s->zoned_header.zoned !=QCOW2_Z_NONE ) { + ret =qcow2_inc_refcounts_imrt (bs, res, refcount_table, nb_clusters, + s->zoned_header.zonedmeta_offset, + (int64_t )s->zoned_header.nr_zones * +sizeof (uint64_t )); +if (ret <0 ) { +return ret; + } + } +/* bitmaps */ ret =qcow2_check_bitmaps_refcounts (bs, res, refcount_table, nb_clusters, fix);
block/qcow2.c +1297 -4
1,420 lines not on this page · raw message
block/qcow2.h +57 -0
69 lines not on this page · raw message
block/trace-events +10 -0
@@ -70,12 +70,22 @@ luring_resubmit_short_io(void *req, int ndone) "req %p ndone %d" qcow2_add_task(void *co, void *bs, void *pool, const char *action, int cluster_type, uint64_t host_offset, uint64_t offset, uint64_t bytes, void *qiov, size_t qiov_offset) "co %p bs %p pool %p: %s: cluster_type %d file_cluster_offset %" PRIu64 " offset %" PRIu64 " bytes %" PRIu64 " qiov %p qiov_offset %zu" qcow2_writev_start_req(void *co, int64_t offset, int64_t bytes) "co %p offset 0x%" PRIx64 " bytes %" PRId64 qcow2_writev_done_req(void *co, int ret) "co %p ret %d" +qcow2_zone_write_conv_to_seq(void *bs, uint64_t end_offset) "bs %p end_offset 0x%" PRIx64 +qcow2_zone_write_full(void *bs, uint64_t zone_offset) "bs %p zone 0x%" PRIx64 +qcow2_zone_write_unaligned(void *bs, uint64_t offset, uint64_t wp) "bs %p offset 0x%" PRIx64 " wp 0x%" PRIx64 +qcow2_zone_write_past_capacity(void *bs, uint64_t end_sector, uint64_t zone_end_sector) "bs %p end 0x%" PRIx64 " zone end 0x%" PRIx64 +qcow2_zone_no_resources(void *bs, const char *kind) "bs %p no more %s zones available" +qcow2_zone_report_invalid(void *bs, int64_t offset, int64_t capacity) "bs %p offset %" PRId64 " capacity %" PRId64 +qcow2_zone_mgmt_invalid(void *bs, int op, int64_t offset, int64_t len, const char *reason) "bs %p op 0x%x offset %" PRId64 " len %" PRId64 ": %s" +qcow2_zone_append_invalid(void *bs, int64_t offset, const char *reason) "bs %p offset %" PRId64 ": %s" qcow2_writev_start_part(void *co) "co %p" qcow2_writev_done_part(void *co, int cur_bytes) "co %p cur_bytes %d" qcow2_writev_data(void *co, uint64_t offset) "co %p offset 0x%" PRIx64 qcow2_pwrite_zeroes_start_req(void *co, int64_t offset, int64_t bytes) "co %p offset 0x%" PRIx64 " bytes %" PRId64 qcow2_pwrite_zeroes(void *co, int64_t offset, int64_t bytes) "co %p offset 0x%" PRIx64 " bytes %" PRId64 qcow2_skip_cow(void *co, uint64_t offset, int nb_clusters) "co %p offset 0x%" PRIx64 " nb_clusters %d" +qcow2_wp_tracking(int index, uint64_t wp) "wps[%d]: 0x%" PRIx64 +qcow2_imp_open_zones(uint8_t op, int nrz) "nr_imp_open_zones after op 0x%x: %d" # qcow2-cluster.c qcow2_alloc_clusters_offset(void *co, uint64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d"
Signature · 1 line
2.56.1
PATCH v19 7/11 iotests: test the zoned format feature for qcow2 file
In reply to Niklas CasselFrom: Sam Li <[email protected]>
The zoned format feature can be tested by:
$ tests/qemu-iotests/check -qcow2 zoned-qcow2
--- MAINTAINERS | 1 + tests/qemu-iotests/tests/zoned-qcow2 | 357 +++++++++++++++++++++++ tests/qemu-iotests/tests/zoned-qcow2.out | 260 +++++++++++++++++ 3 files changed, 618 insertions(+) create mode 100755 tests/qemu-iotests/tests/zoned-qcow2 create mode 100644 tests/qemu-iotests/tests/zoned-qcow2.out
MAINTAINERS +1 -0
@@ -4537,6 +4537,7 @@ L: [email protected] S: Supported F: block/qcow2* F: docs/interop/qcow2.rst +F: tests/qemu-iotests/tests/zoned-qcow2* qcow M: Kevin Wolf <[email protected]>
tests/qemu-iotests/tests/zoned-qcow2 new file +357 -0
357 lines not on this page · raw message
tests/qemu-iotests/tests/zoned-qcow2.out new file +260 -0
260 lines not on this page · raw message
Signature · 1 line
2.56.1
PATCH v19 8/11 qcow2: validate the write pointer table when opening an image
In reply to Niklas CasselThe write pointer table is image content, but unlike the other zoned metadata, it is used without being checked. A write pointer below the start of its zone makes an append write into an earlier zone, and one that is not sector aligned cannot be reported to a guest.
Check that the conventional bit is set for exactly the zones that the header declares conventional, that a conventional zone records its own start, and that the write pointer of a sequential zone is sector aligned and within the writable part of its zone. Add a test case.
--- block/qcow2.c | 67 ++++++++++++++++++++++++ tests/qemu-iotests/tests/zoned-qcow2 | 22 ++++++++ tests/qemu-iotests/tests/zoned-qcow2.out | 7 +++ 3 files changed, 96 insertions(+)
block/qcow2.c +67 -0
@@ -520,6 +520,67 @@ qcow2_refresh_zonedmeta(BlockDriverState *bs)return 0 ; } +/* +* The write pointer table is image content and cannot be trusted. Check it +* against the zone geometry, which qcow2_check_zone_options() has already +* validated. The write pointer of a zone is the offset that an append to that +* zone is written to, so a corrupted table would otherwise misdirect a write: +* qcow2_co_pwv_part() only rejects a pointer that reaches beyond the end of +* its zone, and one that points below the start of its zone would send the +* data to a zone that the guest never asked to write. +*/ +static bool qcow2_check_zonedmeta (BlockDriverState *bs,Error **errp) +{ +BDRVQcow2State *s = bs->opaque; +uint32_t conv_zones = s->zoned_header.conventional_zones; +uint64_t zone_size = s->zoned_header.zone_size; +uint64_t capacity = (uint64_t )bs->total_sectors *BDRV_SECTOR_SIZE ; + +for (uint32_t i =0 ; i < s->zoned_header.nr_zones; i++) { +uint64_t wp = bs->wps->wp[i]; +uint64_t zone_start = (uint64_t )i * zone_size; +bool is_conv =QCOW2_ZT_IS_CONV (wp); +uint64_t zone_end; + +if (is_conv != (i < conv_zones)) { +error_setg (errp,"Zone %" PRIu32" contradicts the header, which " +"declares the first %" PRIu32" zones conventional" , + i, conv_zones); +return false; + } + +if (is_conv) { +if (QCOW2_GET_WP (wp) != zone_start) { +error_setg (errp,"Conventional zone %" PRIu32" has write " +"pointer 0x%" PRIx64" instead of the zone start " +"0x%" PRIx64, i, (uint64_t )QCOW2_GET_WP (wp), + zone_start); +return false; + } +continue ; + } + +/* The last zone is shorter when the capacity is not zone aligned */ + zone_end = zone_start +MIN (s->zoned_header.zone_capacity, + capacity - zone_start); + +if (wp < zone_start || wp > zone_end) { +error_setg (errp,"Zone %" PRIu32" has write pointer 0x%" PRIx64 +" outside its writable range 0x%" PRIx64"..0x%" PRIx64, + i, wp, zone_start, zone_end); +return false; + } + +if (!QEMU_IS_ALIGNED (wp,BDRV_SECTOR_SIZE )) { +error_setg (errp,"Zone %" PRIu32" has write pointer 0x%" PRIx64 +" that is not sector aligned" , i, wp); +return false; + } + } + +return true; +} +/* * Returns true if zone_opt is valid for an image with clusters of * @cluster_size bytes, false otherwise.
@@ -950,6 +1011,12 @@ qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,return ret; } +if (!qcow2_check_zonedmeta (bs, errp)) { +g_free (bs->wps); + bs->wps =NULL ; +return -EINVAL ; + } + s->zone_list_entries =g_new0 (Qcow2ZoneListEntry, zoned_ext.nr_zones);QTAILQ_INIT (&s->exp_open_zones);
tests/qemu-iotests/tests/zoned-qcow2 +22 -0
@@ -351,6 +351,28 @@ poke_file_be "$file_name" $wps_field 8 $wps echo "after restoring the offset:" $QEMU_IO $IMG -c "zrp 0 1" +echo +echo "case 10: a corrupted write pointer table is rejected" +$QEMU_IO $IMG -c "zrs 0 768M" + +# Zone 3 starts at 0xc000000. A write pointer below the start of its own zone +# is the dangerous one: an append would be redirected into an earlier zone. +poke_file_be "$file_name" $((wps + 8 * 3)) 8 0 +$QEMU_IO $IMG -c "zrp 0 1" +poke_file_be "$file_name" $((wps + 8 * 3)) 8 $((0xc000000)) + +poke_file_be "$file_name" $((wps + 8 * 1)) 8 $((0x4000200 + 1)) +$QEMU_IO $IMG -c "zrp 0 1" +poke_file_be "$file_name" $((wps + 8 * 1)) 8 $((0x4000000)) + +# Set the conventional bit on a zone the header declares sequential +poke_file_be "$file_name" $((wps + 8 * 2)) 1 $((0x80)) +$QEMU_IO $IMG -c "zrp 0 1" +poke_file_be "$file_name" $((wps + 8 * 2)) 1 0 + +echo "after restoring the table:" +$QEMU_IO $IMG -c "zrp 0 1" + # success, all done echo "*** done" rm -f $seq.full
tests/qemu-iotests/tests/zoned-qcow2.out +7 -0
@@ -257,4 +257,11 @@ qemu-io: can't open: Zoned metadata offset invalid qemu-io: can't open: Zoned metadata region exceeds the image file size after restoring the offset: start: 0x0, len 0x20000, cap 0x20000, wptr 0x0, zcond:1, [type: 2] + +case 10: a corrupted write pointer table is rejected +qemu-io: can't open: Zone 3 has write pointer 0x0 outside its writable range 0xc000000..0x10000000 +qemu-io: can't open: Zone 1 has write pointer 0x4000201 that is not sector aligned +qemu-io: can't open: Zone 2 contradicts the header, which declares the first 0 zones conventional +after restoring the table: +start: 0x0, len 0x20000, cap 0x20000, wptr 0x0, zcond:1, [type: 2] *** done
Signature · 1 line
2.56.1
PATCH v19 9/11 virtio-blk: report zone errors with their zone status codes
In reply to Niklas Casselvirtio-blk completes a failed write with VIRTIO_BLK_S_IOERR, and a failed zone append or zone management request with VIRTIO_BLK_S_ZONE_INVALID_CMD. It never reports the zone status codes that virtio 1.4 (5.2.6.2) requires for a write off the write pointer or for a request that exceeds a zone resource limit.
When VIRTIO_BLK_F_ZONED is negotiated, map the zone errors of the block layer to them:
BLK_ZE_UNALIGNED_WRITE VIRTIO_BLK_S_ZONE_UNALIGNED_WP BLK_ZE_BOUNDARY VIRTIO_BLK_S_ZONE_INVALID_CMD BLK_ZE_OPEN_RESOURCE VIRTIO_BLK_S_ZONE_OPEN_RESOURCE BLK_ZE_ACTIVE_RESOURCE VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE BLK_ZE_FULL VIRTIO_BLK_S_ZONE_INVALID_CMD
Other errors keep their status code. A FINISH that exceeds a zone resource limit also gets a zone resource status code, which 5.2.6 defines for any zone operation. Zone errors of writes are reported regardless of the rerror/werror policy, as they are the deterministic result of the request.
--- hw/block/virtio-blk.c | 49 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)
hw/block/virtio-blk.c +45 -4
@@ -78,11 +78,45 @@ void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)virtio_notify (vdev, req->vq); } +/* +* Map a zone error (see include/block/block-common.h) to its virtio-blk +* status, or return VIRTIO_BLK_S_OK if @error is not one. +*/ +static uint8_t virtio_blk_zone_status (VirtIOBlock *s,int error) +{ +if (!virtio_vdev_has_feature (VIRTIO_DEVICE (s),VIRTIO_BLK_F_ZONED )) { +return VIRTIO_BLK_S_OK ; + } + +switch (error) { +case BLK_ZE_UNALIGNED_WRITE : +return VIRTIO_BLK_S_ZONE_UNALIGNED_WP ; +case BLK_ZE_BOUNDARY : +case BLK_ZE_FULL : +return VIRTIO_BLK_S_ZONE_INVALID_CMD ; +case BLK_ZE_OPEN_RESOURCE : +return VIRTIO_BLK_S_ZONE_OPEN_RESOURCE ; +case BLK_ZE_ACTIVE_RESOURCE : +return VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE ; +default : +return VIRTIO_BLK_S_OK ; + } +} +static int virtio_blk_handle_rw_error (VirtIOBlockReq *req,int error,bool is_read) {VirtIOBlock *s = req->dev; -BlockErrorAction action =blk_get_error_action (s->blk, is_read, error); +uint8_t zone_status =virtio_blk_zone_status (s, error); +/* +* Zone errors are the deterministic result of the request, so they are +* reported whatever the rerror/werror policy: stopping the VM would only +* make the request fail the same way again when it is retried on resume, +* and ignoring the error would hide the failure from the guest. +*/ +BlockErrorAction action = zone_status !=VIRTIO_BLK_S_OK ? +BLOCK_ERROR_ACTION_REPORT : +blk_get_error_action (s->blk, is_read, error);if (action ==BLOCK_ERROR_ACTION_STOP ) {/* Break the link as the next request is going to be parsed from the
@@ -94,7 +128,8 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, s->rq = req; } }else if (action ==BLOCK_ERROR_ACTION_REPORT ) { -virtio_blk_req_complete (req,VIRTIO_BLK_S_IOERR ); +virtio_blk_req_complete (req, zone_status !=VIRTIO_BLK_S_OK ? + zone_status :VIRTIO_BLK_S_IOERR );block_acct_failed (blk_get_stats (s->blk), &req->acct);g_free (req); }
@@ -781,7 +816,10 @@ static void virtio_blk_zone_mgmt_complete(void *opaque, int ret)trace_virtio_blk_zone_mgmt_complete (vdev, req,ret);if (ret) { - err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ; + err_status =virtio_blk_zone_status (s, -ret); +if (err_status ==VIRTIO_BLK_S_OK ) { + err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ; + } }virtio_blk_req_complete (req, err_status);
@@ -841,7 +879,10 @@ static void virtio_blk_zone_append_complete(void *opaque, int ret)uint8_t err_status =VIRTIO_BLK_S_OK ;if (ret) { - err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ; + err_status =virtio_blk_zone_status (s, -ret); +if (err_status ==VIRTIO_BLK_S_OK ) { + err_status =VIRTIO_BLK_S_ZONE_INVALID_CMD ; + } goto out; }
Signature · 1 line
2.56.1
PATCH v19 10/11 block: add accessors for the zone model, capacity and open zone limit
In reply to Niklas CasselAdd the block-backend accessors blk_get_zone_model(), blk_get_zone_capacity() and blk_get_max_open_zones(), which report the zoned model, the zone capacity and the maximum number of open zones of the backing device, mirroring the existing blk_get_zone_size(). This lets device models query the zoned geometry without dereferencing BlockDriverState internals.
--- block/block-backend.c | 33 +++++++++++++++++++++++++++++++ include/system/block-backend-io.h | 3 +++ 2 files changed, 36 insertions(+)
block/block-backend.c +33 -0
@@ -2338,6 +2338,39 @@ uint64_t blk_get_zone_size(BlockBackend *blk)return bs ? bs->bl.zone_size :0 ; } +/* +* Returns the zoned model of @blk (BLK_Z_HM, BLK_Z_HA), or BLK_Z_NONE if +* @blk does not present zoned geometry. +*/ +BlockZoneModel blk_get_zone_model (BlockBackend *blk) +{ +BlockDriverState *bs =blk_bs (blk); +IO_CODE (); +return bs ? bs->bl.zoned :BLK_Z_NONE ; +} + +/* +* Returns the maximum number of simultaneously open zones for a zoned +* backend, or 0 if there is no limit or @blk is not zoned. +*/ +uint32_t blk_get_max_open_zones (BlockBackend *blk) +{ +BlockDriverState *bs =blk_bs (blk); +IO_CODE (); +return bs ? bs->bl.max_open_zones :0 ; +} + +/* +* Returns how many bytes of each zone of @blk can be written (the zone +* capacity), or 0 if that is not known. +*/ +uint64_t blk_get_zone_capacity (BlockBackend *blk) +{ +BlockDriverState *bs =blk_bs (blk); +IO_CODE (); +return bs ? bs->bl.zone_capacity :0 ; +} +/* Returns the optimal write zeroes alignment, in bytes; guaranteed nonzero */ uint32_t blk_get_pwrite_zeroes_alignment (BlockBackend *blk) {
include/system/block-backend-io.h +3 -0
@@ -122,6 +122,9 @@ uint32_t blk_get_pwrite_zeroes_alignment(BlockBackend *blk);uint32_t blk_get_max_transfer (BlockBackend *blk);uint64_t blk_get_max_hw_transfer (BlockBackend *blk);uint64_t blk_get_zone_size (BlockBackend *blk); +BlockZoneModel blk_get_zone_model (BlockBackend *blk); +uint32_t blk_get_max_open_zones (BlockBackend *blk); +uint64_t blk_get_zone_capacity (BlockBackend *blk); int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, BlockBackend *blk_out, int64_t off_out,
Signature · 1 line
2.56.1
PATCH v19 11/11 scsi: add the sense codes of zoned block devices
In reply to Niklas CasselAdd the sense codes that a zoned block device reports when a request violates the zone model (ZBC-2 and ZAC-2):
ILLEGAL REQUEST, UNALIGNED WRITE COMMAND (21h/04h): a write that does not start at the write pointer of a sequential write required zone
ILLEGAL REQUEST, WRITE BOUNDARY VIOLATION (21h/05h): a write that crosses the end of the writable part of a zone
DATA PROTECT, INSUFFICIENT ZONE RESOURCES (55h/0Eh): a request that would open or activate more zones than the device allows
The IDE device is going to report them for zoned devices.
--- include/scsi/utils.h | 6 ++++++ scsi/utils.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+)
include/scsi/utils.h +6 -0
@@ -69,6 +69,10 @@ extern const struct SCSISense sense_code_TARGET_FAILURE;extern const struct SCSISense sense_code_INVALID_OPCODE;/* Illegal request, LBA out of range */ extern const struct SCSISense sense_code_LBA_OUT_OF_RANGE; +/* Illegal request, Unaligned write command */ +extern const struct SCSISense sense_code_UNALIGNED_WRITE; +/* Illegal request, Write boundary violation */ +extern const struct SCSISense sense_code_WRITE_BOUNDARY_VIOLATION;/* Illegal request, Invalid field in CDB */ extern const struct SCSISense sense_code_INVALID_FIELD;/* Illegal request, Invalid field in parameter list */
@@ -119,6 +123,8 @@ extern const struct SCSISense sense_code_DEVICE_INTERNAL_RESET;extern const struct SCSISense sense_code_WRITE_PROTECTED;/* Data Protection, Space Allocation Failed Write Protect */ extern const struct SCSISense sense_code_SPACE_ALLOC_FAILED; +/* Data Protection, Insufficient zone resources */ +extern const struct SCSISense sense_code_INSUFFICIENT_ZONE_RESOURCES;#define SENSE_CODE (x) sense_code_ ## x
scsi/utils.c +15 -0
@@ -190,6 +190,16 @@ const struct SCSISense sense_code_LBA_OUT_OF_RANGE = { .key = ILLEGAL_REQUEST, .asc = 0x21, .ascq = 0x00 }; +/* Illegal request, Unaligned write command */ +const struct SCSISense sense_code_UNALIGNED_WRITE = { + .key =ILLEGAL_REQUEST , .asc =0x21 , .ascq =0x04 +}; + +/* Illegal request, Write boundary violation */ +const struct SCSISense sense_code_WRITE_BOUNDARY_VIOLATION = { + .key =ILLEGAL_REQUEST , .asc =0x21 , .ascq =0x05 +}; +/* Illegal request, Invalid field in CDB */ const struct SCSISense sense_code_INVALID_FIELD = { .key =ILLEGAL_REQUEST , .asc =0x24 , .ascq =0x00
@@ -330,6 +340,11 @@ const struct SCSISense sense_code_SPACE_ALLOC_FAILED = { .key = DATA_PROTECT, .asc = 0x27, .ascq = 0x07 }; +/* Data Protection, Insufficient zone resources */ +const struct SCSISense sense_code_INSUFFICIENT_ZONE_RESOURCES = { + .key =DATA_PROTECT , .asc =0x55 , .ascq =0x0e +}; +/* * scsi_convert_sense *
Signature · 1 line
2.56.1