From: Damien Le Moal <dlemoal@kernel.org>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai3@huawei.com>,
linux-raid@vger.kernel.org
Subject: [PATCH] md: Correctly disable write zeroes for raid 1, 10 and 5
Date: Tue, 2 Sep 2025 18:38:43 +0900 [thread overview]
Message-ID: <20250902093843.187767-1-dlemoal@kernel.org> (raw)
raid1_set_limits(), raid10_set_queue_limits() and raid5_set_limits()
set max_write_zeroes_sectors to 0 to disable write zeroes support.
However, blk_validate_limits() checks that if
max_hw_wzeroes_unmap_sectors is not zero, it must be equal to
max_write_zeroes_sectors. When creating a RAID1, RAID10 or RAID5 array
of block devices that have a non-zero max_hw_wzeroes_unmap_sectors
limit, blk_validate_limits() returns an error resulting in a failure
to start the array.
Fix this by setting max_hw_wzeroes_unmap_sectors to 0 as well in
raid1_set_limits(), raid10_set_queue_limits() and raid5_set_limits().
Fixes: 0c40d7cb5ef3 ("block: introduce max_{hw|user}_wzeroes_unmap_sectors to queue limits")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/md/raid1.c | 2 ++
drivers/md/raid10.c | 1 +
drivers/md/raid5.c | 1 +
3 files changed, 4 insertions(+)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 408c26398321..b366438f3c00 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3211,6 +3211,8 @@ static int raid1_set_limits(struct mddev *mddev)
md_init_stacking_limits(&lim);
lim.max_write_zeroes_sectors = 0;
+ lim.max_hw_wzeroes_unmap_sectors = 0;
+
lim.features |= BLK_FEAT_ATOMIC_WRITES;
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
if (err)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index b60c30bfb6c7..fe3390948326 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4008,6 +4008,7 @@ static int raid10_set_queue_limits(struct mddev *mddev)
md_init_stacking_limits(&lim);
lim.max_write_zeroes_sectors = 0;
+ lim.max_hw_wzeroes_unmap_sectors = 0
lim.io_min = mddev->chunk_sectors << 9;
lim.chunk_sectors = mddev->chunk_sectors;
lim.io_opt = lim.io_min * raid10_nr_stripes(conf);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 023649fe2476..5f65dd80e2ef 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7732,6 +7732,7 @@ static int raid5_set_limits(struct mddev *mddev)
lim.features |= BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;
lim.discard_granularity = stripe;
lim.max_write_zeroes_sectors = 0;
+ lim.max_hw_wzeroes_unmap_sectors = 0
mddev_stack_rdev_limits(mddev, &lim, 0);
rdev_for_each(rdev, mddev)
queue_limits_stack_bdev(&lim, rdev->bdev, rdev->new_data_offset,
--
2.51.0
next reply other threads:[~2025-09-02 9:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 9:38 Damien Le Moal [this message]
2025-09-02 10:58 ` [PATCH] md: Correctly disable write zeroes for raid 1, 10 and 5 Yu Kuai
2025-09-03 2:46 ` Damien Le Moal
2025-09-03 1:16 ` kernel test robot
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=20250902093843.187767-1-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yukuai3@huawei.com \
/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