From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796194859; b=rDboVEGYTlpTyzvzN/V0gcCgMyu8SYce+klaDflci/Zut/MdDBKA/Mvgsv9uQDO4RIxj QZ/6j6UMo+kISVTidJVgt58ueKE0Yz3bSNrg+VPz4WC6sVca97rNfXovlLesEzHBQRLBM Aw8MyBwsXEqwZ4bmXv1G/2ahuHPR26bVRn//EHaQRcsZvfaVy1MIBTNgbgn2iWeNJLkh9 XGP5XJGWeVsfsSF6TngkkxkfXYzXEDA+x/wFh/ldxz6uXcYMlZ3XKg/RyhXx2D16pJMSC ZYOcSSH3UJgLNK6Mft41t8Ja939tb4TTZvZFZ6fnI3zc5WHsIytxShK0cvLJ4ERMcjw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796194859; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:Organization: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=lj83ZtcWyjAJaXlfMipj4eWa9/7UKtIhVJXZYGlzB2k=; b=TmQA6OG/I/aMQ/Kd5m2RIPuLtA8vmb//1gaQBXCAsLAcjnMPumXtHq/bH367NgRG1kuA QexMa8eR5nQZ5CZbphYF5maRnRnq7YuDZWnYTXiEh+x1Jb69z0GkBQLDbOCV5flrBxirW lJms8By5I3S7apA7KrUABOu3s+fbZvbF3UPO7lMRy2JiJ+de/uIL8LommoSN5K4c/qMJh EsmDREjXFp1c773LX0z2CrrMYZNL5LsVE7m/vg7AT2mu+iOLnyRpGsJf1ogyoN2H4eP3h aLDdTDVVPCoSiR3sjlS7tsJE+pCfWNz1TNpvZAw/iZilu9u0XKkcUGeQ49ngM4pambg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dTejhwuz; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24EB1606A325; Wed, 2 Dec 2026 07:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dTejhwuz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C5B51F00893; Wed, 2 Dec 2026 07:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796194858; bh=lj83ZtcWyjAJaXlfMipj4eWa9/7UKtIhVJXZYGlzB2k=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=dTejhwuzMz7ibf/g8F1gRF/2AZdDVbEIZOY9qJh0YMbjq4W4TpOFk4sOjW68t4xND nuM/Habap7g44AX0dff2pl4KBCdZD5Ok7UtSAQl2FAY0W5a6+w658GsCsfmJrKxOIa HQFc8G4RMC46pW432ZCj9fy5E79iOYcvr9TgKPmLG4Ada279DtfvvJawIS8QrcWp7J Z0/Ss1LSr1YK6mQOB/6jOcnUu21+s7doXn3mnt4MXJgDUWGBR96uC06QO9K4D68DlY FEZyfdAtITNsTJliMlegOHmnMyFRhYWaRYGfA9VvUEmN9iVzCYhM1GfB1j5DsKgCWn /bxpfL+4MZDIA== Message-ID: Date: Wed, 2 Dec 2026 16:00:53 +0900 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 1/1] dm-table: take the zone size from the zoned devices of a target To: Kyrylo Biryuk , 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 References: <20261201121037.366367-1-illofspeed@gmail.com> <20261201121037.366367-2-illofspeed@gmail.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20261201121037.366367-2-illofspeed@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 21:10, 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(). On a regular device chunk_sectors is an I/O boundary, not a zone > size. If it 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; the cover > letter has the details. > > 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 > --- > drivers/md/dm-table.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c > index 48f25ab6b..aba085f8f 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 > @@ -1816,7 +1827,14 @@ int dm_calculate_queue_limits(struct dm_table *t, > * in table support this zoned model and zone sectors. > */ > zoned = (ti_limits.features & BLK_FEAT_ZONED); Note: this can be changed to: zoned = true; Because the "if" already checked that we do have BLK_FEAT_ZONED set. > - zone_sectors = ti_limits.chunk_sectors; > + /* > + * Take the zone size from the first zoned device: the > + * stacked chunk_sectors is the gcd() with the I/O > + * boundary of any regular device that a mixed zoned > + * model target (dm-zoned) maps. > + */ > + ti->type->iterate_devices(ti, device_get_zone_sectors, > + &zone_sectors); Other than the above nit, I think this is OK. > } > > /* Set I/O hints portion of queue limits */ -- Damien Le Moal Western Digital Research