Am 13.11.2013 um 10:44 schrieb Paolo Bonzini <pbonz...@redhat.com>: > Il 13/11/2013 07:29, Peter Lieven ha scritto: >> Wouldn't it be good to add bdi->can_write_zeroes_with_unmap here as well? > > We do: > >> + bdi->unallocated_blocks_are_zero = s->discard_zeroes; >> + bdi->can_write_zeroes_with_unmap = s->discard_zeroes;
Sorry, I missed this. > >> This would automatically avoid full allocation when converting something to >> a host device >> supporting BLKDISCARDZEROES. > > Yes, that's (part of) the point of this patch. > > Regarding the question you posed in the previous patch: > >> does BLKDISCARDZEROES ioctl guarantee that a device is >> zero initialized or does it just guarantee that a discard may not >> fail and that it reads as zeroes afterwards? > > Only the latter. ".bdrv_has_zero_init" is only present in the bdrv_file > BlockDriver. Then bdi->unallocated_blocks_are_zero must stay 0. .bdrv_has_zero_init's semantic is to reflect the zero status of all blocks of the device right after bdrv_create independently of their allocation status. bdi->unallocated_blocks_are_zero reflects the zero status of every unallocated block regardless if it was unallocated right from the beginning or became unallocated through a discard. Peter