nvmf: Check DIF insert/strip setting of NVMf controller when getting DIF context

The first idea was that the caller of spdk_nvmf_request_get_dif_ctx()
should check if the current transport enables DIF insert/strip before
calling spdk_nvmf_request_get_dif_ctx().

But NVMf controller knows if DIF/insert/strip is enabled now by the
previous patch. Hence spdk_nvmf_request_get_dif_ctx() checks if the NVMf
controller enables DIF insert/strip at its head.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I78253d356b694800c3a9a9608514df58e0c631a6
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461314
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-07-11 07:57:22 +09:00 committed by Darek Stojaczyk
parent 91da9aaafe
commit 4ff3665ce9
2 changed files with 12 additions and 1 deletions

View File

@ -2652,6 +2652,11 @@ bool
spdk_nvmf_request_get_dif_ctx(struct spdk_nvmf_request *req, struct spdk_dif_ctx *dif_ctx)
{
struct spdk_nvmf_qpair *qpair = req->qpair;
struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr;
if (spdk_likely(ctrlr == NULL || !ctrlr->dif_insert_or_strip)) {
return false;
}
if (spdk_unlikely(qpair->state != SPDK_NVMF_QPAIR_ACTIVE)) {
return false;
@ -2665,5 +2670,5 @@ spdk_nvmf_request_get_dif_ctx(struct spdk_nvmf_request *req, struct spdk_dif_ctx
return false;
}
return spdk_nvmf_ctrlr_get_dif_ctx(qpair->ctrlr, &req->cmd->nvme_cmd, dif_ctx);
return spdk_nvmf_ctrlr_get_dif_ctx(ctrlr, &req->cmd->nvme_cmd, dif_ctx);
}

View File

@ -1182,6 +1182,12 @@ test_get_dif_ctx(void)
ns.bdev = &bdev;
ctrlr.dif_insert_or_strip = false;
ret = spdk_nvmf_request_get_dif_ctx(&req, &dif_ctx);
CU_ASSERT(ret == false);
ctrlr.dif_insert_or_strip = true;
qpair.state = SPDK_NVMF_QPAIR_UNINITIALIZED;
ret = spdk_nvmf_request_get_dif_ctx(&req, &dif_ctx);