Re: [Qemu-devel] [PATCH v2 0/2] Truncate the tail of the image file in qcow2 shrinking
On 22.09.2017 12:50, Daniel P. Berrange wrote: On Fri, Sep 22, 2017 at 12:39:24PM +0300, 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. If the block backend has discard support enabled, can't we get the tail to be discarded rather than merely truncated ? It has already been implemented. (see https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04581.html) Sorry, I just forgot to mention that this patch rebased on Max's block branch (https://github.com/XanClic/qemu/commits/block). Actually the truncation will always be done on the already discarded area. It can be useful only if the block backend doesn't support discard or a file system doesn't support sparse files. Regards, Daniel
Re: [Qemu-devel] [PATCH v2 0/2] Truncate the tail of the image file in qcow2 shrinking
On Fri, Sep 22, 2017 at 12:39:24PM +0300, 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. If the block backend has discard support enabled, can't we get the tail to be discarded rather than merely truncated ? Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
[Qemu-devel] [PATCH v2 0/2] Truncate the tail of the image file in qcow2 shrinking
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) 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