[PATCH] nvme: respect user max_discard_sectors setting

Keith Busch kbusch at meta.com
Thu Jan 4 11:12:44 PST 2024


From: Keith Busch <kbusch at 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 at 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




More information about the Linux-nvme mailing list