From 6711e5a525fc4e5d6fcf65ae31946e57bde156e4 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 9 Jan 2018 15:23:27 -0700 Subject: [PATCH] nvmf: Fail incoming commands to an inactive subsystem Eventually this should probably queue, but for now just fail these commands. Change-Id: Ie1b1088aa38198c17062ac9874539ad6d99b01eb Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/394125 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- lib/nvmf/request.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/nvmf/request.c b/lib/nvmf/request.c index b6e67c9ff..fd2138e7a 100644 --- a/lib/nvmf/request.c +++ b/lib/nvmf/request.c @@ -118,6 +118,19 @@ spdk_nvmf_request_exec(struct spdk_nvmf_request *req) nvmf_trace_command(req->cmd, qpair->type); + /* Check if the subsystem is paused (if there is a subsystem) */ + if (qpair->ctrlr) { + if (qpair->group->sgroups[qpair->ctrlr->subsys->id].state != SPDK_NVMF_SUBSYSTEM_ACTIVE) { + struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl; + + /* TODO: Queue requests here instead of failing */ + rsp->status.sct = SPDK_NVME_SCT_GENERIC; + rsp->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; + spdk_nvmf_request_complete(req); + return; + } + } + if (spdk_unlikely(req->cmd->nvmf_cmd.opcode == SPDK_NVME_OPC_FABRIC)) { status = spdk_nvmf_ctrlr_process_fabrics_cmd(req); } else if (spdk_unlikely(qpair->type == QPAIR_TYPE_AQ)) {