All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v7 0/6] dm-qcow2: truncate unused tail of image on suspend
@ 2026-10-22 14:50 Alexander Ivanov
  2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 1/6] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Alexander Ivanov @ 2026-10-22 14:50 UTC (permalink / raw)
  To: andrey.zhadchenko; +Cc: devel

Discard punches holes in place of freed clusters, but doesn't change
the file size. On postsuspend dm-qcow2 truncates the image file only
down to file_preallocated_area_start, so if clusters at the end of the
file are freed, the file never shrinks.

This series makes postsuspend scan the refcount blocks backward and
truncate the file to the end of the last used cluster. Close and
reload to RO go through postsuspend too, so the file is shrunk in these
cases as well.

Patch 1 adds qcow2_md_page_read_sync() helper, which is needed by the
scan. Patch 2 is a small cleanup of duplicate prefixes in QC_ERR/QC_INFO
messages. Patches 3-5 fix existing cases where the refcounts or the
dirty bit on disk don't reflect real cluster usage, which the scan
relies on. Patch 6 does the actual truncation.

https://virtuozzo.atlassian.net/browse/VSTOR-148171

v7:
- Patch 5: track whether the image was opened dirty in a new opened_dirty
  flag instead of checking the parsed header, which is reread on resume
  and may carry the bit set by the kernel itself (e.g. on the lower image
  of a cancelled backward merge). A new kernel_dirty_bit flag tells
  whether the bit on disk is the kernel's own.
- Patch 6: use opened_dirty to skip the scan.

v6:
- Add Reviewed-by lines to patches 1 and 2.
- Patch 2: fix "pase" typo in a message touched by the patch.
- Patches 3-5: new patches.
- Patch 6: drop Reviewed-by, as the patch changed a lot.
- Patch 6: mark L1/L2 pages, whose failed writeback reverted refcounts
  of new clusters, with MD_LX_REVERTED and report it via the new
  lx_writeback_error flag, which skips the scan and is included in
  wants_check.
  Set md_writeback_error if relocate_refcount_table() fails
  after the new header is written, and clamp the scan start to
  reftable_max_file_size.
  Skip the scan for an image opened with the dirty bit set
  when kernel_sets_dirty_bit is enabled.
  Check the R1 entry before calc_r2_page_id(), so a corrupted
  one fails the scan without WARN.
  Reword the commit message to make clear that discard does
  free the clusters but doesn't shrink the file.

v5:
- Add Reviewed-by line.

v4:
- Patch 1: document in the comment that the caller must ensure no read
  of the page is in flight.
- Patch 3: say in the commit message that close and reload to RO go
  through postsuspend too.

v3:
- Split from the common series with dm-ploop: dm-ploop patches are
  sent as a separate series.
- Patch 1: rename qcow2_get_md_page_sync() to qcow2_md_page_read_sync(),
  reword commit message and comment.
- Patch 2: new patch.
- Patch 3: start the scan from file_preallocated_area_start instead of
  the end of the file and clamp the result to it, as the last cluster
  may be partial; print the scan error with %pe and drop the duplicate
  "dm-qcow2:" prefix from it.

v2:
- Add dm-ploop support (patches 3-6), as requested in v1 review.
- dm-qcow2: move get_md_page_sync() to a separate patch as
  qcow2_md_page_read_sync() and use it in qcow2_parse_header() as well.
- dm-qcow2: start the refcount scan below file_preallocated_area_start
  instead of the end of the file, and truncate to the used end directly
  instead of min(file_preallocated_area_start, used end).

Alexander Ivanov (6):
  dm-qcow2: add qcow2_md_page_read_sync() helper
  dm-qcow2: drop duplicate prefix from QC_ERR/QC_INFO messages
  dm-qcow2: extend the file in place_r2() before linking the refblock
  dm-qcow2: complete wbd before ending the data qio
  dm-qcow2: keep the dirty bit of an image opened dirty
  dm-qcow2: truncate unused tail of image on suspend

 drivers/md/dm-qcow2-cmd.c    |   4 +-
 drivers/md/dm-qcow2-map.c    | 109 ++++++++++++++++++++++++++++---
 drivers/md/dm-qcow2-target.c | 122 +++++++++++++++++++++++++++--------
 drivers/md/dm-qcow2.h        |  10 ++-
 4 files changed, 205 insertions(+), 40 deletions(-)

-- 
2.53.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-10-26 10:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 14:50 [Devel] [PATCH hci-8.1 v7 0/6] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 1/6] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
2026-10-22 14:55   ` no-reply
2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 2/6] dm-qcow2: drop duplicate prefix from QC_ERR/QC_INFO messages Alexander Ivanov
2026-10-22 14:53   ` no-reply
2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 3/6] dm-qcow2: extend the file in place_r2() before linking the refblock Alexander Ivanov
2026-10-22 14:56   ` no-reply
2026-10-26 10:52   ` Andrey Zhadchenko
2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 4/6] dm-qcow2: complete wbd before ending the data qio Alexander Ivanov
2026-10-22 14:58   ` no-reply
2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 5/6] dm-qcow2: keep the dirty bit of an image opened dirty Alexander Ivanov
2026-10-22 14:58   ` no-reply
2026-10-22 14:50 ` [Devel] [PATCH hci-8.1 v7 6/6] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-22 15:02   ` no-reply
2026-10-23  6:40     ` Alexander Ivanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.