From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: den@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v2 0/6] truncate unused tail of images on suspend
Date: Thu, 8 Oct 2026 09:38:30 +0200 [thread overview]
Message-ID: <20261008073837.510678-1-alexander.ivanov@virtuozzo.com> (raw)
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
next reply other threads:[~2026-10-08 7:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 7:38 Alexander Ivanov [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261008073837.510678-1-alexander.ivanov@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=devel@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox