OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 0/3] dm-qcow2: do not free a discarded cluster under in-flight writes
@ 2026-11-12 11:12 Andrey Zhadchenko
  2026-11-12 11:12 ` [Devel] [PATCH hci-8.1 1/3] dm-qcow2: count in-flight data writes per L2 page Andrey Zhadchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Andrey Zhadchenko @ 2026-11-12 11:12 UTC (permalink / raw)
  To: khorenko, alexander.ivanov; +Cc: devel

A discard unmapping a cluster locks its L2 index, so requests coming
later wait until the discard is finished. But a data write, which has
resolved the index before it was locked, may still be in flight when
the discard drops the cluster refcount in process_indexes_end(). If
the cluster is allocated again before this write lands, the write
corrupts the data or the metadata of the new owner.

Make such a discard wait for these writes before the cluster is freed:

Patch 1 counts in-flight data writes per L2 page in two generations.
Nobody reads the counters yet, so there is no functional change.

Patch 2 is the fix. The discard switches the generation of its L2 page
and waits for the previous one to drain right before the refcount is
dropped. Writes submitted after the switch are counted separately, so
the wait is bounded by the writes already in flight.

Patch 3 is an optimisation. Discards of clusters mapped by one L2 page
usually come to process_indexes_end() in one batch. Let them wait for
the same generation together instead of one by one.

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

Andrey Zhadchenko (3):
  dm-qcow2: count in-flight data writes per L2 page
  dm-qcow2: wait for in-flight writes before freeing a discarded cluster
  dm-qcow2: let discards of one L2 page wait for in-flight writes
    together

 drivers/md/dm-qcow2-map.c    | 118 +++++++++++++++++++++++++++++++++++
 drivers/md/dm-qcow2-target.c |   6 ++
 drivers/md/dm-qcow2.h        |  12 ++++
 3 files changed, 136 insertions(+)

-- 
2.43.5

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

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

end of thread, other threads:[~2026-11-12 19:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 11:12 [Devel] [PATCH hci-8.1 0/3] dm-qcow2: do not free a discarded cluster under in-flight writes Andrey Zhadchenko
2026-11-12 11:12 ` [Devel] [PATCH hci-8.1 1/3] dm-qcow2: count in-flight data writes per L2 page Andrey Zhadchenko
2026-11-12 11:22   ` no-reply
2026-11-12 18:59   ` Konstantin Khorenko
2026-11-12 11:12 ` [Devel] [PATCH hci-8.1 2/3] dm-qcow2: wait for in-flight writes before freeing a discarded cluster Andrey Zhadchenko
2026-11-12 11:26   ` no-reply
2026-11-12 11:47     ` Andrey Zhadchenko
2026-11-12 18:59   ` Konstantin Khorenko
2026-11-12 11:12 ` [Devel] [PATCH hci-8.1 3/3] dm-qcow2: let discards of one L2 page wait for in-flight writes together Andrey Zhadchenko
2026-11-12 11:24   ` no-reply
2026-11-12 18:59   ` Konstantin Khorenko
2026-11-12 12:40 ` [Devel] [PATCH hci-8.1 0/3] dm-qcow2: do not free a discarded cluster under in-flight writes Alexander Ivanov
2026-11-12 18:59 ` Konstantin Khorenko
2026-11-12 19:00 ` Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox