Skip to content

Commit f0bd038

Browse files
zhangyi089YuKuai-huawei
authored andcommitted
md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
The parameter max_hw_wzeroes_unmap_sectors in queue_limits should be equal to max_write_zeroes_sectors if it is set to a non-zero value. However, the stacked md drivers call md_init_stacking_limits() to initialize this parameter to UINT_MAX but only adjust max_write_zeroes_sectors when setting limits. Therefore, this discrepancy triggers a value check failure in blk_validate_limits(). $ modprobe scsi_debug num_parts=2 dev_size_mb=8 lbprz=1 lbpws=1 $ mdadm --create /dev/md0 --level=0 --raid-device=2 /dev/sda1 /dev/sda2 mdadm: Defaulting to version 1.2 metadata mdadm: RUN_ARRAY failed: Invalid argument Fix this failure by explicitly setting max_hw_wzeroes_unmap_sectors to max_write_zeroes_sectors. Since the linear and raid0 drivers support write zeroes, so they can support unmap write zeroes operation if all of the backend devices support it. However, the raid1/10/5 drivers don't support write zeroes, so we have to set it to zero. Fixes: 0c40d7c ("block: introduce max_{hw|user}_wzeroes_unmap_sectors to queue limits") Reported-by: John Garry <john.g.garry@oracle.com> Closes: https://lore.kernel.org/linux-block/803a2183-a0bb-4b7a-92f1-afc5097630d2@oracle.com/ Signed-off-by: Zhang Yi <yi.zhang@huawei.com> Tested-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Li Nan <linan122@huawei.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/linux-raid/20250910111107.3247530-2-yi.zhang@huaweicloud.com Signed-off-by: Yu Kuai <yukuai3@huawei.com>
1 parent 743bf03 commit f0bd038

5 files changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/md/md-linear.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static int linear_set_limits(struct mddev *mddev)
7373
md_init_stacking_limits(&lim);
7474
lim.max_hw_sectors = mddev->chunk_sectors;
7575
lim.max_write_zeroes_sectors = mddev->chunk_sectors;
76+
lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
7677
lim.io_min = mddev->chunk_sectors << 9;
7778
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
7879
if (err)

drivers/md/raid0.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ static int raid0_set_limits(struct mddev *mddev)
382382
md_init_stacking_limits(&lim);
383383
lim.max_hw_sectors = mddev->chunk_sectors;
384384
lim.max_write_zeroes_sectors = mddev->chunk_sectors;
385+
lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
385386
lim.io_min = mddev->chunk_sectors << 9;
386387
lim.io_opt = lim.io_min * mddev->raid_disks;
387388
lim.chunk_sectors = mddev->chunk_sectors;

drivers/md/raid1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,7 @@ static int raid1_set_limits(struct mddev *mddev)
32113211

32123212
md_init_stacking_limits(&lim);
32133213
lim.max_write_zeroes_sectors = 0;
3214+
lim.max_hw_wzeroes_unmap_sectors = 0;
32143215
lim.features |= BLK_FEAT_ATOMIC_WRITES;
32153216
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
32163217
if (err)

drivers/md/raid10.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4008,6 +4008,7 @@ static int raid10_set_queue_limits(struct mddev *mddev)
40084008

40094009
md_init_stacking_limits(&lim);
40104010
lim.max_write_zeroes_sectors = 0;
4011+
lim.max_hw_wzeroes_unmap_sectors = 0;
40114012
lim.io_min = mddev->chunk_sectors << 9;
40124013
lim.chunk_sectors = mddev->chunk_sectors;
40134014
lim.io_opt = lim.io_min * raid10_nr_stripes(conf);

drivers/md/raid5.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7732,6 +7732,7 @@ static int raid5_set_limits(struct mddev *mddev)
77327732
lim.features |= BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;
77337733
lim.discard_granularity = stripe;
77347734
lim.max_write_zeroes_sectors = 0;
7735+
lim.max_hw_wzeroes_unmap_sectors = 0;
77357736
mddev_stack_rdev_limits(mddev, &lim, 0);
77367737
rdev_for_each(rdev, mddev)
77377738
queue_limits_stack_bdev(&lim, rdev->bdev, rdev->new_data_offset,

0 commit comments

Comments
 (0)