From: Damien Le Moal <dlemoal@kernel.org>
To: Kyrylo Biryuk <illofspeed@gmail.com>, dm-devel@lists.linux.dev
Cc: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com,
bmarzins@redhat.com, shinichiro.kawasaki@wdc.com, hare@suse.de,
hare@kernel.org, song@kernel.org, yukuai@fygo.io,
magiclinan@didiglobal.com, xiao@kernel.org, john.garry@linux.dev,
abd.masalkhi@gmail.com, linux-block@vger.kernel.org,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] dm-table: take the zone size from the zoned devices of a target
Date: Thu, 3 Dec 2026 15:39:54 +0900 [thread overview]
Message-ID: <b9f0f10e-ce6c-4171-a2c8-a57f74fafe09@kernel.org> (raw)
In-Reply-To: <20261202202631.664896-1-illofspeed@gmail.com>
On 2026/12/03 5:26, Kyrylo Biryuk wrote:
> dm_calculate_queue_limits() stacks the queue limits of all devices of a
> target and, for the first target whose stacked limits are zoned, records
> the stacked chunk_sectors as the zone size. validate_hardware_zoned()
> then requires every zoned device of the table to have that zone size.
>
> A target with DM_TARGET_MIXED_ZONED_MODEL (dm-zoned) can also map a
> regular device, and blk_stack_limits() combines chunk_sectors with
> gcd(). The chunk_sectors of a regular device is an I/O boundary, not a
> zone size. (A zone size is an I/O boundary too, because BIOs are split
> at zone boundaries, but the gcd() of the two need not be a zone size.) If
> the regular device's chunk_sectors is not zero and not a multiple of the
> zone size, the recorded zone size is smaller than the zone size of the
> zoned devices, and the check fails on the zoned device itself:
>
> device-mapper: table: 253:0: zone sectors is not consistent across all zoned devices
> device-mapper: core: Cannot calculate initial queue limits
> device-mapper: ioctl: unable to set up device queue for new table.
>
> dm-zoned's .io_hints sets chunk_sectors back to the zone size and clears
> BLK_FEAT_ZONED, so the zone size taken from the final table limits at
> the end of dm_calculate_queue_limits() does not replace the wrong value.
>
> Such regular devices have become common. md RAID0 arrays report their
> chunk size since commit 4b8beba60d32 ("md/raid0: set chunk_sectors
> limit"), md RAID10 arrays since commit 7ef50c4c6a9c ("md/raid10: set
> chunk_sectors limit"), and md RAID1 arrays start from
> BARRIER_UNIT_SECTOR_SIZE (131072 sectors) before stacking the limits of
> their members since commit 86d801e895b8 ("md/raid1: restrict atomic
> write limits and handle runtime constraints"). With a host-managed drive
> with 256 MiB zones, dm-zoned can no longer use an md RAID1 array, an md
> RAID0 array whose chunk size is not a multiple of the zone size, or a
> dm-linear mapping on top of one, as its regular device. md RAID5,
> dm-stripe and NVMe namespaces that report an I/O boundary set
> chunk_sectors as well.
>
> Take the zone size from the first zoned device of the target instead.
> Every zoned device of the table must still have that zone size, and
> tables whose final limits are zoned (dm-linear, dm-crypt, dm-flakey and
> similar targets on zoned devices, where every device must be zoned)
> still take the zone size from the final limits, as before. The stacked
> limits of a target are only zoned if one of its devices is zoned, so the
> iteration always finds one.
>
> Reproducer: a zoned null_blk device (256 MiB zones) as the zoned device
> and an md RAID1 of two loop devices as the regular device; "dmzadm
> --format" succeeds and "dmzadm --start" fails as above.
>
> Tested on v7.4-rc5 with lockdep, KASAN and DEBUG_ATOMIC_SLEEP: dm-zoned
> now starts with md RAID1, md RAID0 (512 KiB chunk) and dm-linear on md
> RAID1 as the regular device. Tables whose zoned devices have different
> zone sizes are still refused: by the dm-zoned constructor before
> dm-table checks them, and for dm-linear by the check against the final
> limits, which this patch does not change.
>
> LLM coding assistants (Claude Code, with reviews by OpenAI, Google
> Gemini and GitHub Copilot models) were used for the root cause analysis
> and for drafts of the code, this changelog and the tests.
>
> Fixes: 2d669ceb69c2 ("dm table: Fix zoned model check and zone sectors check")
> Cc: stable@vger.kernel.org # 6.18.x
> Signed-off-by: Kyrylo Biryuk <illofspeed@gmail.com>
> ---
>
> Changes since RFC (review by Damien Le Moal):
> - Set zoned = true in the BLK_FEAT_ZONED branch: the if already checks the
> flag (suggested in the review).
> - Reworded the I/O-boundary text in the commit message and in the code
> comment: a zone size is also an I/O boundary; the point is that a regular
> device's chunk_sectors is not a zone size, so a gcd() over the devices
> need not be one either.
> - Sent as a single patch with no cover letter.
> - No functional change: zoned = true is equivalent to the RFC's assignment.
>
> drivers/md/dm-table.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 48f25ab6b..4c39c97f3 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -1742,6 +1742,17 @@ static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *
> return bdev_zone_sectors(dev->bdev) != *zone_sectors;
> }
>
> +static int device_get_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
> + sector_t start, sector_t len, void *data)
> +{
> + unsigned int *zone_sectors = data;
> +
> + if (!bdev_is_zoned(dev->bdev))
> + return 0;
> + *zone_sectors = bdev_zone_sectors(dev->bdev);
> + return 1;
> +}
> +
> /*
> * Check consistency of zoned model and zone sectors across all targets. For
> * zone sectors, if the destination device is a zoned block device, it shall
> @@ -1815,8 +1826,17 @@ int dm_calculate_queue_limits(struct dm_table *t,
> * After stacking all limits, validate all devices
> * in table support this zoned model and zone sectors.
> */
> - zoned = (ti_limits.features & BLK_FEAT_ZONED);
> - zone_sectors = ti_limits.chunk_sectors;
> + zoned = true;
> + /*
> + * Take the zone size from the first zoned device. The
> + * stacked chunk_sectors can be the gcd() with the
> + * chunk_sectors of a regular device that a mixed zoned
> + * model target (dm-zoned) maps. A regular device's
> + * chunk_sectors is not a zone size, so the stacked
> + * value need not be one either.
> + */
> + ti->type->iterate_devices(ti, device_get_zone_sectors,
> + &zone_sectors);
> }
Having the comment in the middle of 2 lines of code is a little odd. I would
move the "zoned = true;" statement after the comment to make things pretty :)
Other than that, looks OK to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
>
> /* Set I/O hints portion of queue limits */
>
> base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
Damien Le Moal
Western Digital Research
prev parent reply other threads:[~2026-12-03 6:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 12:10 [RFC PATCH 0/1] dm-table: dm-zoned refuses md RAID1/RAID0 as its regular device Kyrylo Biryuk
2026-12-01 12:10 ` [RFC PATCH 1/1] dm-table: take the zone size from the zoned devices of a target Kyrylo Biryuk
2026-12-02 7:00 ` Damien Le Moal
2026-12-02 6:49 ` [RFC PATCH 0/1] dm-table: dm-zoned refuses md RAID1/RAID0 as its regular device Damien Le Moal
2026-12-02 20:29 ` Kyrylo Biryuk
2026-12-02 20:26 ` [PATCH v2] dm-table: take the zone size from the zoned devices of a target Kyrylo Biryuk
2026-12-03 6:39 ` Damien Le Moal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b9f0f10e-ce6c-4171-a2c8-a57f74fafe09@kernel.org \
--to=dlemoal@kernel.org \
--cc=abd.masalkhi@gmail.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=hare@kernel.org \
--cc=hare@suse.de \
--cc=illofspeed@gmail.com \
--cc=john.garry@linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=mpatocka@redhat.com \
--cc=shinichiro.kawasaki@wdc.com \
--cc=snitzer@kernel.org \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox