mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] block: stack max_user_discard_sectors
@ 2026-11-09 19:39 Benjamin Marzinski
  2026-11-20 15:40 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Marzinski @ 2026-11-09 19:39 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Christoph Hellwig, Hannes Reinecke, Keith Busch,
	Martin K . Petersen, linux-block, linux-kernel

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@redhat.com>
---
 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


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

* Re: [PATCH] block: stack max_user_discard_sectors
  2026-11-09 19:39 [PATCH] block: stack max_user_discard_sectors Benjamin Marzinski
@ 2026-11-20 15:40 ` Christoph Hellwig
  2026-11-20 19:43   ` Benjamin Marzinski
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2026-11-20 15:40 UTC (permalink / raw)
  To: Benjamin Marzinski
  Cc: Jens Axboe, Christoph Hellwig, Hannes Reinecke, Keith Busch,
	Martin K . Petersen, linux-block, linux-kernel

On Mon, Nov 09, 2026 at 02:39:27PM -0500, Benjamin Marzinski wrote:
>  		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);

I don't think we should take the underlying max_user_discard_sectors
into account here, just max_discard_sectors.  But otherwise yes, this
should be stacked.

Please avoid the overly long lines, though.

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

* Re: [PATCH] block: stack max_user_discard_sectors
  2026-11-20 15:40 ` Christoph Hellwig
@ 2026-11-20 19:43   ` Benjamin Marzinski
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Marzinski @ 2026-11-20 19:43 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Hannes Reinecke, Keith Busch, Martin K . Petersen,
	linux-block, linux-kernel

On Fri, Nov 20, 2026 at 04:40:40PM +0100, Christoph Hellwig wrote:
> On Mon, Nov 09, 2026 at 02:39:27PM -0500, Benjamin Marzinski wrote:
> >  		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);
> 
> I don't think we should take the underlying max_user_discard_sectors
> into account here, just max_discard_sectors.

Is that to handle devices that call blk_queue_disable_discard()? I
didn't think about that. Makes sense.

> But otherwise yes, this
> should be stacked.
> 
> Please avoid the overly long lines, though.

Sure.

-Ben


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

end of thread, other threads:[~2026-11-20 19:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 19:39 [PATCH] block: stack max_user_discard_sectors Benjamin Marzinski
2026-11-20 15:40 ` Christoph Hellwig
2026-11-20 19:43   ` Benjamin Marzinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®