[PATCH] block: stack max_user_discard_sectors

From: Benjamin Marzinski

Date: Mon Nov 09 2026 - 14:40:40 EST


blk_validate_limits() sets a device's max_discard_sectors partially
based on the value of max_user_discard_sectors. For this to be set
correctly on a stacked device, max_user_discard_sectors needs to be set
to the smallest value of its underlying devices. Otherwise the stacked
device can pass down discards that are over the size limit of the
underlying device. This is a particular problem for request-based
dm-multipath devices, where the underlying device does not have a chance
to split the discard.

Fixes: 4f563a64732d ("block: add a max_user_discard_sectors queue limit")
Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
block/blk-settings.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 1f5ee2453269..1f02a867061e 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -919,6 +919,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,

t->max_discard_sectors = min_not_zero(t->max_discard_sectors,
b->max_discard_sectors);
+ t->max_user_discard_sectors = min_not_zero(t->max_user_discard_sectors,
+ b->max_user_discard_sectors);
t->max_hw_discard_sectors = min_not_zero(t->max_hw_discard_sectors,
b->max_hw_discard_sectors);
t->discard_granularity = max(t->discard_granularity,
--
2.56.0