[Devel] [PATCH hci-8.2] dm-qcow2: report the unit L2 can unmap as discard granularity
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Tue Dec 1 03:13:08 MSK 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dm-qcow2: larger discard_granularity stops fstrim reclaiming
sub-unit extents
--
commit f99effe256258fbc884b886dfde94f2336c8f3b2
Author: Vasileios Anagnostoulis <vasileios.anagnostoulis at virtuozzo.com>
dm-qcow2: report the unit L2 can unmap as discard granularity
The patch changes qcow2_io_hints() to report the L2 unmap unit as discard_granularity. That unit is the subcluster with extended_l2 and the cluster otherwise. Before, it reported the host filesystem block size.
> diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
> index d445bfe1232a6..a343266fb1beb 100644
> --- a/drivers/md/dm-qcow2-target.c
> +++ b/drivers/md/dm-qcow2-target.c
> @@ -1117,10 +1117,15 @@ static void qcow2_io_hints(struct dm_target *ti, struct queue_limits *limits)
> if (sb->s_bdev)
> block_size = bdev_logical_block_size(sb->s_bdev);
> /*
> - * Even if this is less than discard_granularity of bdev,
> - * we can free a block on filesystem.
> + * Report the unit L2 can unmap: the subcluster with extended L2,
> + * the cluster otherwise. The block layer aligns discard split
> + * points to this granularity only; with a smaller one, a long
> + * discard that starts mid-cluster is split at the same offset
> + * inside every cluster, and the (sub)cluster under each split is
> + * covered only in part by both pieces, so neither unmaps it.
> */
> - limits->discard_granularity = sb->s_blocksize;
> + limits->discard_granularity = qcow2->ext_l2 ? qcow2->subclu_size :
> + qcow2->clu_size;
[Severity: Low]
Does this change drop host block reclaim for free extents smaller than the new granularity?
discard_granularity is also the minimum trim size that filesystems use. For example, ext4_trim_fs() raises minlen to the granularity, so free extents shorter than one cluster (or one subcluster with extended_l2) no longer reach dm-qcow2. Before the patch, such extents reached issue_discard(). It punched the host blocks even though L2 was not updated. With 1M clusters and no extended_l2, free runs under 1M are no longer reclaimed on the host.
The removed comment said the 4K granularity was deliberate ("we can free a block on filesystem"). Neither the new comment nor the commit message mentions this cost. Could they state that the trade-off is intended?
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/20261125-br-vstor-154496-v1-1-dd8d86661647@virtuozzo.com?part=1
More information about the Devel
mailing list