linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers
@ 2025-09-10 11:11 Zhang Yi
  2025-09-10 11:11 ` [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter Zhang Yi
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Zhang Yi @ 2025-09-10 11:11 UTC (permalink / raw)
  To: linux-block, linux-raid, drbd-dev
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, axboe, yi.zhang, yi.zhang, yukuai3, yangerkun

From: Zhang Yi <yi.zhang@huawei.com>

Changes since v1:
 - Improve commit messages in patch 1 by adding a simple reproduction
   case as Paul suggested and explaining the implementation differences
   between RAID 0 and RAID 1/10/5, no code changes.

v1: https://lore.kernel.org/linux-block/20250825083320.797165-1-yi.zhang@huaweicloud.com/

This series fixes the initialization of max_hw_wzeroes_unmap_sectors in
queue_limits for all md raid and drbd drivers, preventing
blk_validate_limits() failures on underlying devices that support the
unmap write zeroes command.

Best regards,
Yi.

Zhang Yi (2):
  md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
  drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter

 drivers/block/drbd/drbd_nl.c | 1 +
 drivers/md/md-linear.c       | 1 +
 drivers/md/raid0.c           | 1 +
 drivers/md/raid1.c           | 1 +
 drivers/md/raid10.c          | 1 +
 drivers/md/raid5.c           | 1 +
 6 files changed, 6 insertions(+)

-- 
2.46.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
  2025-09-10 11:11 [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
@ 2025-09-10 11:11 ` Zhang Yi
  2025-09-10 11:41   ` Hannes Reinecke
  2025-09-17  1:20   ` Yu Kuai
  2025-09-10 11:11 ` [PATCH v2 2/2] drbd: " Zhang Yi
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 10+ messages in thread
From: Zhang Yi @ 2025-09-10 11:11 UTC (permalink / raw)
  To: linux-block, linux-raid, drbd-dev
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, axboe, yi.zhang, yi.zhang, yukuai3, yangerkun

From: Zhang Yi <yi.zhang@huawei.com>

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: 0c40d7cb5ef3 ("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>
---
 drivers/md/md-linear.c | 1 +
 drivers/md/raid0.c     | 1 +
 drivers/md/raid1.c     | 1 +
 drivers/md/raid10.c    | 1 +
 drivers/md/raid5.c     | 1 +
 5 files changed, 5 insertions(+)

diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index 5d9b08115375..3e1f165c2d20 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -73,6 +73,7 @@ static int linear_set_limits(struct mddev *mddev)
 	md_init_stacking_limits(&lim);
 	lim.max_hw_sectors = mddev->chunk_sectors;
 	lim.max_write_zeroes_sectors = mddev->chunk_sectors;
+	lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
 	lim.io_min = mddev->chunk_sectors << 9;
 	err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
 	if (err)
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index f1d8811a542a..419139ad7663 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -382,6 +382,7 @@ static int raid0_set_limits(struct mddev *mddev)
 	md_init_stacking_limits(&lim);
 	lim.max_hw_sectors = mddev->chunk_sectors;
 	lim.max_write_zeroes_sectors = mddev->chunk_sectors;
+	lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
 	lim.io_min = mddev->chunk_sectors << 9;
 	lim.io_opt = lim.io_min * mddev->raid_disks;
 	lim.chunk_sectors = mddev->chunk_sectors;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index bf44878ec640..d30b82beeb92 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3211,6 +3211,7 @@ 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..9832eefb2f15 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..e385ef1355e8 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.46.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
  2025-09-10 11:11 [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
  2025-09-10 11:11 ` [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter Zhang Yi
@ 2025-09-10 11:11 ` Zhang Yi
  2025-09-10 11:41   ` Hannes Reinecke
  2025-09-12  6:16 ` [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
  2025-09-17 14:21 ` (subset) " Jens Axboe
  3 siblings, 1 reply; 10+ messages in thread
From: Zhang Yi @ 2025-09-10 11:11 UTC (permalink / raw)
  To: linux-block, linux-raid, drbd-dev
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, axboe, yi.zhang, yi.zhang, yukuai3, yangerkun

From: Zhang Yi <yi.zhang@huawei.com>

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, when the backend bdev is specified, this parameter is
initialized to UINT_MAX during the call to blk_set_stacking_limits(),
while only max_write_zeroes_sectors is adjusted. Therefore, this
discrepancy triggers a value check failure in blk_validate_limits().

Since the drvd driver doesn't yet support unmap write zeroes, so fix
this failure by explicitly setting max_hw_wzeroes_unmap_sectors to
zero.

Fixes: 0c40d7cb5ef3 ("block: introduce max_{hw|user}_wzeroes_unmap_sectors to queue limits")
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/block/drbd/drbd_nl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index e09930c2b226..91f3b8afb63c 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1330,6 +1330,7 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device,
 		lim.max_write_zeroes_sectors = DRBD_MAX_BBIO_SECTORS;
 	else
 		lim.max_write_zeroes_sectors = 0;
+	lim.max_hw_wzeroes_unmap_sectors = 0;
 
 	if ((lim.discard_granularity >> SECTOR_SHIFT) >
 	    lim.max_hw_discard_sectors) {
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
  2025-09-10 11:11 ` [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter Zhang Yi
@ 2025-09-10 11:41   ` Hannes Reinecke
  2025-09-17  1:20   ` Yu Kuai
  1 sibling, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2025-09-10 11:41 UTC (permalink / raw)
  To: Zhang Yi, linux-block, linux-raid, drbd-dev
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, axboe, yi.zhang, yukuai3, yangerkun

On 9/10/25 13:11, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> 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: 0c40d7cb5ef3 ("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>
> ---
>   drivers/md/md-linear.c | 1 +
>   drivers/md/raid0.c     | 1 +
>   drivers/md/raid1.c     | 1 +
>   drivers/md/raid10.c    | 1 +
>   drivers/md/raid5.c     | 1 +
>   5 files changed, 5 insertions(+)
> 
Notice the failure, too. Thanks for fixing it.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
  2025-09-10 11:11 ` [PATCH v2 2/2] drbd: " Zhang Yi
@ 2025-09-10 11:41   ` Hannes Reinecke
  0 siblings, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2025-09-10 11:41 UTC (permalink / raw)
  To: Zhang Yi, linux-block, linux-raid, drbd-dev
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, axboe, yi.zhang, yukuai3, yangerkun

On 9/10/25 13:11, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> 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, when the backend bdev is specified, this parameter is
> initialized to UINT_MAX during the call to blk_set_stacking_limits(),
> while only max_write_zeroes_sectors is adjusted. Therefore, this
> discrepancy triggers a value check failure in blk_validate_limits().
> 
> Since the drvd driver doesn't yet support unmap write zeroes, so fix
> this failure by explicitly setting max_hw_wzeroes_unmap_sectors to
> zero.
> 
> Fixes: 0c40d7cb5ef3 ("block: introduce max_{hw|user}_wzeroes_unmap_sectors to queue limits")
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/block/drbd/drbd_nl.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
> index e09930c2b226..91f3b8afb63c 100644
> --- a/drivers/block/drbd/drbd_nl.c
> +++ b/drivers/block/drbd/drbd_nl.c
> @@ -1330,6 +1330,7 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device,
>   		lim.max_write_zeroes_sectors = DRBD_MAX_BBIO_SECTORS;
>   	else
>   		lim.max_write_zeroes_sectors = 0;
> +	lim.max_hw_wzeroes_unmap_sectors = 0;
>   
>   	if ((lim.discard_granularity >> SECTOR_SHIFT) >
>   	    lim.max_hw_discard_sectors) {
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers
  2025-09-10 11:11 [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
  2025-09-10 11:11 ` [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter Zhang Yi
  2025-09-10 11:11 ` [PATCH v2 2/2] drbd: " Zhang Yi
@ 2025-09-12  6:16 ` Zhang Yi
  2025-09-15 10:43   ` John Garry
  2025-09-17 14:21 ` (subset) " Jens Axboe
  3 siblings, 1 reply; 10+ messages in thread
From: Zhang Yi @ 2025-09-12  6:16 UTC (permalink / raw)
  To: axboe
  Cc: linux-block, linux-raid, drbd-dev, linux-fsdevel, linux-kernel,
	john.g.garry, pmenzel, hch, martin.petersen, yi.zhang, yukuai3,
	yangerkun

Hi, Jens!

Can you take this patch set through the linux-block tree?

Thanks,
Yi.

On 9/10/2025 7:11 PM, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> Changes since v1:
>  - Improve commit messages in patch 1 by adding a simple reproduction
>    case as Paul suggested and explaining the implementation differences
>    between RAID 0 and RAID 1/10/5, no code changes.
> 
> v1: https://lore.kernel.org/linux-block/20250825083320.797165-1-yi.zhang@huaweicloud.com/
> 
> This series fixes the initialization of max_hw_wzeroes_unmap_sectors in
> queue_limits for all md raid and drbd drivers, preventing
> blk_validate_limits() failures on underlying devices that support the
> unmap write zeroes command.
> 
> Best regards,
> Yi.
> 
> Zhang Yi (2):
>   md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
>   drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
> 
>  drivers/block/drbd/drbd_nl.c | 1 +
>  drivers/md/md-linear.c       | 1 +
>  drivers/md/raid0.c           | 1 +
>  drivers/md/raid1.c           | 1 +
>  drivers/md/raid10.c          | 1 +
>  drivers/md/raid5.c           | 1 +
>  6 files changed, 6 insertions(+)
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers
  2025-09-12  6:16 ` [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
@ 2025-09-15 10:43   ` John Garry
  2025-09-16  0:49     ` Yu Kuai
  0 siblings, 1 reply; 10+ messages in thread
From: John Garry @ 2025-09-15 10:43 UTC (permalink / raw)
  To: Zhang Yi, axboe, linux-raid
  Cc: linux-block, drbd-dev, linux-fsdevel, linux-kernel, pmenzel, hch,
	martin.petersen, yi.zhang, yukuai3, yangerkun

On 12/09/2025 07:16, Zhang Yi wrote:
> Hi, Jens!
> 
> Can you take this patch set through the linux-block tree?


md raid maintainers,

please try to get this picked up ASAP. As things stand, all these RAID 
personalities will be broken for 6.17 on drives supporting/reporting 
write zeroes.

Thanks

> 
> Thanks,
> Yi.
> 
> On 9/10/2025 7:11 PM, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.com>
>>
>> Changes since v1:
>>   - Improve commit messages in patch 1 by adding a simple reproduction
>>     case as Paul suggested and explaining the implementation differences
>>     between RAID 0 and RAID 1/10/5, no code changes.
>>
>> v1: https://urldefense.com/v3/__https://lore.kernel.org/linux-block/20250825083320.797165-1-yi.zhang@huaweicloud.com/__;!!ACWV5N9M2RV99hQ!JAN4eq3ePrspeto0Hn7563lg3392Lh44jM1oTbgxbDoClxVOh5B73QhGD53f9tiLxuxfJCr51PyAP55COV2TTZAt$
>>
>> This series fixes the initialization of max_hw_wzeroes_unmap_sectors in
>> queue_limits for all md raid and drbd drivers, preventing
>> blk_validate_limits() failures on underlying devices that support the
>> unmap write zeroes command.
>>
>> Best regards,
>> Yi.
>>
>> Zhang Yi (2):
>>    md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
>>    drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
>>
>>   drivers/block/drbd/drbd_nl.c | 1 +
>>   drivers/md/md-linear.c       | 1 +
>>   drivers/md/raid0.c           | 1 +
>>   drivers/md/raid1.c           | 1 +
>>   drivers/md/raid10.c          | 1 +
>>   drivers/md/raid5.c           | 1 +
>>   6 files changed, 6 insertions(+)
>>
> 
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers
  2025-09-15 10:43   ` John Garry
@ 2025-09-16  0:49     ` Yu Kuai
  0 siblings, 0 replies; 10+ messages in thread
From: Yu Kuai @ 2025-09-16  0:49 UTC (permalink / raw)
  To: John Garry, Zhang Yi, axboe, linux-raid
  Cc: linux-block, drbd-dev, linux-fsdevel, linux-kernel, pmenzel, hch,
	martin.petersen, yi.zhang, yangerkun, yukuai (C)

Hi,

在 2025/09/15 18:43, John Garry 写道:
> On 12/09/2025 07:16, Zhang Yi wrote:
>> Hi, Jens!
>>
>> Can you take this patch set through the linux-block tree?
> 
> 
> md raid maintainers,
> 
> please try to get this picked up ASAP. As things stand, all these RAID 
> personalities will be broken for 6.17 on drives supporting/reporting 
> write zeroes.
> 

Not sure if Jens missed this, I'll pick patch 1 later today if Jens
doesn't apply.

Thanks,
Kuai

> Thanks
> 
>>
>> Thanks,
>> Yi.
>>
>> On 9/10/2025 7:11 PM, Zhang Yi wrote:
>>> From: Zhang Yi <yi.zhang@huawei.com>
>>>
>>> Changes since v1:
>>>   - Improve commit messages in patch 1 by adding a simple reproduction
>>>     case as Paul suggested and explaining the implementation differences
>>>     between RAID 0 and RAID 1/10/5, no code changes.
>>>
>>> v1: 
>>> https://urldefense.com/v3/__https://lore.kernel.org/linux-block/20250825083320.797165-1-yi.zhang@huaweicloud.com/__;!!ACWV5N9M2RV99hQ!JAN4eq3ePrspeto0Hn7563lg3392Lh44jM1oTbgxbDoClxVOh5B73QhGD53f9tiLxuxfJCr51PyAP55COV2TTZAt$ 
>>>
>>>
>>> This series fixes the initialization of max_hw_wzeroes_unmap_sectors in
>>> queue_limits for all md raid and drbd drivers, preventing
>>> blk_validate_limits() failures on underlying devices that support the
>>> unmap write zeroes command.
>>>
>>> Best regards,
>>> Yi.
>>>
>>> Zhang Yi (2):
>>>    md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
>>>    drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
>>>
>>>   drivers/block/drbd/drbd_nl.c | 1 +
>>>   drivers/md/md-linear.c       | 1 +
>>>   drivers/md/raid0.c           | 1 +
>>>   drivers/md/raid1.c           | 1 +
>>>   drivers/md/raid10.c          | 1 +
>>>   drivers/md/raid5.c           | 1 +
>>>   6 files changed, 6 insertions(+)
>>>
>>
>>
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
  2025-09-10 11:11 ` [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter Zhang Yi
  2025-09-10 11:41   ` Hannes Reinecke
@ 2025-09-17  1:20   ` Yu Kuai
  1 sibling, 0 replies; 10+ messages in thread
From: Yu Kuai @ 2025-09-17  1:20 UTC (permalink / raw)
  To: Zhang Yi, linux-block, linux-raid, drbd-dev
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, axboe, yi.zhang, yangerkun, yukuai (C)

在 2025/09/10 19:11, Zhang Yi 写道:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> 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: 0c40d7cb5ef3 ("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>
> ---
>   drivers/md/md-linear.c | 1 +
>   drivers/md/raid0.c     | 1 +
>   drivers/md/raid1.c     | 1 +
>   drivers/md/raid10.c    | 1 +
>   drivers/md/raid5.c     | 1 +
>   5 files changed, 5 insertions(+)
> 
> diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
> index 5d9b08115375..3e1f165c2d20 100644
> --- a/drivers/md/md-linear.c
> +++ b/drivers/md/md-linear.c
> @@ -73,6 +73,7 @@ static int linear_set_limits(struct mddev *mddev)
>   	md_init_stacking_limits(&lim);
>   	lim.max_hw_sectors = mddev->chunk_sectors;
>   	lim.max_write_zeroes_sectors = mddev->chunk_sectors;
> +	lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
>   	lim.io_min = mddev->chunk_sectors << 9;
>   	err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
>   	if (err)
> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
> index f1d8811a542a..419139ad7663 100644
> --- a/drivers/md/raid0.c
> +++ b/drivers/md/raid0.c
> @@ -382,6 +382,7 @@ static int raid0_set_limits(struct mddev *mddev)
>   	md_init_stacking_limits(&lim);
>   	lim.max_hw_sectors = mddev->chunk_sectors;
>   	lim.max_write_zeroes_sectors = mddev->chunk_sectors;
> +	lim.max_hw_wzeroes_unmap_sectors = mddev->chunk_sectors;
>   	lim.io_min = mddev->chunk_sectors << 9;
>   	lim.io_opt = lim.io_min * mddev->raid_disks;
>   	lim.chunk_sectors = mddev->chunk_sectors;
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index bf44878ec640..d30b82beeb92 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -3211,6 +3211,7 @@ 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..9832eefb2f15 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..e385ef1355e8 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,
> 
Apply patch 1 to md-6.17.

Thanks,
Kuai


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: (subset) [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers
  2025-09-10 11:11 [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
                   ` (2 preceding siblings ...)
  2025-09-12  6:16 ` [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
@ 2025-09-17 14:21 ` Jens Axboe
  3 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2025-09-17 14:21 UTC (permalink / raw)
  To: linux-block, linux-raid, drbd-dev, Zhang Yi
  Cc: linux-fsdevel, linux-kernel, john.g.garry, pmenzel, hch,
	martin.petersen, yi.zhang, yukuai3, yangerkun


On Wed, 10 Sep 2025 19:11:05 +0800, Zhang Yi wrote:
> Changes since v1:
>  - Improve commit messages in patch 1 by adding a simple reproduction
>    case as Paul suggested and explaining the implementation differences
>    between RAID 0 and RAID 1/10/5, no code changes.
> 
> v1: https://lore.kernel.org/linux-block/20250825083320.797165-1-yi.zhang@huaweicloud.com/
> 
> [...]

Applied, thanks!

[2/2] drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter
      commit: 027a7a9c07d0d759ab496a7509990aa33a4b689c

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-09-17 14:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10 11:11 [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
2025-09-10 11:11 ` [PATCH v2 1/2] md: init queue_limits->max_hw_wzeroes_unmap_sectors parameter Zhang Yi
2025-09-10 11:41   ` Hannes Reinecke
2025-09-17  1:20   ` Yu Kuai
2025-09-10 11:11 ` [PATCH v2 2/2] drbd: " Zhang Yi
2025-09-10 11:41   ` Hannes Reinecke
2025-09-12  6:16 ` [PATCH v2 0/2] Fix the initialization of max_hw_wzeroes_unmap_sectors for stacking drivers Zhang Yi
2025-09-15 10:43   ` John Garry
2025-09-16  0:49     ` Yu Kuai
2025-09-17 14:21 ` (subset) " Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).