Skip to contentSkip to conversation

nvme: set discard_alignment to zero

PATCH New David Disseldorp 4 participants 5 messages Nov 24, 2017 – Dec 4, 2017 NVMe

lore
Share & tools
lore
#0 lore raw

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.

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
index 25da74d310d1..2e224ab5c340 100644
@@ -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
#1 lore raw

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: 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.

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
index 25da74d310d1..2e224ab5c340 100644
@@ -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---

maintainer
#2 lore raw

PATCH 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: 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.

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
index 25da74d310d1..2e224ab5c340 100644
@@ -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
#3 lore raw

PATCH 1/1 nvme: set discard_alignment to zero

In reply to David Disseldorp

David,

Quoted 15 lines

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.

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
index 25da74d310d1..2e224ab5c340 100644

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.

Reviewed-by Martin K. Petersen <martin.petersen at oracle.com>
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering