History

virtio-blk: fix to match virtio spec

The merged patch series to support zoned block devices in virtio-blk is not the most up to date version. The merged patch can be found at https://lore.kernel.org/linux-block/20221016034127.330942-3-dmitry.fomichev@wdc.com/ but the latest and reviewed version is https://lore.kernel.org/linux-block/20221110053952.3378990-3-dmitry.fomichev@wdc.com/ The reason is apparently that the correct mailing lists and maintainers were not copied. The differences between the two are mostly cleanups, but there is one change that is very important in terms of compatibility with the approved virtio-zbd specification. Before it was approved, the OASIS virtio spec had a change in VIRTIO_BLK_T_ZONE_APPEND request layout that is not reflected in the current virtio-blk driver code. In the running code, the status is the first byte of the in-header that is followed by some pad bytes and the u64 that carries the sector at which the data has been written to the zone back to the driver, aka the append sector. This layout turned out to be problematic for implementing in QEMU and the request status byte has been eventually made the last byte of the in-header. The current code doesn't expect that and this causes the append sector value always come as zero to the block layer. This needs to be fixed ASAP.

Dmitry Fomichev committed 3 years ago

Commit f1ba4e61 parent 7e364e52 files · +166 −90Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/virtio_blk.h+9−9
@@ -140,11 +140,11 @@ struct virtio_blk_config { · 139 unmodified lines
140 140
141 /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */141 /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
142 struct virtio_blk_zoned_characteristics {142 struct virtio_blk_zoned_characteristics {
143 __le32 zone_sectors;143 __virtio32 zone_sectors;
144 __le32 max_open_zones;144 __virtio32 max_open_zones;
145 __le32 max_active_zones;145 __virtio32 max_active_zones;
146 __le32 max_append_sectors;146 __virtio32 max_append_sectors;
147 __le32 write_granularity;147 __virtio32 write_granularity;
148 __u8 model;148 __u8 model;
149 __u8 unused2[3];149 __u8 unused2[3];
150 } zoned;150 } zoned;
@@ -241,11 +241,11 @@ struct virtio_blk_outhdr { · 90 unmodified lines
241 */241 */
242struct virtio_blk_zone_descriptor {242struct virtio_blk_zone_descriptor {
243 /* Zone capacity */243 /* Zone capacity */
244 __le64 z_cap;244 __virtio64 z_cap;
245 /* The starting sector of the zone */245 /* The starting sector of the zone */
246 __le64 z_start;246 __virtio64 z_start;
247 /* Zone write pointer position in sectors */247 /* Zone write pointer position in sectors */
248 __le64 z_wp;248 __virtio64 z_wp;
249 /* Zone type */249 /* Zone type */
250 __u8 z_type;250 __u8 z_type;
251 /* Zone state */251 /* Zone state */
@@ -254,7 +254,7 @@ struct virtio_blk_zone_descriptor { · 2 unmodified lines
254};254};
255 255
256struct virtio_blk_zone_report {256struct virtio_blk_zone_report {
257 __le64 nr_zones;257 __virtio64 nr_zones;
258 __u8 reserved[56];258 __u8 reserved[56];
259 struct virtio_blk_zone_descriptor zones[];259 struct virtio_blk_zone_descriptor zones[];
260};260};