@@ -4243,6 +4243,20 @@ void nvme_wait_freeze(struct nvme_ctrl *ctrl)
}
EXPORT_SYMBOL_GPL(nvme_wait_freeze);
+bool nvme_frozen(struct nvme_ctrl *ctrl)
+{
+ struct nvme_ns *ns;
+ int ret = 0;
+
+ down_read(&ctrl->namespaces_rwsem);
+ list_for_each_entry(ns, &ctrl->namespaces, list)
+ ret += !blk_mq_queue_frozen(ns->queue);
+ up_read(&ctrl->namespaces_rwsem);
+
+ return ret == 0;
+}
+EXPORT_SYMBOL_GPL(nvme_frozen);
+
void nvme_start_freeze(struct nvme_ctrl *ctrl)
{
struct nvme_ns *ns;
@@ -508,6 +508,7 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl);
void nvme_wait_freeze(struct nvme_ctrl *ctrl);
void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
void nvme_start_freeze(struct nvme_ctrl *ctrl);
+bool nvme_frozen(struct nvme_ctrl *ctrl);
#define NVME_QID_ANY -1
struct request *nvme_alloc_request(struct request_queue *q,
Add one new API of nvme_frozen(), reset handler may use this helper to query if all ns queues have been frozen completely. Meantime, the reset handler can check if there is new hardware failure happened. If yes, reset handler can break from current handling, and schedule a fresh new recovery, so deadlock or deleting controller & fail all IOs can be avoided. Cc: Christoph Hellwig <hch@lst.de> Cc: Sagi Grimberg <sagi@grimberg.me> Cc: Keith Busch <kbusch@kernel.org> Cc: Max Gurtovoy <maxg@mellanox.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> --- drivers/nvme/host/core.c | 14 ++++++++++++++ drivers/nvme/host/nvme.h | 1 + 2 files changed, 15 insertions(+)