[PATCH 2/2] nvme: round max_discard_sectors down against discard_granularity
Tom Yan
tom.ty89 at gmail.com
Mon Aug 16 11:11:02 PDT 2021
Signed-off-by: Tom Yan <tom.ty89 at gmail.com>
---
drivers/nvme/host/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3a1bfb45da2a..dff165b92ff6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1636,6 +1636,9 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
if (blk_queue_flag_test_and_set(QUEUE_FLAG_DISCARD, queue))
return;
+ ctrl->max_discard_sectors = round_down(ctrl->max_discard_sectors,
+ size >> SECTOR_SHIFT);
+
blk_queue_max_discard_sectors(queue, ctrl->max_discard_sectors);
blk_queue_max_discard_segments(queue, ctrl->max_discard_segments);
--
2.32.0
More information about the Linux-nvme
mailing list