From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796127043; b=UDblFVE2z9jxeV8oUyxhILK8rlRh+JSH3CwtsCbLBSMBBlp+JSGfM4D67/XPkTtyGWMf r4Z8kw3v14vNMf6x9S4ONp3rWxD31ml2ibwfNyOqy1sH//ZKApUefkuFFkWX/w8DYGvtc H5rsyIrv3YBI6liDvQQnBo+3mtl9qrDqo7iuVptfx9DewugDt9SVjomK/rHoh0Cvd46mC HjT8RmoCFQ4th+wgcFxBIC5xX6L76Huttv1IxYSdyw+UhXTNX7DuSOQmh+xge3soIcjaq O56s/3aMQ3QnggtHD1K/u0SZrpsYypR8RjESG8BcVe+YceAGHcbzJYJfCzKiURwTs2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796127043; 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:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=Mf8Zt9K+yc7Y8f7jp1oiQtk6zxeuqI3E0EUB8G9SoEU=; b=YCCOEX+0p9O3mYFCUecaPob9s+TKX0jwWTF44/xbksoqhbRwSKYVB1DN0QOWOtmSG5q8 eu2fYTRlT9DJj3hSjnun5QUgA7fTNaE1RqPqIp/GZwWrJPesovMcJ7r5E+J5oCWLkzJvB neN3jrIZJTXCFc8cYzWSThM35dtgcKjh0mVD1RZJtS38MisJpBDCEw81s4I/shAjQHVSL PFLHzx/JY7A+zQVhEYbhLYt41V9MaIJZcvZmZRQaHSE3PEtJL4Bm+KHhAupYFknXEH2D9 Nzp/H1VEQAF1GfAmRd5Jd9gtUGNL9D+JvH2LqqvfPeGfH4Pe/rTw5AE2i+eL+9qg6Sw== 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=HiBcMoKo; arc=none smtp.remote-ip=209.85.218.53 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 087E0606A33C for ; Tue, 1 Dec 2026 12:10:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 087E0606A33C 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=HiBcMoKo Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-c5126505cb3so1570498566b.0 for ; Tue, 01 Dec 2026 04:10:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796127041; x=1796731841; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Mf8Zt9K+yc7Y8f7jp1oiQtk6zxeuqI3E0EUB8G9SoEU=; b=HiBcMoKoWSlGmbId818m9HdLeB6v6/c5gd3DTMXwnc1PnJmKr6VVWfOAhWPO4+faTl 2RfyebhKOO1qDgJvxr92MHazjM+qVNSqEs6WMbsNKmtSC99AQ4vKtWuFswhVYf9VjdDX WIQSZS8lgCKyCTZtbj48X/Vf8xfA9DlKTPBaIg4ZbSsrW4ZxX0Vb1U4aOaLCjVbX8KSW EHxGyzAYj+ATP2s8x4YbH/C4LmAkZbMuKMczgff+onkbjhQzlxCkf7q+NpceiupsjnSK D9Q7P3yjqkSLToh1Jq7sqii0rD4z+oXGnB+6zrZ0imoXPM7dizvv5F5xWnwh8LI+rRvH ecFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796127041; x=1796731841; h=content-transfer-encoding:mime-version:references:in-reply-to :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=Mf8Zt9K+yc7Y8f7jp1oiQtk6zxeuqI3E0EUB8G9SoEU=; b=DYrK9yQNjMRgAQ8AEiMHOXcKmWsLsiZvlQ3Dit6B7ysqEUGTyJDp5HGVQQFS6G9wpG ZKWXRUwi/N7wewt9tb27z2ipUZQSqAF9AY0pqCj2GCKs1SplfNK2HAuKEJz5hZz8c4ix FLqatkkImrCh0vqg6q4+YFhsIHoSf62pDrn+oPJUZLFv3Y6FTOCPQGCdcSBeGRyZKBTw ixf0hONGH5l/dLbWP1Gl2fjmYBGzE2k3NZWIy0mTAidnRl0Q5nB12Oe6iGdjWYiyDJqu 8eVvEuIs+r4M2N2kp0d0z+M7ahJaY5XIx+PmskETE+zzqqU3Geu6G8yy49rQ3Sn76EUq 1Tsw== X-Forwarded-Encrypted: i=1; AL+hErGZ3n7xQNONpXtmKFvZqfcowBcfsN5g8mRfe3Ujwf3nZ0Fsod+GZTGa+NnQ07mTmSr3uzDYytMKmRklJEs=@vger.kernel.org X-Gm-Message-State: APuU4Z9LniiY7tALfrIR04PJcKcMYXd8eEEtJXKqnPkpNcwXBs/VdC21 BDcKXvxOm7POxi+XZs3UyrftBf7LjRj25S86/RmUz39DPe1eJ+bVGYG9 X-Gm-Gg: AZFdTZdrUTfDsX/TwJU3xFxLNr7ZYYJwpco/SztWPFbybKSL+5X1pOfGXgP9YZHzD00 w9Wm7pSeAZqQXe0ANkTowOT/CyCePgg/AYSKxvYyTvL8UafQDWfhMlY42x02jFBHuoehTFq9ZSD 0E9ldaFsS3edJMFrghcRjnkuwOwT272Uyqptn4zbyj+a465vp6GwYZtk1lqKc6HDhJC5bk5nGOt tewN2u8ma13P4pV/CSeGfdUTpmtXq5W2TjruQ/5McKbIQrGDb3DFCjUZDW88b/SM6C4PV6cGSdG qmNxdi0bOGz/FM0nyUTqrGDp//1yMPweSJF7pdU7wSC4NkQz9in9pQhB7KMRDu/61HJCugDUxdK ZMUANbyxLE7Wztsp5jPo5sODgLQxwucAFdUfHccGY8hCwd0L+GzrJa6UgXCYnhVyMGdk31DZSJ8 7s2iMcWOl+US5JLrJ0Kf67I4P+R6yYfEJYtztf8G2y05naU6QF5NrWft/fkG02MMi2hrZbedDwF JQKyv79mywqR3Q+r0vDGOiSU9bqyuSqMem1BkgJcQoObqalLSnWb4upUjmHYFvLup4lirlGJcMY Y4J0wuQ4UQX1inSRNNCNondvtxMunPqHm3f6/ozDhYszCmo= X-Received: by 2002:a17:907:3f05:b0:c41:e0c0:e6b7 with SMTP id a640c23a62f3a-c513a99a69cmr2621105766b.12.1796127041229; Tue, 01 Dec 2026 04:10:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 04:10:40 -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 1/1] dm-table: take the zone size from the zoned devices of a target Date: Tue, 1 Dec 2026 13:10:37 +0100 Message-ID: <20261201121037.366367-2-illofspeed@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201121037.366367-1-illofspeed@gmail.com> References: <20261201121037.366367-1-illofspeed@gmail.com> 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 Content-Transfer-Encoding: 8bit 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); - 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); } /* Set I/O hints portion of queue limits */ -- 2.43.0