From: Benjamin Marzinski <bmarzins@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, Hannes Reinecke <hare@suse.de>,
Keith Busch <kbusch@kernel.org>,
"Martin K . Petersen" <mkp@kernel.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: stack max_user_discard_sectors
Date: Sun, 22 Nov 2026 14:43:53 -0500 [thread overview]
Message-ID: <awNF-dV2TacxpUqf@redhat.com> (raw)
In-Reply-To: <20261121001334.GA13058@lst.de>
On Sat, Nov 21, 2026 at 01:13:34AM +0100, Christoph Hellwig wrote:
> On Fri, Nov 20, 2026 at 02:43:59PM -0500, Benjamin Marzinski wrote:
> > > 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.
>
> That too. But also because user limits on lower devices shouldn't
> really affect upper devices for consistency, as new updates on the
> lower device after the upper one was created don't get picked up
> either.
Um... Now it doesn't make sense again.
If I do something like:
t->max_user_discard_sectors = min(t->max_user_discard_sectors,
b->max_discard_sectors);
That mean that changes to underlying device user limits can effect upper
device user limits (since adjusting max_user_discard_sectors
via sysfs automatically adjusts max_discard_sectors).
Also, while this does make blk_stack_limits() disable discards on upper
devices that have a lower device that dissabled discards with
blk_queue_disable_discard(), it doesn't disable discards on upper
devices that have lower devices that have discards disabled normally
(since blk_validate_limits() sets discard_granularity to 0 for devices
that set max_discard_sectors to 0, and this part of blk_stack_limits()
only runs if the bottom device has discard_granularity != 0). That
seems wrong. So perhaps handling blk_queue_disable_discard() isn't the
right answer. Alternatively, blk_stack_limits() could disable discards
on upper device is any of the lower device has max_discard_sectors. But
I assume there's a good reason why it currently doesn't.
Additionally, if we use max_user_discard_sectors to clamp the upper
device's max_discard_sectors to the lower device's. It allows users to
just override it by changing max_user_discard_sectors to something that
doesn't work with the underlying device. That also seems wrong.
So what do you think about doing this instead:
t->max_hw_discard_sectors = min(t->max_hw_discard_sectors,
b->max_discard_sectors);
This doesn't handle blk_queue_disable_discard(), but like I said, the
other patch didn't handle it well either. It also keep users from being
able to send too large discards by setting max_user_discard_sectors too
high on stacked devices. I'll send a v2 that does this.
-Ben
prev parent reply other threads:[~2026-11-22 19:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-11-21 0:13 ` Christoph Hellwig
2026-11-22 19:43 ` Benjamin Marzinski [this message]
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=awNF-dV2TacxpUqf@redhat.com \
--to=bmarzins@redhat.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkp@kernel.org \
/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