From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384900; b=eRwsqs4UEDrjAG6xayWwENSaRZwVooTtOyLQEf4Q8/CAsBBtP8n1a4bL6/Io/Dn/PzX8 6lAVly+nRVcZhDeH5NJOiIE11DSZVtDvnGYDrrc9a5jFXUnsgMdTb5yZcDKDuFVkRmPWB NgYQVmfxBa3rguvIshjidL9tQPpwGks7kFXYy7kaJtFRRk9ZSjhRtZ/eJ9ZYYUMXxEcJ7 Qcvp5Tsc2xonklRYjy8afYI1SPOWFYHtmy2Rzp2kQcAY5pTu9wKnaJnbBJWMGjJNMKLiO NLc8xjMPQWoeN3wtQIK2j8udRdoY95WYHqDdgHx/3XhTEy0ZFlRiq/6SUA9+dQWfB3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384900; 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=I993eKDooaC6WwndEQJlfpF0Bf0A0I3G3ycJPynZAAw=; b=MFoeGb7ahb8i00FbcqqB7dNuDm70NHbG2/SrmXReP9h3cftaY3BDR/8RCDG5iOLc7ABs s5QqsNWXTJn4mQpP4ue9uOwXDDO+boBWeSHaG6ORXkwQvEgW/c+MxydRg5AMF1YPEjSE/ gyYSUu3CnHzBUF6cyY7a3b4MOXIK/eY2ID+ttMnOFhbb2Qtt67WOs4HxpGK2c6U+8hnn9 6v3zxczDoCiF0jiM294m5F0aHDvyb+F8fUqIKW/zRgJxJsD0hECfef68ZxeV2UV9VhoOr 2um/KQa1xOFxQFGjq9B9DZcFR/KU/ciTLGCcIomHagGgdaAW+qUcXIthmwY7FDDCj0Q== 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=wsucLTqu; arc=none smtp.remote-ip=209.85.208.50 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 4E772606A333 for ; Fri, 4 Dec 2026 11:48:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4E772606A333 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=wsucLTqu Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-6bc48670259so944171a12.0 for ; Fri, 04 Dec 2026 03:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796384898; x=1796989698; 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=I993eKDooaC6WwndEQJlfpF0Bf0A0I3G3ycJPynZAAw=; b=wsucLTquM7PBgxD3Pb6VNd4EA6bkOum+AMXJ7545rRpEZRAe42R9Ae3boZnmpbe2nW DriiNQRMF7GHl7/7mCePKRfAX3+qUVxsyPEQCxZsDCN6rKwjAE35RYOQEknPixZEZT1N ClgXr6B2lnQJne30nvDU0SCZf3xGxSBqhlBGzdifaPH47YZNBx4R4On/7TCFSKhDTtD3 kbUp6CP7xKVrGo4qieS+QgiI64qgNn3keuHjWkTgdkZ+8xYIcAbXu+0u/ceAByyjQAbT Evi3O+tU0qGwjOfsN4ixvfUZfcnlVf7BXJi0S5ltsq7FHdpq0LcQJ54tF7PFlM8pCSRw M6SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796384898; x=1796989698; 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=I993eKDooaC6WwndEQJlfpF0Bf0A0I3G3ycJPynZAAw=; b=cxpMnEnpgbkp/hY4YERG6eb1cTaQ+C6ynLcsPKFReGDItn/IqxN4/QL0LH2Ty5fIaY oQgB74GciSzfdFvwbBWkETxrqxTcaz6TcisCsG7bxjb/9kx/RNzhAiQXNx8Ak8l7suov BFn1eVwnCKLZO3bAZp27e360weoqcHSlLGwPC3kZarhHGnod7EobCJgsZLHs1kgd5ejZ ytpUAKa4S41sR68mqrcfgFOXLdaItwe8tx1C4aT974A/7Kqy6lP0PQF6NCj2V24nqNqM at3db6mbjBIuL/tud0SnUV9v81e7CRdCCe5tVw7Uw8W/P4cqVO9yO/ZG0cNugHhyzg6k gUbA== X-Forwarded-Encrypted: i=1; AL+hErH3fWh2lbooooiOARf1J1F/yYddOBjvfiT+W6t1MckCaS1Wz3MSVTvIw+ESIP198WsoSTE83BNHFM+G@vger.kernel.org X-Gm-Message-State: APuU4Z81JE2SHPZvQSoBWp8TXJKwS/cwhucNKgkUoineMoSdsU+OAaGU E3/jj0DmUFIXJUgAcTDM/DA30R2Dy5/seLtnbdmAMHEAAY56t8IpSPHG X-Gm-Gg: AZFdTZe0uIeyOo4PR+0HQ4MnGqiZ8DfzqYFznbMRuv2f2BtnfvmFNl2L/yGgJq5yfdA D3F4CEeqB+cmbzLB7Z9QT3OWrUWbFcoK38TttCd+jFQip17OwCK5ToKhN1YSRa+5cIlk6jjjZWm OTUUYBN24YsYA7TBbUgIuSsmsv/nKi4zjVyCMqJRk957JxmrZkI64uGN0tJlD6yxsstJ+ZgSuOo Fsmdzg2L8v/3VE2Vz3zplJqxfBYSEsA2Uw8r3N7bZ7oK6UbGc05KgfQcPzADr2rZjev998LfG6X bMqKP7xexRyJsd/TwYm82IEDoM+h3XxgR6eYYG7xaJO67OgqBmpcADRJLtb+IezDsp2OMizayRx vr9nPbwYAYrIEloouaKWn4H4CEI/qdAQBtmQT/QFhZ2F1hCo23l0xWKS+7y3NfyifV/PTUZm/rc cb+2hKeURM3vITr8PR7P/7M/BVT57fNF+HPlpb2/hesGTrFo13Wv2bma6QL2+3yar1FwvoV2VC3 prXwC1qj1UMlgk3UedkZJDFhj3HdOMtkLGKmrtKBcBi8T6OwHcSfM5111WNFYT0dCa7GNl4UrEE FVoZh22Cs9MUaRiY6qdv2V3eafQKgeXUueVD2MiDioOGpbySRSWFOVtsx40qAu7zeb5YbDWeYNA 1/Q== X-Received: by 2002:a17:907:80b:b0:c46:645f:cedc with SMTP id a640c23a62f3a-c5262569be4mr114555366b.46.1796384897510; Fri, 04 Dec 2026 03:48:17 -0800 (PST) Received: from localhost.localdomain (87-205-122-125.dynamic.inetia.pl. [87.205.122.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c525b380300sm107814066b.23.2026.12.04.03.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 03:48:17 -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: [PATCH v3] dm-table: take the zone size from the zoned devices of a target Date: Fri, 4 Dec 2026 12:48:08 +0100 Message-ID: <20261204114808.945313-1-illofspeed@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202202631.664896-1-illofspeed@gmail.com> References: <20261202202631.664896-1-illofspeed@gmail.com> X-Mailing-List: linux-raid@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(). 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 Reviewed-by: Damien Le Moal Signed-off-by: Kyrylo Biryuk --- Changes since v2 (review by Damien Le Moal): - Moved the "zoned = true" statement below the new comment in the BLK_FEAT_ZONED branch, so the comment is not between two statements. - Added his Reviewed-by tag. No functional change. 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..391c68a44 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; + /* + * 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. + */ + zoned = true; + ti->type->iterate_devices(ti, device_get_zone_sectors, + &zone_sectors); } /* Set I/O hints portion of queue limits */ base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.43.0