nvmf/tcp: Fix wrong data offset in nvmf_tcp_pdu_payload_insert_dif

We updated readv_offset before generating DIF to avoid adding
the temporary variable _rc in the previous patch, but that caused
write error when inserting DIF.

Fix the bug in this patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Id0788280a83cbea2554c851db77751432fc00cba
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461116
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-07-10 09:53:53 +09:00 committed by Darek Stojaczyk
parent 2c9b0af271
commit 9d4ee5f344

View File

@ -1859,12 +1859,13 @@ err:
}
static int
nvmf_tcp_pdu_payload_insert_dif(struct nvme_tcp_pdu *pdu, int read_len)
nvmf_tcp_pdu_payload_insert_dif(struct nvme_tcp_pdu *pdu, uint32_t read_offset,
int read_len)
{
int rc;
rc = spdk_dif_generate_stream(pdu->data_iov, pdu->data_iovcnt,
pdu->readv_offset, read_len, pdu->dif_ctx);
read_offset, read_len, pdu->dif_ctx);
if (rc != 0) {
SPDK_ERRLOG("DIF generate failed\n");
}
@ -1985,7 +1986,7 @@ spdk_nvmf_tcp_sock_process(struct spdk_nvmf_tcp_qpair *tqpair)
pdu->readv_offset += rc;
if (spdk_unlikely(pdu->dif_ctx != NULL)) {
rc = nvmf_tcp_pdu_payload_insert_dif(pdu, rc);
rc = nvmf_tcp_pdu_payload_insert_dif(pdu, pdu->readv_offset - rc, rc);
if (rc != 0) {
return NVME_TCP_PDU_FATAL;
}