]> www.infradead.org Git - users/hch/block.git/commitdiff
nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard
authorChristoph Hellwig <hch@lst.de>
Mon, 26 Feb 2024 17:56:20 +0000 (12:56 -0500)
committerChristoph Hellwig <hch@lst.de>
Thu, 29 Feb 2024 15:00:50 +0000 (07:00 -0800)
Move the handling of the NVME_QUIRK_DEALLOCATE_ZEROES quirk out of
nvme_config_discard so that it is combined with the normal write_zeroes
limit handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
drivers/nvme/host/core.c

index 74cd384ca5fc73b2a7f3d262e5996ca79bfe397c..ee1e13a658c314cd5b386d7c64590fb00c9bc1c9 100644 (file)
@@ -1816,9 +1816,6 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
        else
                blk_queue_max_discard_segments(queue, NVME_DSM_MAX_RANGES);
        queue->limits.discard_granularity = queue_logical_block_size(queue);
-
-       if (ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
-               blk_queue_max_write_zeroes_sectors(queue, UINT_MAX);
 }
 
 static bool nvme_ns_ids_equal(struct nvme_ns_ids *a, struct nvme_ns_ids *b)
@@ -2029,8 +2026,12 @@ static void nvme_update_disk_info(struct nvme_ctrl *ctrl, struct gendisk *disk,
        set_capacity_and_notify(disk, capacity);
 
        nvme_config_discard(ctrl, disk, head);
-       blk_queue_max_write_zeroes_sectors(disk->queue,
-                                          ctrl->max_zeroes_sectors);
+
+       if (ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
+               blk_queue_max_write_zeroes_sectors(disk->queue, UINT_MAX);
+       else
+               blk_queue_max_write_zeroes_sectors(disk->queue,
+                               ctrl->max_zeroes_sectors);
 }
 
 static bool nvme_ns_is_readonly(struct nvme_ns *ns, struct nvme_ns_info *info)