All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: set discard_alignment to zero
@ 2017-11-24 15:30 David Disseldorp
  2017-11-28 12:38 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David Disseldorp @ 2017-11-24 15:30 UTC (permalink / raw)


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(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 25da74d310d1..2e224ab5c340 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] nvme: set discard_alignment to zero
  2017-11-24 15:30 [PATCH] nvme: set discard_alignment to zero David Disseldorp
@ 2017-11-28 12:38 ` Christoph Hellwig
  2017-12-01 22:15   ` Jens Axboe
  2017-11-30 17:40 ` Martin K. Petersen
  2017-12-04 20:20 ` Christoph Hellwig
  2 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2017-11-28 12:38 UTC (permalink / raw)


Adding Jens, who added this code, but it looks fine to me.

On Fri, Nov 24, 2017@04:30:53PM +0100, David Disseldorp wrote:
> 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(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 25da74d310d1..2e224ab5c340 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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);
> -- 
> 2.13.6
> 
> 
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
---end quoted text---

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nvme: set discard_alignment to zero
  2017-11-24 15:30 [PATCH] nvme: set discard_alignment to zero David Disseldorp
  2017-11-28 12:38 ` Christoph Hellwig
@ 2017-11-30 17:40 ` Martin K. Petersen
  2017-12-04 20:20 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-11-30 17:40 UTC (permalink / raw)



David,

> 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(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 25da74d310d1..2e224ab5c340 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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>

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nvme: set discard_alignment to zero
  2017-11-28 12:38 ` Christoph Hellwig
@ 2017-12-01 22:15   ` Jens Axboe
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2017-12-01 22:15 UTC (permalink / raw)


On 11/28/2017 05:38 AM, Christoph Hellwig wrote:
> Adding Jens, who added this code, but it looks fine to me.
> 
> On Fri, Nov 24, 2017@04:30:53PM +0100, David Disseldorp wrote:
>> 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(-)
>>
>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>> index 25da74d310d1..2e224ab5c340 100644
>> --- a/drivers/nvme/host/core.c
>> +++ b/drivers/nvme/host/core.c
>> @@ -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);

Looks good to me.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nvme: set discard_alignment to zero
  2017-11-24 15:30 [PATCH] nvme: set discard_alignment to zero David Disseldorp
  2017-11-28 12:38 ` Christoph Hellwig
  2017-11-30 17:40 ` Martin K. Petersen
@ 2017-12-04 20:20 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-12-04 20:20 UTC (permalink / raw)


Thanks,

applied to nvme-4.15.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-04 20:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-24 15:30 [PATCH] nvme: set discard_alignment to zero David Disseldorp
2017-11-28 12:38 ` Christoph Hellwig
2017-12-01 22:15   ` Jens Axboe
2017-11-30 17:40 ` Martin K. Petersen
2017-12-04 20:20 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.