All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v2 0/6] truncate unused tail of images on suspend
@ 2026-10-08  7:38 Alexander Ivanov
  2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 1/6] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Alexander Ivanov @ 2026-10-08  7:38 UTC (permalink / raw)
  To: den; +Cc: devel

Preallocated space and clusters at the end of an image freed by discard
are never given back, so the image file never shrinks. Truncate the
unused tail of the top image on suspend in both dm-qcow2 and dm-ploop,
so that userspace doesn't have to do it by hand.

dm-qcow2 (patches 1-2) finds the end of the last cluster with nonzero
refcount by scanning refcount blocks backward and truncates the image
to it on postsuspend.

dm-ploop needs more preparation. On "dmsetup reload" the new ploop
reads metadata in ploop_ctr(), while IO still goes through the old one,
so after resume it may work with outdated BAT and file sizes. Patches
3-4 fix a raw delta handling bug and factor out ploop_read_delta(),
patch 5 reloads all the metadata in ploop_preresume(), and patch 6
truncates the top delta to the end of the last used cluster (BAT area,
mapped cluster or format extension) on postsuspend.

The corresponding ploop userspace changes:
https://bitbucket.org/openvz/ploop.ovz/pull-requests/486

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

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: truncate unused tail of image on suspend
  dm-ploop: set delta is_raw before applying its mappings
  dm-ploop: factor out ploop_read_delta() from ploop_add_delta()
  dm-ploop: reload metadata on resume
  dm-ploop: truncate unused tail of top delta on suspend

 drivers/md/dm-ploop-bat.c    | 229 +++++++++++++++++++++++++++++++++--
 drivers/md/dm-ploop-map.c    |  26 +++-
 drivers/md/dm-ploop-target.c | 100 +++++++++++----
 drivers/md/dm-ploop.h        |   8 +-
 drivers/md/dm-qcow2-map.c    |  53 ++++++++
 drivers/md/dm-qcow2-target.c |  48 +++++++-
 drivers/md/dm-qcow2.h        |   3 +
 7 files changed, 421 insertions(+), 46 deletions(-)

-- 
2.53.0

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

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

end of thread, other threads:[~2026-10-08 11:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08  7:38 [Devel] [PATCH hci-8.1 v2 0/6] truncate unused tail of images on suspend Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 1/6] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
2026-10-08  7:43   ` no-reply
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 2/6] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-08  7:44   ` no-reply
2026-10-08  9:50   ` Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 3/6] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-10-08  7:46   ` no-reply
2026-10-08 10:42   ` Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 4/6] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-10-08  7:46   ` no-reply
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 5/6] dm-ploop: reload metadata on resume Alexander Ivanov
2026-10-08  7:54   ` no-reply
2026-10-08 11:46   ` Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 6/6] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-10-08  7:52   ` no-reply

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.