On 11/12/26 03:49, Niklas Cassel wrote: > A 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. > > Signed-off-by: Niklas Cassel <[email protected]>
Looks OK to me. Reviewed-by: Damien Le Moal <[email protected]> -- Damien Le Moal Western Digital Research
