Commit 12b83abc authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Greg Kroah-Hartman

nvme: set 0 capacity if namespace block size exceeds PAGE_SIZE

[ Upstream commit 01fa0174 ]

If our target exposed a namespace with a block size that is greater
than PAGE_SIZE, set 0 capacity on the namespace as we do not support it.

This issue encountered when the nvmet namespace was backed by a tempfile.
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 6fb42f3c
...@@ -1591,6 +1591,10 @@ static void nvme_update_disk_info(struct gendisk *disk, ...@@ -1591,6 +1591,10 @@ static void nvme_update_disk_info(struct gendisk *disk,
sector_t capacity = le64_to_cpup(&id->nsze) << (ns->lba_shift - 9); sector_t capacity = le64_to_cpup(&id->nsze) << (ns->lba_shift - 9);
unsigned short bs = 1 << ns->lba_shift; unsigned short bs = 1 << ns->lba_shift;
if (ns->lba_shift > PAGE_SHIFT) {
/* unsupported block size, set capacity to 0 later */
bs = (1 << 9);
}
blk_mq_freeze_queue(disk->queue); blk_mq_freeze_queue(disk->queue);
blk_integrity_unregister(disk); blk_integrity_unregister(disk);
...@@ -1601,7 +1605,8 @@ static void nvme_update_disk_info(struct gendisk *disk, ...@@ -1601,7 +1605,8 @@ static void nvme_update_disk_info(struct gendisk *disk,
if (ns->ms && !ns->ext && if (ns->ms && !ns->ext &&
(ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED)) (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
nvme_init_integrity(disk, ns->ms, ns->pi_type); nvme_init_integrity(disk, ns->ms, ns->pi_type);
if (ns->ms && !nvme_ns_has_pi(ns) && !blk_get_integrity(disk)) if ((ns->ms && !nvme_ns_has_pi(ns) && !blk_get_integrity(disk)) ||
ns->lba_shift > PAGE_SHIFT)
capacity = 0; capacity = 0;
set_capacity(disk, capacity); set_capacity(disk, capacity);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment