On 15/08/2018 17:12, Jakub Jermar wrote:
> In the absence of such a conforming patch, I would kindly ask someone to
> clarify the relationship between the virtio_blk_discard_write_zeroes
> structures and the virtio descriptor. [1] seems to indicate that there
> is always one struct virtio_blk_discard_write_zeroes per descriptor, but
> the wording is not very clear. If the containing descriptor must be a
> multiple of 512 in size (because of u8 data[][512]),
The descriptors are intended to be a multiple of 16 bytes in size for
discard and write zeroes.
In fact, even for reads/writes the descriptors are a multiple of the
logical block size, not of 512. That ought to be corrected as well.
> there is no way to
> figure out how many of these structs it contains. So there must be only
> one and the only way to add a segment is to chain descriptors.
No, it does not matter how descriptors are chained. Data is always
treated as if it was just one descriptor.
> Unless
> the descriptor size is somehow allowed to be a multiple of sizeof(struct
> virtio_blk_discard_write_zeroes) in which case it could be determined
> and there may be several of these structures per descriptor.
>
> Also, why is it that there is discard_sector_alignment but no
> write_zeroes_sector_alignment?
You can use discard_zeroes_alignment too if unmap=1 in the descriptor's
flags. If unmap=0, it doesn't matter.
Paolo