dif: Change data_len of spdk_dif_set_md_interleave_iovs to be remaining length

This patch changes the meaning of the data_len parameter of
spdk_dif_set_md_interleave_iovs from `Expected data length of the payload`
to `Expected length of the newly read data in the extended LBA payload`.

This change will align the parameters of spdk_dif_set_md_intereleave_iovs
to of spdk_dif_generate_stream.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7f9c45e78be977625713acb79d2ae82d4375f419
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457543
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-06-13 07:39:29 +09:00 committed by Darek Stojaczyk
parent df2164f6f4
commit 94f67dd5ae
4 changed files with 18 additions and 12 deletions

View File

@ -293,7 +293,7 @@ int spdk_dix_inject_error(struct iovec *iovs, int iovcnt, struct iovec *md_iov,
* \param buf_iovs SGL for the buffer to create extended LBA payload.
* \param buf_iovcnt Size of the SGL for the buffer to create extended LBA payload.
* \param data_offset Offset to store the next incoming data.
* \param data_len Expected data length of the payload.
* \param data_len Expected length of the newly read data in the extended LBA payload.
* \param mapped_len Output parameter that will contain data length mapped by
* the iovec array.
* \param ctx DIF context.

View File

@ -386,7 +386,8 @@ iscsi_conn_read_data_segment(struct spdk_iscsi_conn *conn,
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,
pdu->data_valid_bytes,
segment_len - pdu->data_valid_bytes, NULL,
&pdu->dif_ctx);
if (rc > 0) {
rc = spdk_iscsi_conn_readv_data(conn, iovs, rc);
@ -640,8 +641,8 @@ _iscsi_sgl_append_with_md(struct _iscsi_sgl *s,
buf_iov.iov_base = buf;
buf_iov.iov_len = buf_len;
rc = spdk_dif_set_md_interleave_iovs(s->iov, s->iovcnt, &buf_iov, 1,
s->iov_offset, data_len, &total_size,
dif_ctx);
s->iov_offset, data_len - s->iov_offset,
&total_size, dif_ctx);
if (rc < 0) {
SPDK_ERRLOG("Failed to setup iovs for DIF strip\n");
return false;

View File

@ -1385,17 +1385,12 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
data_block_size = ctx->block_size - ctx->md_size;
if ((data_len % data_block_size) != 0) {
SPDK_ERRLOG("Data length must be a multiple of data block size\n");
if (((data_offset + data_len) % data_block_size) != 0) {
SPDK_ERRLOG("Data offset + length must be a multiple of data block size\n");
return -EINVAL;
}
if (data_offset >= data_len) {
SPDK_ERRLOG("Data offset must be smaller than data length\n");
return -ERANGE;
}
num_blocks = data_len / data_block_size;
num_blocks = (data_offset + data_len) / data_block_size;
_dif_sgl_init(&dif_sgl, iovs, iovcnt);
_dif_sgl_init(&buf_sgl, buf_iovs, buf_iovcnt);

View File

@ -1430,6 +1430,7 @@ set_md_interleave_iovs_test(void)
CU_ASSERT(rc == 0);
data_offset += read_len;
data_len -= read_len;
/* 2nd read */
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 4, &iov1, 1,
@ -1448,6 +1449,7 @@ set_md_interleave_iovs_test(void)
CU_ASSERT(rc == 0);
data_offset += read_len;
data_len -= read_len;
/* 3rd read */
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 4, &iov1, 1,
@ -1466,6 +1468,7 @@ set_md_interleave_iovs_test(void)
CU_ASSERT(rc == 0);
data_offset += read_len;
data_len -= read_len;
/* 4th read */
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 4, &iov1, 1,
@ -1482,6 +1485,8 @@ set_md_interleave_iovs_test(void)
data_offset += read_len;
CU_ASSERT(data_offset == 4096 * 4);
data_len -= read_len;
CU_ASSERT(data_len == 0);
/* The second data buffer:
* - Set data pattern with a space for metadata for each block.
@ -1561,6 +1566,7 @@ set_md_interleave_iovs_split_test(void)
CU_ASSERT(rc == 0);
data_offset += read_len;
data_len -= read_len;
/* 2nd read */
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 8, iovs1, 7,
@ -1583,6 +1589,7 @@ set_md_interleave_iovs_split_test(void)
CU_ASSERT(rc == 0);
data_offset += read_len;
data_len -= read_len;
/* 3rd read */
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 8, iovs1, 7,
@ -1605,6 +1612,7 @@ set_md_interleave_iovs_split_test(void)
CU_ASSERT(rc == 0);
data_offset += read_len;
data_len -= read_len;
/* 4th read */
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 8, iovs1, 7,
@ -1622,6 +1630,8 @@ set_md_interleave_iovs_split_test(void)
data_offset += read_len;
CU_ASSERT(data_offset == 512 * 4);
data_len -= read_len;
CU_ASSERT(data_len == 0);
/* The second SGL data buffer:
* - Set data pattern with a space for metadata for each block.