* [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes
@ 2017-12-14 20:49 Jeff Lien
2017-12-14 22:42 ` Keith Busch
2017-12-15 3:52 ` Martin K. Petersen
0 siblings, 2 replies; 4+ messages in thread
From: Jeff Lien @ 2017-12-14 20:49 UTC (permalink / raw)
If you format a device with a 4k sector size back to 512 bytes,
the queue limit values for physical block size and IO sizes were
not getting updated; only the logical block size was being
updated. This patch adds code to update the physical block
and IO sizes.
Signed-off-by: Jeff Lien <jeff.lien at wdc.com>
---
drivers/nvme/host/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f837d666cbd4..035ed9e57f70 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1336,6 +1336,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
{
sector_t capacity = le64_to_cpup(&id->nsze) << (ns->lba_shift - 9);
unsigned stream_alignment = 0;
+ unsigned short bs;
if (ns->ctrl->nr_streams && ns->sws && ns->sgs)
stream_alignment = ns->sws * ns->sgs;
@@ -1343,7 +1344,10 @@ static void nvme_update_disk_info(struct gendisk *disk,
blk_mq_freeze_queue(disk->queue);
blk_integrity_unregister(disk);
- blk_queue_logical_block_size(disk->queue, 1 << ns->lba_shift);
+ bs = 1 << ns->lba_shift;
+ blk_queue_logical_block_size(disk->queue, bs);
+ blk_queue_physical_block_size(ns->queue, bs);
+ blk_limits_io_min(&ns->queue->limits, bs);
if (ns->ms && !ns->ext &&
(ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
nvme_init_integrity(disk, ns->ms, ns->pi_type);
--
2.14.2.746.g8fb8a94
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes
2017-12-14 20:49 [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes Jeff Lien
@ 2017-12-14 22:42 ` Keith Busch
2017-12-15 3:52 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Keith Busch @ 2017-12-14 22:42 UTC (permalink / raw)
On Thu, Dec 14, 2017@02:49:36PM -0600, Jeff Lien wrote:
> If you format a device with a 4k sector size back to 512 bytes,
> the queue limit values for physical block size and IO sizes were
> not getting updated; only the logical block size was being
> updated. This patch adds code to update the physical block
> and IO sizes.
That's true, though I always considered that to be a happy accident. As
far as I know, most NVMe SSDs advertising a 512 byte logical block are
only emulating that size, and are natively 4k or larger.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes
2017-12-14 20:49 [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes Jeff Lien
2017-12-14 22:42 ` Keith Busch
@ 2017-12-15 3:52 ` Martin K. Petersen
2017-12-15 14:53 ` Christoph Hellwig
1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2017-12-15 3:52 UTC (permalink / raw)
Jeff,
> + blk_queue_logical_block_size(disk->queue, bs);
> + blk_queue_physical_block_size(ns->queue, bs);
A bit messy that you mix ns->queue and disk->queue.
> + blk_limits_io_min(&ns->queue->limits, bs);
blk_queue_io_min(foo->queue, bs);
Otherwise OK.
Reviewed-by: Martin K. Petersen <martin.petersen at oracle.com>
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes
2017-12-15 3:52 ` Martin K. Petersen
@ 2017-12-15 14:53 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-12-15 14:53 UTC (permalink / raw)
On Thu, Dec 14, 2017@10:52:11PM -0500, Martin K. Petersen wrote:
>
> Jeff,
>
> > + blk_queue_logical_block_size(disk->queue, bs);
> > + blk_queue_physical_block_size(ns->queue, bs);
>
> A bit messy that you mix ns->queue and disk->queue.
It's not just ugly, but actually broken. We must use disk->queue
both times to correctly handle multipathing.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-15 14:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 20:49 [PATCH] NVMe: Format fix when going from 4k sector size to 512 bytes Jeff Lien
2017-12-14 22:42 ` Keith Busch
2017-12-15 3:52 ` Martin K. Petersen
2017-12-15 14:53 ` 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.