[Qemu-devel] [PATCH v4 0/2] Truncate the tail of the image file in qcow2 shrinking

Pavel Butsykin posted 2 patches 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170929121613.25997-1-pbutsykin@virtuozzo.com
Test checkpatch passed
Test docker passed
Test s390x passed
block/qcow2-refcount.c | 22 ++++++++++++++++++++++
block/qcow2.c          | 27 +++++++++++++++++++++++++--
block/qcow2.h          |  1 +
3 files changed, 48 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH v4 0/2] Truncate the tail of the image file in qcow2 shrinking
Posted by Pavel Butsykin 6 years, 6 months ago
Now after shrinking the qcow2 image, at the end of the image file, there might
be a tail that probably will never be used. Although it will not bring any
tangible benefit, we can cut the tail if it is. Yes, it will not free up disk
space, but if the blocks were be allocated sequentially and the image is not
heavily fragmented then the virtual size of the image file will be commensurate
with the real size. It also doesn't look like a great plus.. Well, at least we
can discuss it.

Changes from v1:
- rewrite qcow2_get_last_cluster() function according to Max's comments. (2)

Changes from v2:
- report a warning if truncation of the tail of the image file failed. (2)

Pavel Butsykin (2):
  qcow2: fix return error code in qcow2_truncate()
  qcow2: truncate the tail of the image file after shrinking the image

 block/qcow2-refcount.c | 22 ++++++++++++++++++++++
 block/qcow2.c          | 27 +++++++++++++++++++++++++--
 block/qcow2.h          |  1 +
 3 files changed, 48 insertions(+), 2 deletions(-)

-- 
2.14.1


Re: [Qemu-devel] [PATCH v4 0/2] Truncate the tail of the image file in qcow2 shrinking
Posted by Max Reitz 6 years, 6 months ago
On 2017-09-29 14:16, Pavel Butsykin wrote:
> Now after shrinking the qcow2 image, at the end of the image file, there might
> be a tail that probably will never be used. Although it will not bring any
> tangible benefit, we can cut the tail if it is. Yes, it will not free up disk
> space, but if the blocks were be allocated sequentially and the image is not
> heavily fragmented then the virtual size of the image file will be commensurate
> with the real size. It also doesn't look like a great plus.. Well, at least we
> can discuss it.
> 
> Changes from v1:
> - rewrite qcow2_get_last_cluster() function according to Max's comments. (2)
> 
> Changes from v2:
> - report a warning if truncation of the tail of the image file failed. (2)
> 
> Pavel Butsykin (2):
>   qcow2: fix return error code in qcow2_truncate()
>   qcow2: truncate the tail of the image file after shrinking the image
> 
>  block/qcow2-refcount.c | 22 ++++++++++++++++++++++
>  block/qcow2.c          | 27 +++++++++++++++++++++++++--
>  block/qcow2.h          |  1 +
>  3 files changed, 48 insertions(+), 2 deletions(-)

Thanks, applied to my block branch:

https://github.com/XanClic/qemu/commits/block

Max