[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded cluster
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters |
Date: |
Fri, 21 Feb 2014 17:01:05 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
On 02/21/2014 03:11 PM, Kevin Wolf wrote:
> Instead of making the backing file contents visible again after a discard
> request, set the zero flag if possible (i.e. on version >= 3).
>
> Signed-off-by: Kevin Wolf <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> ---
> block/qcow2-cluster.c | 22 ++++++++++++++++++++--
> tests/qemu-iotests/046 | 18 ++++++++++++++----
> 2 files changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index c57f39d..36c1bed 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -1367,13 +1367,31 @@ static int discard_single_l2(BlockDriverState *bs,
> uint64_t offset,
> uint64_t old_offset;
>
> old_offset = be64_to_cpu(l2_table[l2_index + i]);
> - if ((old_offset & L2E_OFFSET_MASK) == 0) {
> +
> + /*
> + * Make sure that a discarded area reads back as zeroes for v3 images
> + * (we cannot do it for v2 without actually writing a zero-filled
> + * buffer). We can skip the operation if the cluster is already
> marked
> + * as zero, or if it's unallocated and we don't have a backing file.
> + *
Possible idea for a followup:
Is it possible with v2 images to write a single sector/cluster with all
0s, and to make all other writes of all-0 data bump the reference count
of the magic known-zero cluster, so that we are at least conserving disk
space by heavily reusing the known cluster?
Then again, we may be reaching the point where no one cares about v2
images as much.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PULL 00/54] Block patches, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 02/54] block: Fix bdrv_is_first_non_filter(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters, Kevin Wolf, 2014/02/21
- Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters,
Eric Blake <=
- [Qemu-devel] [PULL 03/54] block: Change BDS parameter of bdrv_open() to **, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 05/54] block: Make bdrv_file_open() static, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 04/54] block: Add reference parameter to bdrv_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 06/54] block: Reuse reference handling from bdrv_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 07/54] block: Remove bdrv_new() from bdrv_file_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 08/54] block: Handle bs->options in bdrv_open() only, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 09/54] block: Reuse success path from bdrv_open(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 10/54] block: Remove bdrv_open_image()'s force_raw option, Kevin Wolf, 2014/02/21