[Devel] [PATCH hci-8.2 4/9] dm-qcow2: map fast path writes without md_pages_lock
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Tue Dec 1 03:25:52 MSK 2026
> From: Denis V. Lunev <den at openvz.org>
>
> Fast path writes still take md_pages_lock in parse_metadata() to map
> the cluster and count themselves in the L2 page's active_writers. With
> reads off the lock it is the remaining global serialization point for
> an overwrite workload.
>
> Map plain writes of allocated clusters through
> parse_metadata_lockless() too, then count the write and recheck the
> L2 page's md->gen. A discard that unmaps the cluster locks its index,
> which bumps md->gen, long before it waits for writers in
> delay_discard_if_writers(). With a full barrier on both sides, either
> the write sees the new md->gen, uncounts itself and takes the locked
> path, or the discard sees the count and waits for the write to finish
> before the cluster can be reused. The barrier is taken on entry, so a
> discard that re-enters to recheck the generation it waits for is
> covered as well.
>
> The write reads md->writer_gen without the lock. If it reads the
> generation the discard has just switched to, the switch comes after
> the md->gen bump and the discard's barrier, so the write's recheck
> sees the bump and backs off. If it reads the old one, the discard
> waits for it as for any earlier write.
>
> Discards and write-zeroes keep the locked parse.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-95494
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Denis V. Lunev <den at openvz.org>
Sashiko has reviewed this patch and found no issues.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply at sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125012525.681662-1-den@openvz.org?part=4
More information about the Devel
mailing list