nvmf: remove redundant nvmf_process_io_cmd params
Everything necessary for processing an I/O is now stored in nvmf_request. Change-Id: I3f390707ebe83ea66a116dcfda4d0388a6823629 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
8c6fa80874
commit
2f5ccef310
@ -403,7 +403,6 @@ nvmf_io_cmd_continue(struct spdk_nvmf_conn *conn, struct nvme_qp_tx_desc *tx_des
|
|||||||
{
|
{
|
||||||
struct nvme_qp_rx_desc *rx_desc;
|
struct nvme_qp_rx_desc *rx_desc;
|
||||||
struct nvmf_request *req;
|
struct nvmf_request *req;
|
||||||
struct spdk_nvme_cmd *cmd;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
||||||
@ -414,11 +413,10 @@ nvmf_io_cmd_continue(struct spdk_nvmf_conn *conn, struct nvme_qp_tx_desc *tx_des
|
|||||||
}
|
}
|
||||||
|
|
||||||
req = &tx_desc->req_state;
|
req = &tx_desc->req_state;
|
||||||
cmd = &req->cmd->nvme_cmd;
|
|
||||||
req->fabric_rx_ctx = rx_desc;
|
req->fabric_rx_ctx = rx_desc;
|
||||||
|
|
||||||
/* send to NVMf library for backend NVMe processing */
|
/* send to NVMf library for backend NVMe processing */
|
||||||
ret = nvmf_process_io_cmd(req->session, cmd, req->data, req->length, req);
|
ret = nvmf_process_io_cmd(req);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* library failed the request and should have
|
/* library failed the request and should have
|
||||||
Updated the response */
|
Updated the response */
|
||||||
@ -675,7 +673,7 @@ nvmf_process_io_command(struct spdk_nvmf_conn *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* send to NVMf library for backend NVMe processing */
|
/* send to NVMf library for backend NVMe processing */
|
||||||
ret = nvmf_process_io_cmd(req->session, cmd, req->data, req->length, req);
|
ret = nvmf_process_io_cmd(req);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* library failed the request and should have
|
/* library failed the request and should have
|
||||||
Updated the response */
|
Updated the response */
|
||||||
|
@ -42,11 +42,10 @@
|
|||||||
#include "spdk/trace.h"
|
#include "spdk/trace.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
nvmf_process_io_cmd(struct nvmf_session *session,
|
nvmf_process_io_cmd(struct nvmf_request *req)
|
||||||
struct spdk_nvme_cmd *cmd,
|
|
||||||
void *buf, uint32_t len,
|
|
||||||
struct nvmf_request *req_state)
|
|
||||||
{
|
{
|
||||||
|
struct nvmf_session *session = req->session;
|
||||||
|
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
|
||||||
struct spdk_nvme_cpl *response;
|
struct spdk_nvme_cpl *response;
|
||||||
struct spdk_nvmf_subsystem *subsystem = session->subsys;
|
struct spdk_nvmf_subsystem *subsystem = session->subsys;
|
||||||
struct spdk_nvmf_namespace *nvmf_ns;
|
struct spdk_nvmf_namespace *nvmf_ns;
|
||||||
@ -60,10 +59,10 @@ nvmf_process_io_cmd(struct nvmf_session *session,
|
|||||||
uint32_t io_flags;
|
uint32_t io_flags;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_io_cmd: req_state %p\n", req_state);
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_io_cmd: req %p\n", req);
|
||||||
|
|
||||||
/* pre-set response details for this command */
|
/* pre-set response details for this command */
|
||||||
response = &req_state->rsp->nvme_cpl;
|
response = &req->rsp->nvme_cpl;
|
||||||
response->status.sc = SPDK_NVME_SC_SUCCESS;
|
response->status.sc = SPDK_NVME_SC_SUCCESS;
|
||||||
response->cid = cmd->cid;
|
response->cid = cmd->cid;
|
||||||
|
|
||||||
@ -108,20 +107,20 @@ nvmf_process_io_cmd(struct nvmf_session *session,
|
|||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_io_cmd: Read; lba address %lx, lba count %x\n",
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_io_cmd: Read; lba address %lx, lba count %x\n",
|
||||||
lba_address, lba_count);
|
lba_address, lba_count);
|
||||||
spdk_trace_record(TRACE_NVMF_LIB_READ_START, 0, 0,
|
spdk_trace_record(TRACE_NVMF_LIB_READ_START, 0, 0,
|
||||||
(uint64_t)req_state->fabric_rx_ctx, 0);
|
(uint64_t)req->fabric_rx_ctx, 0);
|
||||||
rc = spdk_nvme_ns_cmd_read(ns, qpair,
|
rc = spdk_nvme_ns_cmd_read(ns, qpair,
|
||||||
buf, lba_address, lba_count,
|
req->data, lba_address, lba_count,
|
||||||
nvmf_complete_cmd,
|
nvmf_complete_cmd,
|
||||||
(void *)req_state, io_flags);
|
req, io_flags);
|
||||||
} else {
|
} else {
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_io_cmd: Write; lba address %lx, lba count %x\n",
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_process_io_cmd: Write; lba address %lx, lba count %x\n",
|
||||||
lba_address, lba_count);
|
lba_address, lba_count);
|
||||||
spdk_trace_record(TRACE_NVMF_LIB_WRITE_START, 0, 0,
|
spdk_trace_record(TRACE_NVMF_LIB_WRITE_START, 0, 0,
|
||||||
(uint64_t)req_state->fabric_rx_ctx, 0);
|
(uint64_t)req->fabric_rx_ctx, 0);
|
||||||
rc = spdk_nvme_ns_cmd_write(ns, qpair,
|
rc = spdk_nvme_ns_cmd_write(ns, qpair,
|
||||||
buf, lba_address, lba_count,
|
req->data, lba_address, lba_count,
|
||||||
nvmf_complete_cmd,
|
nvmf_complete_cmd,
|
||||||
(void *)req_state, io_flags);
|
req, io_flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -129,9 +128,9 @@ nvmf_process_io_cmd(struct nvmf_session *session,
|
|||||||
cmd->nsid = nsid;
|
cmd->nsid = nsid;
|
||||||
rc = spdk_nvme_ctrlr_cmd_io_raw(ctrlr, qpair,
|
rc = spdk_nvme_ctrlr_cmd_io_raw(ctrlr, qpair,
|
||||||
cmd,
|
cmd,
|
||||||
buf, len,
|
req->data, req->length,
|
||||||
nvmf_complete_cmd,
|
nvmf_complete_cmd,
|
||||||
(void *)req_state);
|
req);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +126,7 @@ nvmf_process_admin_cmd(struct nvmf_session *session,
|
|||||||
struct nvmf_request *req_state);
|
struct nvmf_request *req_state);
|
||||||
|
|
||||||
int
|
int
|
||||||
nvmf_process_io_cmd(struct nvmf_session *session,
|
nvmf_process_io_cmd(struct nvmf_request *req);
|
||||||
struct spdk_nvme_cmd *cmd,
|
|
||||||
void *buf, uint32_t len,
|
|
||||||
struct nvmf_request *req_state);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nvmf_property_get(struct nvmf_session *session,
|
nvmf_property_get(struct nvmf_session *session,
|
||||||
|
@ -528,44 +528,47 @@ nvmf_test_process_io_cmd(void)
|
|||||||
struct nvmf_request nvmf_req = {};
|
struct nvmf_request nvmf_req = {};
|
||||||
struct nvme_read_cdw12 *cdw12;
|
struct nvme_read_cdw12 *cdw12;
|
||||||
struct spdk_nvmf_subsystem *tmp;
|
struct spdk_nvmf_subsystem *tmp;
|
||||||
int buf_len = 64;
|
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
nvmf_cmd.opc = SPDK_NVME_OPC_READ;
|
nvmf_cmd.opc = SPDK_NVME_OPC_READ;
|
||||||
nvmf_cmd.nsid = 2;
|
nvmf_cmd.nsid = 2;
|
||||||
nvmf_cmd.cid = 3;
|
nvmf_cmd.cid = 3;
|
||||||
|
nvmf_req.cmd = (union nvmf_h2c_msg *)&nvmf_cmd;
|
||||||
nvmf_req.rsp = malloc(sizeof(union nvmf_c2h_msg));
|
nvmf_req.rsp = malloc(sizeof(union nvmf_c2h_msg));
|
||||||
nvmf_req.cb_fn = io_nvmf_cmd_complete;
|
nvmf_req.cb_fn = io_nvmf_cmd_complete;
|
||||||
nvmf_req.cid = nvmf_cmd.cid;
|
nvmf_req.cid = nvmf_cmd.cid;
|
||||||
cdw12 = (struct nvme_read_cdw12 *)&nvmf_cmd.cdw12;
|
cdw12 = (struct nvme_read_cdw12 *)&nvmf_cmd.cdw12;
|
||||||
cdw12->nlb = 16; //read 16 lb, check in nvme read
|
cdw12->nlb = 16; //read 16 lb, check in nvme read
|
||||||
buf = malloc(buf_len);
|
nvmf_req.length = 64;
|
||||||
|
buf = malloc(nvmf_req.length);
|
||||||
SPDK_CU_ASSERT_FATAL(buf != NULL);
|
SPDK_CU_ASSERT_FATAL(buf != NULL);
|
||||||
|
nvmf_req.data = buf;
|
||||||
sess = nvmf_find_session_by_id("subsystem1", SS_SC_CNTLID);
|
sess = nvmf_find_session_by_id("subsystem1", SS_SC_CNTLID);
|
||||||
|
nvmf_req.session = sess;
|
||||||
sess->vcprop.csts.bits.rdy = 1;
|
sess->vcprop.csts.bits.rdy = 1;
|
||||||
CU_ASSERT_EQUAL(nvmf_process_io_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), 0);
|
CU_ASSERT_EQUAL(nvmf_process_io_cmd(&nvmf_req), 0);
|
||||||
CU_ASSERT_STRING_EQUAL(buf, "hello");
|
CU_ASSERT_STRING_EQUAL(buf, "hello");
|
||||||
nvmf_cmd.cid = 4;
|
nvmf_cmd.cid = 4;
|
||||||
nvmf_cmd.opc = SPDK_NVME_OPC_WRITE;
|
nvmf_cmd.opc = SPDK_NVME_OPC_WRITE;
|
||||||
CU_ASSERT_EQUAL(nvmf_process_io_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), 0);
|
CU_ASSERT_EQUAL(nvmf_process_io_cmd(&nvmf_req), 0);
|
||||||
nvmf_cmd.opc = 0xff;
|
nvmf_cmd.opc = 0xff;
|
||||||
nvmf_cmd.cid = 5;
|
nvmf_cmd.cid = 5;
|
||||||
CU_ASSERT_EQUAL(nvmf_process_io_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), 0);
|
CU_ASSERT_EQUAL(nvmf_process_io_cmd(&nvmf_req), 0);
|
||||||
sess->vcprop.csts.bits.rdy = 0;
|
sess->vcprop.csts.bits.rdy = 0;
|
||||||
nvmf_cmd.cid = 6;
|
nvmf_cmd.cid = 6;
|
||||||
CU_ASSERT_EQUAL(nvmf_process_io_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), -1);
|
CU_ASSERT_EQUAL(nvmf_process_io_cmd(&nvmf_req), -1);
|
||||||
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, SPDK_NVME_SC_NAMESPACE_NOT_READY);
|
CU_ASSERT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, SPDK_NVME_SC_NAMESPACE_NOT_READY);
|
||||||
sess->vcprop.csts.bits.rdy = 1;
|
sess->vcprop.csts.bits.rdy = 1;
|
||||||
/* nsid = 0 */
|
/* nsid = 0 */
|
||||||
nvmf_cmd.nsid = 0;
|
nvmf_cmd.nsid = 0;
|
||||||
nvmf_cmd.cid = 7;
|
nvmf_cmd.cid = 7;
|
||||||
CU_ASSERT_EQUAL(nvmf_process_io_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), -1);
|
CU_ASSERT_EQUAL(nvmf_process_io_cmd(&nvmf_req), -1);
|
||||||
CU_ASSERT_NOT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, SPDK_NVME_SC_SUCCESS);
|
CU_ASSERT_NOT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, SPDK_NVME_SC_SUCCESS);
|
||||||
/* set sess->subsys to NULL */
|
/* set sess->subsys to NULL */
|
||||||
tmp = sess->subsys;
|
tmp = sess->subsys;
|
||||||
sess->subsys = NULL;
|
sess->subsys = NULL;
|
||||||
nvmf_cmd.nsid = 1;
|
nvmf_cmd.nsid = 1;
|
||||||
nvmf_cmd.cid = 8;
|
nvmf_cmd.cid = 8;
|
||||||
CU_ASSERT_EQUAL(nvmf_process_io_cmd(sess, &nvmf_cmd, buf, buf_len, &nvmf_req), -1);
|
CU_ASSERT_EQUAL(nvmf_process_io_cmd(&nvmf_req), -1);
|
||||||
CU_ASSERT_NOT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, SPDK_NVME_SC_SUCCESS);
|
CU_ASSERT_NOT_EQUAL(nvmf_req.rsp->nvme_cpl.status.sc, SPDK_NVME_SC_SUCCESS);
|
||||||
sess->subsys = tmp;
|
sess->subsys = tmp;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user