nvme: set discard_alignment to zero
PATCH 1/1 nvme: set discard_alignment to zero
Similar to 7c084289795b ("rbd: set discard_alignment to zero"), NVMe devices are currently incorrectly initialised with the block queue discard_alignment set to the NVMe stream alignment.
As per Documentation/ABI/testing/sysfs-block:
The discard_alignment parameter indicates how many bytes the beginning of the device is offset from the internal allocation unit's natural alignment.
Correcting the discard_alignment parameter to zero has no effect on how discard requests are propagated through the block layer - @alignment in __blkdev_issue_discard() remains zero. However, it does fix other consumers, such as LIO's Block Limits VPD response.
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -1287,7 +1287,7 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl,BUILD_BUG_ON (PAGE_SIZE /sizeof (struct nvme_dsm_range ) <NVME_DSM_MAX_RANGES ); - queue->limits.discard_alignment = size; + queue->limits.discard_alignment =0 ; queue->limits.discard_granularity = size;blk_queue_max_discard_sectors (queue,UINT_MAX );
Signature · 1 line
2.13.6
PATCH 1/1 nvme: set discard_alignment to zero
Adding Jens, who added this code, but it looks fine to me.
Quoted 40 lines · David Disseldorp
Similar to
7c084289795b("rbd: setdiscard_alignmentto zero"), NVMe devices are currently incorrectly initialised with the block queuediscard_alignmentset to the NVMe stream alignment.As per
Documentation/ABI/testing/sysfs-block:
Thediscard_alignmentparameter indicates how many bytes the beginning of the device is offset from the internal allocation unit's natural alignment.Correcting the
discard_alignmentparameter to zero has no effect on how discard requests are propagated through the block layer - @alignment in__blkdev_issue_discard()remains zero. However, it does fix other consumers, such as LIO's Block Limits VPD response.Signed-off-by David Disseldorp <ddiss at suse.de>--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/core.c +1
-1@@ -1287,7 +1287,7 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl,BUILD_BUG_ON (PAGE_SIZE /sizeof (struct nvme_dsm_range ) <NVME_DSM_MAX_RANGES ); - queue->limits.discard_alignment = size; + queue->limits.discard_alignment =0 ; queue->limits.discard_granularity = size;blk_queue_max_discard_sectors (queue,UINT_MAX );Signature · 7 lines
2.13.6 _______________________________________________ Linux-nvme mailing list Linux-nvme at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme
---end quoted text---
Jens Axboe
maintainerPATCH 1/1 nvme: set discard_alignment to zero
Quoted 30 lines · Christoph Hellwig
Adding Jens, who added this code, but it looks fine to me.
Quoted 27 lines · David Disseldorp
Similar to
7c084289795b("rbd: setdiscard_alignmentto zero"), NVMe devices are currently incorrectly initialised with the block queuediscard_alignmentset to the NVMe stream alignment.As per
Documentation/ABI/testing/sysfs-block:
Thediscard_alignmentparameter indicates how many bytes the beginning of the device is offset from the internal allocation unit's natural alignment.Correcting the
discard_alignmentparameter to zero has no effect on how discard requests are propagated through the block layer - @alignment in__blkdev_issue_discard()remains zero. However, it does fix other consumers, such as LIO's Block Limits VPD response.Signed-off-by David Disseldorp <ddiss at suse.de>--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/core.c +0
-0@@ -1287,7 +1287,7 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl,BUILD_BUG_ON (PAGE_SIZE /sizeof (struct nvme_dsm_range ) <NVME_DSM_MAX_RANGES );
Quoted 5 lines
drivers/nvme/host/core.c static void nvme_config_discard(struct nvme_ctrl *ctrl, · line 1293
Quoted 5 lines
drivers/nvme/host/core.c +1
-1- queue->limits.discard_alignment = size; + queue->limits.discard_alignment =0 ; queue->limits.discard_granularity = size;blk_queue_max_discard_sectors (queue,UINT_MAX );
Looks good to me.
Signature · 1 line
Jens Axboe
PATCH 1/1 nvme: set discard_alignment to zero
In reply to David DisseldorpDavid,
Quoted 15 lines
Correcting the
discard_alignmentparameter to zero has no effect on how discard requests are propagated through the block layer - @alignment in__blkdev_issue_discard()remains zero. However, it does fix other consumers, such as LIO's Block Limits VPD response.Signed-off-by David Disseldorp <ddiss at suse.de>--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/core.c +0
-0
drivers/nvme/host/core.c static void nvme_config_discard(struct nvme_ctrl *ctrl, · line 1291
Quoted 6 lines
drivers/nvme/host/core.c +1
-1@@ -1287,7 +1287,7 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl,BUILD_BUG_ON (PAGE_SIZE /sizeof (struct nvme_dsm_range ) <NVME_DSM_MAX_RANGES ); - queue->limits.discard_alignment = size; + queue->limits.discard_alignment =0 ; queue->limits.discard_granularity = size;
This looks good to me.
The alignment parameter was really only there to handle early drives which were deliberately misaligned internally to avoid performance penalties on operating systems that started the first partition on LBA 63.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Christoph Hellwig
AppliedPATCH 1/1 nvme: set discard_alignment to zero
In reply to David DisseldorpThanks,
applied to nvme-4.15.