* [PATCH] nvme: respect user max_discard_sectors setting
@ 2024-01-04 19:12 Keith Busch
2024-01-05 4:34 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Keith Busch @ 2024-01-04 19:12 UTC (permalink / raw)
To: linux-nvme, hch, sagi; +Cc: Keith Busch
From: Keith Busch <kbusch@kernel.org>
A user can change that attribute to 0 through sysfs, but they can't
change the hw limit. Check the hw limit instead to know if the driver
previously set up discard capabilities.
Fixes: 70200574cc229 ("block: remove QUEUE_FLAG_DISCARD")
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 50818dbcfa1ae..8d56c102974ee 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1748,7 +1748,7 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
* updating the hardware limits when overridden through sysfs. This is
* harmless because discard limits in NVMe are purely advisory.
*/
- if (queue->limits.max_discard_sectors)
+ if (queue->limits.max_hw_discard_sectors)
return;
blk_queue_max_discard_sectors(queue, max_discard_sectors);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] nvme: respect user max_discard_sectors setting
2024-01-04 19:12 [PATCH] nvme: respect user max_discard_sectors setting Keith Busch
@ 2024-01-05 4:34 ` Christoph Hellwig
2024-01-05 16:07 ` Keith Busch
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2024-01-05 4:34 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, sagi, Keith Busch
On Thu, Jan 04, 2024 at 11:12:44AM -0800, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> A user can change that attribute to 0 through sysfs, but they can't
> change the hw limit. Check the hw limit instead to know if the driver
> previously set up discard capabilities.
blk_queue_max_discard_sectors updates the hardware and user limit.
It's a bit of a mess, but Jens didn't quite like my half-hearted fix
last time. If we want to do this properly we probably need a separate
user limit and recalculate the effective limit when either the hw or
user limit changes. For early in the 6.9 merge window I plan to redo
how all the limits are set, and that should give us a better opportunity
for these kinds of things
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: respect user max_discard_sectors setting
2024-01-05 4:34 ` Christoph Hellwig
@ 2024-01-05 16:07 ` Keith Busch
2024-01-08 8:26 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Keith Busch @ 2024-01-05 16:07 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Keith Busch, linux-nvme, sagi
On Fri, Jan 05, 2024 at 05:34:01AM +0100, Christoph Hellwig wrote:
> On Thu, Jan 04, 2024 at 11:12:44AM -0800, Keith Busch wrote:
> > From: Keith Busch <kbusch@kernel.org>
> >
> > A user can change that attribute to 0 through sysfs, but they can't
> > change the hw limit. Check the hw limit instead to know if the driver
> > previously set up discard capabilities.
>
> blk_queue_max_discard_sectors updates the hardware and user limit.
> It's a bit of a mess, but Jens didn't quite like my half-hearted fix
> last time. If we want to do this properly we probably need a separate
> user limit and recalculate the effective limit when either the hw or
> user limit changes. For early in the 6.9 merge window I plan to redo
> how all the limits are set, and that should give us a better opportunity
> for these kinds of things
Cool, I look forward to seeing what improvements you have in mind for
this error prone area. In the meantime, is this patch okay with you or
is that a 'Nak'?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: respect user max_discard_sectors setting
2024-01-05 16:07 ` Keith Busch
@ 2024-01-08 8:26 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-01-08 8:26 UTC (permalink / raw)
To: Keith Busch; +Cc: Christoph Hellwig, Keith Busch, linux-nvme, sagi
On Fri, Jan 05, 2024 at 09:07:40AM -0700, Keith Busch wrote:
> > blk_queue_max_discard_sectors updates the hardware and user limit.
> > It's a bit of a mess, but Jens didn't quite like my half-hearted fix
> > last time. If we want to do this properly we probably need a separate
> > user limit and recalculate the effective limit when either the hw or
> > user limit changes. For early in the 6.9 merge window I plan to redo
> > how all the limits are set, and that should give us a better opportunity
> > for these kinds of things
>
> Cool, I look forward to seeing what improvements you have in mind for
> this error prone area. In the meantime, is this patch okay with you or
> is that a 'Nak'?
It's not a hard NAK, but I think this actually leaves us in a slightly
worse position than before. So in doubt I'd not merge it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-08 8:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04 19:12 [PATCH] nvme: respect user max_discard_sectors setting Keith Busch
2024-01-05 4:34 ` Christoph Hellwig
2024-01-05 16:07 ` Keith Busch
2024-01-08 8:26 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox