From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796127041; b=aY2T/33239/YzV4uEFrDq+PPzQ4elOoM690FONaqw3ErmYoYZyjBKMFMzH0UVjCLdMZU JbViBEEhHE5LW+sz9Ei/gQWsXhAKx56nTpOje57XZRP4yTQtKnQPKqZI0esSGXAOCI+At 701WMwzPqanqgqGrNIRCSjwD7PqTDENjxpwbd9ZmECUvs1xoYc1amnGqjQyXSRf0z2biD me7gl4I0W3lQ1Kz0xz0Iq5P6CRmdsBXZu5qheydrRysIXDbDb3S5Up2Cut4/3FJ1YRWj7 l22wUAl520hifkhHCsPhWqxtLo5UFaOCnlroF8uYkDJU3YW5NIs1kPjuI2fp47W44cg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796127041; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=Jhv8XXAGcA4wfEcI2p7StqJ99fILRB1lytLdl0qv0pc=; b=hLyB5rMr6xK2ebiclMHoBv9AahuYdF2xDmZfEJObT5DkCBTHZwfO8Qx2EmCNHdPOD39J h7qBHlhmS154vh/5Sq3TNOlYmkb8iJhya+7pkjtSrNpVAo9KM7MVokJHuVl/YFlQuG/IP OCCEUcOb3Thp518sJwQybUlbKjAUMFfiaSZFOUmBI0o7PeSo9ktkx+wZsRiyrj3zCqfY3 hMDC30ZevHkSYinF3+/8j4SdC39bh3mZ0DrYCcHu25gC977w5f8P+Mg2t5f4lpXsbGJOp Rc5Tc5eyX90DKUOjeIz7gRlG27a/SCsE+UN7KD+0dYRW5BX0eSWxOEIxbe1WKkin8ww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NzcMfHWo; arc=none smtp.remote-ip=209.85.218.46 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88B01606A31A for ; Tue, 1 Dec 2026 12:10:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 88B01606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=NzcMfHWo Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-c4d2b741ed9so1864714466b.2 for ; Tue, 01 Dec 2026 04:10:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796127040; x=1796731840; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Jhv8XXAGcA4wfEcI2p7StqJ99fILRB1lytLdl0qv0pc=; b=NzcMfHWonscx6m4b4fGcjvR7KfMm8iZf8pqRAMRdfWxPOqpHOs2Fj6KyDLNbDtIMH0 HIfquPhg0G+CHdrRXaNVg4VfSpQ9nOVc04lNjeIbxcchgZMxV48LmDey0aecC6+BkiY7 F/RufPuVG3U98INYa4YjxC62a/VwCqQgrIiBwtQbQkrTK3SemveledvG+b+OcmAuxBSE 44psvKt7ZLNyn3cEMn2TR80kDfMo2BHANJ0uWTB36Guz7r+5WO/EO1eb1NzdMhPMHPCF tasZDpslhDKFussQmYYh1Lp6A2CkV58f9x+Qt248wfcKTZDmox0OskuZWCnsgx/3W7+A BxeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796127040; x=1796731840; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Jhv8XXAGcA4wfEcI2p7StqJ99fILRB1lytLdl0qv0pc=; b=ZUNla2TBYdXnT+s7dg/svJ5yWCeVXI0B5nFYH4R+TFoem82G3EIQFLhVbpeL8CIZVi vsl4PLoWKjFkFiudUHU3nmvcDdwiiaMVmdPoKVaB85IpyLRPiVs/mTObw8byP6lon+TF AqwG/kgjagdZALF2qJSCgrhiqkUBIY+LVJOoxsqrMJcvq6N1sxvXxJcZRW3hEdREnZ5Z H5JPeu/TyV/44n40iEvAu8xAaQXSzetlHmrtd7oZQwSdyayFv7Ux2ddkD3trX0NRJ8vM RT68fNE7b6kVOw9nYRXFQ3AQ/R/N5cyYhmfQWrb8XruIk1BZ/ZIuyvo7vPsS3+ZOBMpU 9/tQ== X-Forwarded-Encrypted: i=1; AL+hErG7oQ057qE60XGggjQq8LmYKqtohn71bcY9YqCnUmKKZRthmVMsnCGTLhGfaFktTTGkxmrkWGLXOxGxDQ==@vger.kernel.org X-Gm-Message-State: APuU4Z/tXT6WSgyiOnisbWywbiZhIjO2wGK4d4IA0kqlQB50UwFu0ZCS DohObxntY89AY90FJksMrAeTwbwwoJI6EKPnNOVM7h98HEloIJjYH/OD X-Gm-Gg: AZFdTZenNUqjosKk1y6B9RUlgyhXyRPPFQGv0DiEol1Hm507Jal8AQ7jrv49c8axe9m S3WGtsJbGZv40an4q9rMMQR5fwzzRpdK+UWYHjoWpIr4kYhUq3/vL9+i0CwG4uZybw7PA5FFTDS fzs0eagasa2FaKTySlYtrq4npeZBEOrlU+Up27M5vwtNs78SyXm1iRP04ZrzZaVEe6N6DD1YTVV EupgPBBndNZ2TkfGAScFz/1d1eJuj4mE45XXsgAW3KcjYE/frx+1vG18hmgjRRP3/nUK+xhRdiq TGPwS+ZmnUIm/7RT/vuITUg2UHfcV/xzW+i2L2jVvK3iTISh8v+wO7EClRDuX4gx0AzjEhX7MtT RutDoNQyB3Ij/mMb1JDhrE6Xvof6+xKO+bKchhytiJ5K5Dp4gcIkSLr+ZlXK3QK5R3Q+FqXKSx0 5gvtox7EA+OqjcqnoyaWnA9erIFaa7Wgf32FvmMk41IgOPp9uH9Tts5K1Sg/NHQsKkiqYASx+cw JdiIQru3SHXJiA1HJyPd3NZDvPKt7DvPyau21oug7nOxnoDYBA06PNcLeITaO75KY5tJwAy5EES 5ja8Ivn+cCTw1kyLdjmTWp9vHVUJJusUxDU5eTEDh4fs/TM= X-Received: by 2002:a17:906:17c9:b0:c46:7ec3:fde7 with SMTP id a640c23a62f3a-c513a8920damr2338950866b.31.1796127039676; Tue, 01 Dec 2026 04:10:39 -0800 (PST) Received: from localhost.localdomain (luna.k.pl. [193.239.59.185]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c51beef9244sm624517166b.28.2026.12.01.04.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 04:10:39 -0800 (PST) From: Kyrylo Biryuk To: dm-devel@lists.linux.dev Cc: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, bmarzins@redhat.com, dlemoal@kernel.org, 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: [RFC PATCH 0/1] dm-table: dm-zoned refuses md RAID1/RAID0 as its regular device Date: Tue, 1 Dec 2026 13:10:36 +0100 Message-ID: <20261201121037.366367-1-illofspeed@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, dm-zoned can no longer be set up with an md RAID1 array (since v7.3 and 7.2.y) or an md RAID0 array (since v6.17) as its regular device, next to a host-managed drive with 256 MiB zones. The table load fails with 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. I think the problem is in dm_calculate_queue_limits(), not in md, and patch 1/1 is a proposed fix. I first hit this on a 7.2.10 kernel with real drives (an md RAID1 of two SSD partitions as the regular device, a host-managed HDD with 256 MiB zones) and reproduced it on vanilla 7.3.6 and 7.4-rc5 in a VM. What changed in md: commit 86d801e895b8 ("md/raid1: restrict atomic write limits and handle runtime constraints", v7.3-rc1, also in linux-7.2.y) makes raid1_set_limits() start from lim.chunk_sectors = BARRIER_UNIT_SECTOR_SIZE (131072 sectors, 64 MiB) before it stacks the members' limits, so an md RAID1 of ordinary members reports 131072, and commit 4b8beba60d32 ("md/raid0: set chunk_sectors limit", v6.17-rc1) sets it to the chunk size on md RAID0. Any regular device whose chunk_sectors is non-zero and not a multiple of the zone size fails in the same way: tested md RAID1, md RAID0 with a 512 KiB chunk, and dm-linear on top of md RAID1; by the same mechanism, not tested, md RAID10 and RAID5, dm-stripe and NVMe namespaces with NOIOB. Where it goes wrong (7.4-rc5 line numbers): 1. dm_calculate_queue_limits() stacks all devices of the target into ti_limits via dmz_iterate_devices(), regular device first. blk_stack_limits() combines chunk_sectors with gcd(), so gcd(131072 (md RAID1), 524288 (256 MiB zones)) = 131072. BLK_FEAT_ZONED is inherited from the zoned device. 2. dm-table.c:1819 stores zone_sectors = ti_limits.chunk_sectors, i.e. 131072. This happens before the target's .io_hints runs, on purpose (see the comment above dm-table.c:1866). 3. dmz_io_hints() (dm-zoned-target.c:1008) sets chunk_sectors back to the zone size and clears BLK_FEAT_ZONED, so the assignment from the final limits at dm-table.c:1872 is skipped and zone_sectors stays 131072. 4. validate_hardware_zoned() calls device_not_matches_zone_sectors(), which compares bdev_zone_sectors() of the zoned device (524288) with 131072 and fails (dm-table.c:1767). On a zoned device chunk_sectors is the zone size, but on a regular device it is only an I/O boundary, so the gcd over all devices is not a zone size as soon as a regular device carries a smaller non-zero value. dm core already reads the zone size from the zoned device everywhere else (device_area_is_invalid(), device_not_matches_zone_sectors()), and so does dm-zoned (dmz_fixup_devices()); the patch makes this one place do the same: it takes the zone size from the first zoned device of the target. All zoned devices of the table must still have that zone size, and tables whose final limits are zoned (linear, crypt, flakey and the other DM_TARGET_ZONED_HM targets) still take it from the final limits. Why not elsewhere: a dm-zoned .io_hints change cannot work, because the value is captured before .io_hints runs, and changing md alone would leave RAID0/10/5, dm-stripe and NVMe NOIOB. A dm-raid (LVM raid1) LV is not affected because raid1_run() calls raid1_set_limits() only if !mddev_is_dm(). Results before the patch (x86_64 KVM guest, Debian 13 userspace, vanilla kernels from defconfig plus md, dm-zoned and null_blk as modules; start of the dm-zoned target with the regular device first): kernel md md plain LVM raid1 dm-linear RAID1 RAID0 loop LV on md RAID1 Debian 6.12.118 (cloud) ok ok (*) ok ok ok 7.3.6 (kernel.org tarball) FAIL FAIL ok ok FAIL 7.4-rc5 (torvalds snapshot) FAIL FAIL ok ok FAIL (*) on 6.12.118 md RAID0 reports chunk_sectors 0. The patch, on v7.4-rc5 with KASAN (generic, inline), PROVE_LOCKING and DEBUG_ATOMIC_SLEEP, same kernel with the unpatched and the patched dm-mod in a KVM guest; zoned devices are zoned null_blk, regular devices loop-backed: case unpatched patched dm-zoned + md RAID1 (256 MiB zones) refused starts, I/O ok dm-zoned + md RAID0, 512 KiB chunk refused starts, I/O ok dm-zoned + dm-linear on md RAID1 refused starts, I/O ok dm-zoned + md RAID1 + two zoned devices refused starts dm-zoned + loop, LVM raid1 LV, or md RAID1 with 32 MiB zones (controls) starts starts dm-zoned on one zoned device only starts starts dm-zoned, zoned devices of different sizes refused refused (a) dm-linear, zoned devices of different sizes refused refused dm-linear, zoned + regular device refused refused dm-linear, not zone aligned refused refused dm-linear, dm-crypt, dm-flakey on a zoned device: zoned model, zone size, nr_zones = device = device "I/O ok": ext4 on the target, 256 MiB written, suspend/resume while mounted, remount, checksum equal (the controls passed this on both kernels). In the cases started by the reproduction script (the first three rows and the controls), the same table was then loaded again and resumed; the target's limits stayed chunk_sectors = zone size, not zoned. dm-crypt also wrote and read back 16 MiB through the zone write pointer. (a) refused by the dm-zoned constructor ("Zone nr sectors mismatch") before dm-table checks anything. No KASAN, lockdep or might_sleep reports; the kernel stayed untainted and lockdep stayed enabled in both runs. checkpatch --strict: one warning, for the quoted kernel log line. Not tested: md RAID10/RAID5, dm-stripe or NVMe as the regular device, real NVMe members with atomic write limits, stable kernels at run time, blktests and the dm-zoned-tools tests, and a table where the changed line itself refuses (the dm-zoned constructor refuses mismatched zone sizes first). Reproduction, on a disposable test VM (root; kernel with null_blk, md, loop and dm-zoned; mdadm 4.4, dm-zoned-tools 2.2.2): modprobe null_blk nr_devices=0; modprobe loop; modprobe dm-zoned mount -t configfs none /sys/kernel/config 2>/dev/null d=/sys/kernel/config/nullb/zt; mkdir $d echo 32768 > $d/size; echo 4096 > $d/blocksize echo 1 > $d/memory_backed; echo 1 > $d/zoned echo 256 > $d/zone_size; echo 0 > $d/zone_nr_conv; echo 1 > $d/power w=$(mktemp -d); truncate -s 4G $w/a.img $w/b.img A=$(losetup -f --show $w/a.img); B=$(losetup -f --show $w/b.img) mdadm --create /dev/md/zt --run --level=1 --raid-devices=2 \ --bitmap=none --assume-clean $A $B M=$(readlink -f /dev/md/zt) cat /sys/block/${M#/dev/}/queue/chunk_sectors # 131072 dmzadm --format $M /dev/zt --force dmzadm --start $M /dev/zt # fails as above The script I used for all cases (RAID1, RAID0, plain loop, LVM raid1, dm-linear on RAID1, with cleanup) is available on request. Workaround until then: an LVM raid1 LV (dm-raid) or a plain partition as the regular device, as long as it reports chunk_sectors 0 or a multiple of the zone size. A dm-linear over md RAID1 does not help. Questions: 1. Fixes: patch 1/1 names 2d669ceb69c2 ("dm table: Fix zoned model check and zone sectors check"). That commit introduced DM_TARGET_MIXED_ZONED_MODEL and made the zone size check skip regular devices, but kept the stacked chunk_sectors as the reference zone size, which is the logic the patch amends. This is from reading the history, not a bisect; please say if another commit fits better. 2. Stable: "Cc: stable # 6.18.x". The md RAID0/RAID10 and dm-stripe triggers are in v6.17 and later, md RAID5 in v7.1 and later, and md RAID1 in v7.3 and 7.2.y; the patch applies to 6.18.y, 7.2.y and 7.3.y. On 6.12.y (it applies there too) the only trigger I know of is an NVMe namespace that reports NOIOB, which I have not tested, so I left it out; say if you want it widened. Older trees need a separate backport (different context); I can do one if wanted. 3. FYI for linux-raid: independently of this fix, is chunk_sectors the right limit for raid1's barrier unit? It makes a mirror report a 64 MiB "chunk" to everything stacked on top of it. The dm fix is needed either way. Based on v7.4-rc5; the patch also applies to linux-dm for-next and to current mainline. I used LLM coding assistants (Claude Code for the root-cause analysis and drafts of the code, the changelog, this report and the test harness; OpenAI, Google Gemini and GitHub Copilot models for reviews). I reviewed the code and changed it where needed, and I am responsible for this patch. Kyrylo Biryuk (1): dm-table: take the zone size from the zoned devices of a target drivers/md/dm-table.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.43.0