From: jeff.lien@wdc.com (Jeff Lien)
Subject: [PATCH v3] NVMe: Format fix when going from 4k sector size to 512 bytes
Date: Tue, 19 Dec 2017 13:24:15 -0600 [thread overview]
Message-ID: <20171219192415.8468-1-jeff.lien@wdc.com> (raw)
If you format a device with a 4k sector size back to 512 bytes,
the queue limit values for physical block size and minimum IO
size were not getting updated; only the logical block size was
being updated. This patch adds code to update the physical
block and IO minimum sizes.
Signed-off-by: Jeff Lien <jeff.lien at wdc.com>
---
drivers/nvme/host/core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f837d666cbd4..f289d30584c1 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,11 @@ 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(disk->queue, bs);
+ blk_queue_io_min(disk->queue, 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
next reply other threads:[~2017-12-19 19:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 19:24 Jeff Lien [this message]
2017-12-21 1:38 ` [PATCH v3] NVMe: Format fix when going from 4k sector size to 512 bytes Martin K. Petersen
2017-12-21 10:16 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171219192415.8468-1-jeff.lien@wdc.com \
--to=jeff.lien@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox