[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 09/16] block/qcow2: Generalize preallocate()
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 09/16] block/qcow2: Generalize preallocate() |
Date: |
Tue, 30 May 2017 16:26:18 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 |
On 05/26/2017 11:55 AM, Max Reitz wrote:
> This patch adds two new parameters to the preallocate() function so we
> will be able to use it not just for preallocating a new image but also
> for preallocated image growth.
>
> The offset parameter allows the caller to specify a virtual offset from
> which to start preallocating. For newly created images this is always 0,
> but for preallocating growth this will be the old image length.
>
> The new_length parameter specifies the supposed new length of the image
> (basically the "end offset" for preallocation). During image truncation,
> bdrv_getlength() will return the old image length so we cannot rely on
> its return value then.
bdrv_getlength() is (currently) always sector-aligned (rounding up as
needed).
new_length is passed from qcow2_create2()'s total_size, which in turn
comes from qcow2_create()'s size, which can be user-supplied - but also
appears that we round up to ensure it is always sector-aligned.
Testing: 'qemu-img create -f qcow2 a.img 1' reports "size=1", but
'qemu-img info a.img' reports "virtual size: 512" - so we have a
secondary bug worth fixing later in that we are rounding AFTER what we
report to the user, but I'm not seeing a behavior change in this patch.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v3 02/16] block: Add PreallocMode to bdrv_truncate(), (continued)
- [Qemu-devel] [PATCH v3 02/16] block: Add PreallocMode to bdrv_truncate(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 03/16] block: Add PreallocMode to blk_truncate(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 04/16] qemu-img: Expose PreallocMode for resizing, Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 05/16] block/file-posix: Small fixes in raw_create(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 06/16] block/file-posix: Extract raw_regular_truncate(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 07/16] block/file-posix: Generalize raw_regular_truncate, Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 08/16] block/file-posix: Preallocation for truncate, Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 09/16] block/qcow2: Generalize preallocate(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 10/16] block/qcow2: Lock s->lock in preallocate(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 11/16] block/qcow2: Metadata preallocation for truncate, Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 13/16] block/qcow2: Rename "fail_block" to just "fail", Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 12/16] block/qcow2: Add qcow2_refcount_area(), Max Reitz, 2017/05/26
- [Qemu-devel] [PATCH v3 14/16] block/qcow2: falloc/full preallocating growth, Max Reitz, 2017/05/26