[Devel] [PATCH hci-8.1 v9 10/10] dm-qcow2: truncate unused tail of image on suspend

Konstantin Khorenko khorenko at virtuozzo.com
Tue Nov 3 20:50:49 MSK 2026


I won't apply this version, please send v10 with the changes below.

On 10/28/26 16:06, Alexander Ivanov wrote:
> inconsistent. Userspace checks the image before opening it RW, which
> find_unused_cluster() already relies on when it reuses clusters with
> zero refcount.

- Drop the find_unused_cluster() argument, and say plainly that in
  the default mode the scan is safe only because userspace checks the
  image before an RW open.
- Say that v2 images are covered only by that check too.
- Split the paragraphs longer than four sentences.

The allocator reuses a wrongly free cluster only on an allocating
write, and it takes the lowest free cluster first, so it reaches the
tail last. The scan reads the tail on every RW suspend. After a crash
the stale refcounts are exactly at the tail, because L2 goes out with
the request and refblocks wait for the slow writeback. So the two do
not carry the same risk.

A v2 image has no dirty bit, so the opened_dirty guard never applies
to it.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team



More information about the Devel mailing list