nvmf: Add call support for compare and write cmd in spdk_nvmf_ctrlr_process_io_cmd

Add call for spdk_nvmf_bdev_ctrlr_compare_and_write_cmd
function in spdk_nvmf_ctrlr_process_io_cmd function
when fused command is discovered.

This patch also removes redundant defines for fused flags.

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: I61971a56577ab32b52e1fde1e572f718a9a2d9aa
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476621
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Maciej Szwed 2020-01-21 12:57:03 +01:00 committed by Tomasz Zawadzki
parent 87be077d0b
commit 71beb568d6
4 changed files with 70 additions and 10 deletions

View File

@ -2839,9 +2839,9 @@ SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_fw_commit) == 4, "Incorrect size");
(cpl)->status.sc == SPDK_NVME_SC_REFERENCE_TAG_CHECK_ERROR))
/** Set fused operation */
#define SPDK_NVME_IO_FLAGS_FUSE_FIRST (1U << 0)
#define SPDK_NVME_IO_FLAGS_FUSE_SECOND (1U << 1)
#define SPDK_NVME_IO_FLAGS_FUSE_MASK (3U << 0)
#define SPDK_NVME_IO_FLAGS_FUSE_FIRST (SPDK_NVME_CMD_FUSE_FIRST << 0)
#define SPDK_NVME_IO_FLAGS_FUSE_SECOND (SPDK_NVME_CMD_FUSE_SECOND << 0)
#define SPDK_NVME_IO_FLAGS_FUSE_MASK (SPDK_NVME_CMD_FUSE_MASK << 0)
/** Enable protection information checking of the Logical Block Reference Tag field */
#define SPDK_NVME_IO_FLAGS_PRCHK_REFTAG (1U << 26)
/** Enable protection information checking of the Application Tag field */

View File

@ -2452,35 +2452,73 @@ spdk_nvmf_ctrlr_process_io_fused_cmd(struct spdk_nvmf_request *req, struct spdk_
{
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
struct spdk_nvmf_request *first_fused_req = req->qpair->first_fused_req;
int rc;
if (cmd->fuse == SPDK_NVME_CMD_FUSE_FIRST) {
/* first fused operation (should be compare) */
if (req->qpair->first_fused_req != NULL) {
struct spdk_nvme_cpl *fused_response = &req->qpair->first_fused_req->rsp->nvme_cpl;
if (first_fused_req != NULL) {
struct spdk_nvme_cpl *fused_response = &first_fused_req->rsp->nvme_cpl;
SPDK_ERRLOG("Wrong sequence of fused operations\n");
/* abort req->qpair->first_fused_request and continue with new fused command */
fused_response->status.sc = SPDK_NVME_SC_ABORTED_MISSING_FUSED;
fused_response->status.sct = SPDK_NVME_SCT_GENERIC;
spdk_nvmf_request_complete(req->qpair->first_fused_req);
spdk_nvmf_request_complete(first_fused_req);
} else if (cmd->opc != SPDK_NVME_OPC_COMPARE) {
SPDK_ERRLOG("Wrong op code of fused operations\n");
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_OPCODE;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
req->qpair->first_fused_req = req;
return SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS;
} else if (cmd->fuse == SPDK_NVME_CMD_FUSE_SECOND) {
/* second fused operation */
if (req->qpair->first_fused_req == NULL) {
/* second fused operation (should be write) */
if (first_fused_req == NULL) {
SPDK_ERRLOG("Wrong sequence of fused operations\n");
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
rsp->status.sc = SPDK_NVME_SC_ABORTED_MISSING_FUSED;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
} else if (cmd->opc != SPDK_NVME_OPC_WRITE) {
struct spdk_nvme_cpl *fused_response = &first_fused_req->rsp->nvme_cpl;
SPDK_ERRLOG("Wrong op code of fused operations\n");
/* abort req->qpair->first_fused_request and fail current command */
fused_response->status.sc = SPDK_NVME_SC_ABORTED_MISSING_FUSED;
fused_response->status.sct = SPDK_NVME_SCT_GENERIC;
spdk_nvmf_request_complete(first_fused_req);
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_OPCODE;
req->qpair->first_fused_req = NULL;
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
/* save request of first command to generate response later */
req->first_fused_req = req->qpair->first_fused_req;
req->first_fused_req = first_fused_req;
req->qpair->first_fused_req = NULL;
}
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
rc = spdk_nvmf_bdev_ctrlr_compare_and_write_cmd(bdev, desc, ch, req->first_fused_req, req);
if (rc == SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE) {
if (spdk_nvme_cpl_is_error(rsp)) {
struct spdk_nvme_cpl *fused_response = &first_fused_req->rsp->nvme_cpl;
fused_response->status = rsp->status;
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
rsp->status.sc = SPDK_NVME_SC_ABORTED_FAILED_FUSED;
/* Complete first of fused commands. Second will be completed by upper layer */
spdk_nvmf_request_complete(first_fused_req);
req->first_fused_req = NULL;
}
}
return rc;
}
int
@ -2538,6 +2576,16 @@ spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)
if (spdk_unlikely(cmd->fuse & SPDK_NVME_CMD_FUSE_MASK)) {
return spdk_nvmf_ctrlr_process_io_fused_cmd(req, bdev, desc, ch);
} else if (spdk_unlikely(req->qpair->first_fused_req != NULL)) {
struct spdk_nvme_cpl *fused_response = &req->qpair->first_fused_req->rsp->nvme_cpl;
SPDK_ERRLOG("Expected second of fused commands - failing first of fused commands\n");
/* abort req->qpair->first_fused_request and continue with new command */
fused_response->status.sc = SPDK_NVME_SC_ABORTED_MISSING_FUSED;
fused_response->status.sct = SPDK_NVME_SCT_GENERIC;
spdk_nvmf_request_complete(req->qpair->first_fused_req);
req->qpair->first_fused_req = NULL;
}
switch (cmd->opc) {

View File

@ -142,6 +142,12 @@ DEFINE_STUB(spdk_nvmf_bdev_ctrlr_compare_cmd,
struct spdk_nvmf_request *req),
0);
DEFINE_STUB(spdk_nvmf_bdev_ctrlr_compare_and_write_cmd,
int,
(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_nvmf_request *cmp_req, struct spdk_nvmf_request *write_req),
0);
DEFINE_STUB(spdk_nvmf_bdev_ctrlr_write_zeroes_cmd,
int,
(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,

View File

@ -139,6 +139,12 @@ DEFINE_STUB(spdk_nvmf_bdev_ctrlr_compare_cmd,
struct spdk_nvmf_request *req),
0);
DEFINE_STUB(spdk_nvmf_bdev_ctrlr_compare_and_write_cmd,
int,
(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
struct spdk_nvmf_request *cmp_req, struct spdk_nvmf_request *write_req),
0);
DEFINE_STUB(spdk_nvmf_bdev_ctrlr_write_zeroes_cmd,
int,
(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,