From fd3f7ee3b3aea50ce431bedfc38124810e8c73b3 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 21 Jul 2016 16:15:03 -0700 Subject: [PATCH] nvmf: simplify nvmf_process_io_cmd() Drop the redundant controller ready check. nvmf_process_io_cmd() was checking CSTS.RDY, but this is not necessary, since its only caller, spdk_nvmf_request_exec(), is already checking CC.EN, which always matches RDY in our virtual controller implementation. The initialization of status is a dead store - nvmf_complete_cmd() always writes the full response, and the only other branch is the return immediately below the call, which also sets status. Change-Id: I1ec2b8a225a91c4b2997d8ab4f45d050cc216de3 Signed-off-by: Daniel Verkamp --- lib/nvmf/request.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/nvmf/request.c b/lib/nvmf/request.c index 06b00c08f8..3827dad473 100644 --- a/lib/nvmf/request.c +++ b/lib/nvmf/request.c @@ -254,32 +254,18 @@ passthrough: static bool nvmf_process_io_cmd(struct spdk_nvmf_request *req) { - struct nvmf_session *session = req->conn->sess; - struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd; - struct spdk_nvme_cpl *response; - struct spdk_nvmf_subsystem *subsystem = session->subsys; + struct spdk_nvmf_subsystem *subsystem = req->conn->sess->subsys; int rc; - /* pre-set response details for this command */ - response = &req->rsp->nvme_cpl; - response->status.sc = SPDK_NVME_SC_SUCCESS; - - /* verify that the contoller is ready to process commands */ - if (session->vcprop.csts.bits.rdy == 0) { - SPDK_ERRLOG("Subsystem Controller Not Ready!\n"); - response->status.sc = SPDK_NVME_SC_NAMESPACE_NOT_READY; - return true; - } - rc = spdk_nvme_ctrlr_cmd_io_raw(subsystem->ctrlr, subsystem->io_qpair, - cmd, + &req->cmd->nvme_cmd, req->data, req->length, nvmf_complete_cmd, req); if (rc) { - SPDK_ERRLOG("Failed to submit Opcode 0x%02x\n", cmd->opc); - response->status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; + SPDK_ERRLOG("Failed to submit request %p\n", req); + req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR; return true; }