]> git.itanic.dy.fi Git - linux-stable/commitdiff
nvme: also skip discard granularity updates in nvme_config_discard
authorChristoph Hellwig <hch@lst.de>
Tue, 26 Dec 2023 08:58:42 +0000 (08:58 +0000)
committerKeith Busch <kbusch@kernel.org>
Wed, 3 Jan 2024 16:09:40 +0000 (08:09 -0800)
Don't just skip the discard sectors and segments but also the granularity
if a value was already set before.

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

index 56107cfc97b7bca0ba716d6b7835b301f98f492b..6c52b0ab382c85737836a485ea8cfc97ef06f7ef 100644 (file)
@@ -1727,7 +1727,6 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
                struct nvme_ns_head *head)
 {
        struct request_queue *queue = disk->queue;
-       u32 size = queue_logical_block_size(queue);
 
        if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(head, UINT_MAX))
                ctrl->max_discard_sectors =
@@ -1741,8 +1740,6 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
        BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
                        NVME_DSM_MAX_RANGES);
 
-       queue->limits.discard_granularity = size;
-
        /*
         * If discard is already enabled, don't reset queue limits.
         *
@@ -1755,6 +1752,7 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
 
        blk_queue_max_discard_sectors(queue, ctrl->max_discard_sectors);
        blk_queue_max_discard_segments(queue, ctrl->max_discard_segments);
+       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);