[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 08/19] block drivers: add discard/write_zeroe
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v3 08/19] block drivers: add discard/write_zeroes properties to bdrv_get_info implementation |
Date: |
Tue, 03 Dec 2013 16:21:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9 |
Il 03/12/2013 16:09, Kevin Wolf ha scritto:
>> > BDRVQcowState *s = bs->opaque;
>> > + bdi->unallocated_blocks_are_zero = true;
>> > + bdi->can_write_zeroes_with_unmap = (s->qcow_version >= 3);
>> > bdi->cluster_size = s->cluster_size;
>> > bdi->vm_state_offset = qcow2_vm_state_offset(s);
>> > return 0;
> We must change qcow2_discard_clusters() to set the zero flag instead of
> just deallocating the cluster. (We should be doing that anyway, because
> the backing file reappearing isn't very nice.)
No, that's not needed:
* unallocated_blocks_are_zero is only meaningful for bs->backing_hd ==
NULL (not too intuitive, but I didn't introduce that interface :)). In
fact, v2 was checking backing_hd == NULL but I removed it after Peter
noticed I was being inconsistent.
* can_write_zeroes_with_unmap correctly returns true only if zero
clusters are enabled
> For the other formats, I guess this is only correct because they don't
> implement discard anyway?
No, it is correct because that's what their bdrv_co_readv (or similar)
will return when a block is not allocated and there is no backing file.
Of course, for many formats there will never be a backing file.
Paolo