iscsi: Get DIF context once when allocating data buffer

DIF context had been got for every read of data segment but
DIF context is not changed and so getting DIF context once
when allocating data buffer is enough and is done in this
patch.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I0f386ab594a0d9076fa0206d5fc240f5c790181d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456772
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-06-04 16:06:54 +09:00 committed by Changpeng Liu
parent 1204ff34e0
commit 85e6f154b8

View File

@ -365,27 +365,25 @@ iscsi_conn_read_data_segment(struct spdk_iscsi_conn *conn,
struct spdk_iscsi_pdu *pdu,
uint32_t segment_len)
{
struct spdk_dif_ctx dif_ctx;
struct iovec buf_iov, iovs[32];
int rc, _rc;
if (spdk_likely(!spdk_iscsi_get_dif_ctx(conn, pdu, &dif_ctx))) {
if (spdk_likely(!pdu->dif_insert_or_strip)) {
return spdk_iscsi_conn_read_data(conn,
segment_len - pdu->data_valid_bytes,
pdu->data_buf + pdu->data_valid_bytes);
} else {
pdu->dif_insert_or_strip = true;
buf_iov.iov_base = pdu->data_buf;
buf_iov.iov_len = pdu->data_buf_len;
rc = spdk_dif_set_md_interleave_iovs(iovs, 32, &buf_iov, 1,
pdu->data_valid_bytes, segment_len, NULL,
&dif_ctx);
&pdu->dif_ctx);
if (rc > 0) {
rc = spdk_iscsi_conn_readv_data(conn, iovs, rc);
if (rc > 0) {
_rc = spdk_dif_generate_stream(&buf_iov, 1,
pdu->data_valid_bytes, rc,
&dif_ctx);
&pdu->dif_ctx);
if (_rc != 0) {
SPDK_ERRLOG("DIF generate failed\n");
rc = _rc;
@ -484,6 +482,10 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
return 0;
}
pdu->data_buf = pdu->mobj->buf;
if (spdk_unlikely(spdk_iscsi_get_dif_ctx(conn, pdu, &pdu->dif_ctx))) {
pdu->dif_insert_or_strip = true;
}
}
rc = iscsi_conn_read_data_segment(conn, pdu, data_len);