[PATCH 5.9 178/255] nvme: freeze the queue over ->lba_shift updates
From: Greg Kroah-Hartman
Date: Tue Nov 17 2020 - 08:47:13 EST
[ Upstream commit f9d5f4579feafa721dba2f350fc064a1852c6f8c ]
Ensure that there can't be any I/O in flight went we change the disk
geometry in nvme_update_ns_info, most notable the LBA size by lifting
the queue free from nvme_update_disk_info into the caller
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Reviewed-by: Keith Busch <kbusch@xxxxxxxxxx>
Reviewed-by: Damien Le Moal <damien.lemoal@xxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/nvme/host/core.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index be0cec51f5e6d..b130696b00592 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2001,7 +2001,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
/* unsupported block size, set capacity to 0 later */
bs = (1 << 9);
}
- blk_mq_freeze_queue(disk->queue);
+
blk_integrity_unregister(disk);
atomic_bs = phys_bs = bs;
@@ -2066,8 +2066,6 @@ static void nvme_update_disk_info(struct gendisk *disk,
set_disk_ro(disk, true);
else
set_disk_ro(disk, false);
-
- blk_mq_unfreeze_queue(disk->queue);
}
static inline bool nvme_first_scan(struct gendisk *disk)
@@ -2114,6 +2112,7 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
struct nvme_ctrl *ctrl = ns->ctrl;
int ret;
+ blk_mq_freeze_queue(ns->disk->queue);
/*
* If identify namespace failed, use default 512 byte block size so
* block layer can use before failing read/write for 0 capacity.
@@ -2131,29 +2130,38 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
dev_warn(ctrl->device,
"failed to add zoned namespace:%u ret:%d\n",
ns->head->ns_id, ret);
- return ret;
+ goto out_unfreeze;
}
break;
default:
dev_warn(ctrl->device, "unknown csi:%u ns:%u\n",
ns->head->ids.csi, ns->head->ns_id);
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_unfreeze;
}
ret = nvme_configure_metadata(ns, id);
if (ret)
- return ret;
+ goto out_unfreeze;
nvme_set_chunk_sectors(ns, id);
nvme_update_disk_info(disk, ns, id);
+ blk_mq_unfreeze_queue(ns->disk->queue);
+
#ifdef CONFIG_NVME_MULTIPATH
if (ns->head->disk) {
+ blk_mq_freeze_queue(ns->head->disk->queue);
nvme_update_disk_info(ns->head->disk, ns, id);
blk_stack_limits(&ns->head->disk->queue->limits,
&ns->queue->limits, 0);
nvme_mpath_update_disk_size(ns->head->disk);
+ blk_mq_unfreeze_queue(ns->head->disk->queue);
}
#endif
return 0;
+
+out_unfreeze:
+ blk_mq_unfreeze_queue(ns->disk->queue);
+ return ret;
}
static int _nvme_revalidate_disk(struct gendisk *disk)
--
2.27.0