[Devel] [PATCH hci-8.1 v9 10/10] dm-qcow2: truncate unused tail of image on suspend
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Wed Oct 28 18:21:15 MSK 2026
> Discard punches holes in place of freed clusters, so they hold no
> physical extents, but it doesn't change the file size. On postsuspend
> we truncate the image file only down to file_preallocated_area_start,
> i.e. we drop preallocations only. So if clusters at the end of the
> file are freed (refcount dropped to zero), the file size stays the
> same and the image never shrinks.
>
> Add qcow2_calc_used_end(), which scans refcount blocks backward from
> file_preallocated_area_start and returns the end of the last cluster
> with non-zero refcount, clamped to file_preallocated_area_start since
> the last cluster may be partial. Refcount ranges with no allocated
> refblock are skipped at once. The scan walks R1 entries normal I/O may
> never touch, so it validates them itself instead of letting
> calc_r2_page_id() WARN on a corrupted one. Metadata pages are taken from
> md cache or read synchronously. This is called on suspended device after
> [ ... ]
>
> https://virtuozzo.atlassian.net/browse/VSTOR-148171
> Feature: dm-qcow2: block device over QCOW2 files driver
>
> Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261028150645.3222391-1-alexander.ivanov@virtuozzo.com?part=10
More information about the Devel
mailing list