Applying with these fixes on my side:
- the example: bios [0, 8) and [16, 24) in sectors instead of
[0, 512) and [1024, 1536) with no unit
- "range in the file" -> "range of the device", "always" dropped
- added why the limit is USHRT_MAX and what the user sees, split into
paragraphs
On Mon, 09 Nov 2026 18:36:18 +0300, Andrey Zhadchenko wrote:
> Imagine we have a request with starting sector 0 and length 1024,
> so read or write means [0, 1024) range in the file. For discard this
> request can have 2 bios [0, 512) and [1024, 1536), but we always
> discarded [0, 1024).
qcow2_io_hints() caps max_hw_discard_sectors at one cluster, so with
the default 64K cluster a 1024-sector request is never built.
blk_rq_pos() is an offset on the device, the file offset comes from the
L2 table. The message now reads:
Discard is a special type of request that can have non-contiguous
bios: dm-qcow2 keeps the dm stacking default max_discard_segments =
USHRT_MAX, so the block layer merges discard bios with gaps.
Imagine we have a request with starting sector 0 and length 16
sectors, so read or write means the [0, 16) range of the device. For
discard this request can have 2 bios [0, 8) and [16, 24), but we
discarded [0, 16).
Data in sectors 8-15 reads back as zeroes, and sectors 16-23 are not
discarded.
Set max_discard_segments to 1 to avoid such merges.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel