nvme: respect user max_discard_sectors setting
PATCH 1/1 nvme: respect user max_discard_sectors setting
From: Keith Busch <[email protected]>
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.
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -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);
Signature · 1 line
2.34.1
Christoph Hellwig
maintainerQuoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
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
Keith Busch
maintainerQuoted 7 lines · Christoph Hellwig
Quoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
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.
Quoted 7 lines
blk_queue_max_discard_sectorsupdates 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'?
Christoph Hellwig
maintainerQuoted 11 lines · Keith Busch
Quoted 7 lines
blk_queue_max_discard_sectorsupdates 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 thingsCool, 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.