[Devel] [PATCH hci-8.1 v3 0/5] dm-ploop: truncate unused tail of top delta on suspend

Alexander Ivanov alexander.ivanov at virtuozzo.com
Thu Oct 8 17:03:28 MSK 2026


Preallocated space and clusters at the end of the top delta freed by
discard are never given back, so the delta file never shrinks. This
series makes dm-ploop truncate the unused tail of the top delta on
suspend, so that userspace doesn't have to do it by hand.

This needs some 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.

Patch 1 fixes a lost wakeup of the allocator thread, which may leave
a preallocation request pending forever, so waiting for it on suspend
would hang. Patch 2 fixes raw and empty delta handling, patch 3
factors out ploop_read_delta(), patch 4 reloads all the metadata in
ploop_preresume(), and patch 5 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

v3:
- Split from the common series with dm-qcow2: dm-qcow2 patches are
  sent as a separate series. Patches 3-6 of v2 are patches 2-5 now.
- Patch 1: new patch.
- Patch 2: also skip applying the mappings of an empty delta, as BAT
  iterators can't handle nr_be == 0.
- Patch 4: wait for inflight_md on postsuspend, as data bios are
  completed before BAT writeback is finished, and use wake_up() for
  inflight_md_wq; reload metadata under memalloc_noio_save(), as the
  device is suspended; restore m_Sig, m_Type and m_Sectors on reload
  failure.
- Patch 5: don't truncate anything if m_FormatExtensionOffset is not
  cluster-aligned or out of range; truncate under memalloc_noio_save().

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 (5):
  dm-ploop: fix lost wakeup in ploop_allocator()
  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    | 260 +++++++++++++++++++++++++++++++++--
 drivers/md/dm-ploop-map.c    |  77 +++++++----
 drivers/md/dm-ploop-target.c | 122 ++++++++++++----
 drivers/md/dm-ploop.h        |   8 +-
 4 files changed, 403 insertions(+), 64 deletions(-)

-- 
2.53.0



More information about the Devel mailing list