dif: Support a single iovec for data buffer in spdk_dif_generate_stream
As a subsequent effort, this patch changes the interface of spdk_dif_generate_stream to accept SGL data buffer. This patch allows only a single iove. The next patch will allow multiple iovecs. Change-Id: I56f901d73ca3b9da4b56c213ebafcd7706b1fef8 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453755 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
079ad446d2
commit
17b2f5e931
@ -289,15 +289,15 @@ int spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
||||
/**
|
||||
* Generate and insert DIF into metadata space for newly read data block.
|
||||
*
|
||||
* \param buf Buffer to create extended LBA payload.
|
||||
* \param buf_len Length of the buffer to create extended LBA payload.
|
||||
* \param offset Offset to the newly read data.
|
||||
* \param read_len Length of the newly read data.
|
||||
* \param iovs iovec array describing the extended LBA payload.
|
||||
* \param iovcnt Number of elements in the iovec array.
|
||||
* \param offset Offset to the newly read data in the extended LBA payload.
|
||||
* \param read_len Length of the newly read data in the extended LBA payload.
|
||||
* \param ctx DIF context.
|
||||
*
|
||||
* \return 0 on success and negated errno otherwise.
|
||||
*/
|
||||
int spdk_dif_generate_stream(uint8_t *buf, uint32_t buf_len,
|
||||
int spdk_dif_generate_stream(struct iovec *iovs, int iovcnt,
|
||||
uint32_t offset, uint32_t read_len,
|
||||
const struct spdk_dif_ctx *ctx);
|
||||
#endif /* SPDK_DIF_H */
|
||||
|
@ -384,7 +384,7 @@ iscsi_conn_read_data_segment(struct spdk_iscsi_conn *conn,
|
||||
if (rc > 0) {
|
||||
rc = spdk_iscsi_conn_readv_data(conn, iovs, rc);
|
||||
if (rc > 0) {
|
||||
_rc = spdk_dif_generate_stream(pdu->data_buf, pdu->data_buf_len,
|
||||
_rc = spdk_dif_generate_stream(&buf_iov, 1,
|
||||
pdu->data_valid_bytes, rc,
|
||||
&dif_ctx);
|
||||
if (_rc != 0) {
|
||||
|
@ -1426,18 +1426,14 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_dif_generate_stream(uint8_t *buf, uint32_t buf_len,
|
||||
uint32_t offset, uint32_t read_len,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
static int
|
||||
dif_generate_stream(uint8_t *buf, uint32_t buf_len,
|
||||
uint32_t offset, uint32_t read_len,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
{
|
||||
uint32_t data_block_size, offset_blocks, num_blocks, i;
|
||||
uint16_t guard = 0;
|
||||
|
||||
if (buf == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data_block_size = ctx->block_size - ctx->md_size;
|
||||
|
||||
offset_blocks = offset / data_block_size;
|
||||
@ -1464,3 +1460,20 @@ spdk_dif_generate_stream(uint8_t *buf, uint32_t buf_len,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_dif_generate_stream(struct iovec *iovs, int iovcnt,
|
||||
uint32_t offset, uint32_t read_len,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
{
|
||||
if (iovs == NULL || iovcnt == 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (iovcnt == 1) {
|
||||
return dif_generate_stream(iovs[0].iov_base, iovs[0].iov_len,
|
||||
offset, read_len, ctx);
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
@ -1422,7 +1422,7 @@ set_md_interleave_iovs_test(void)
|
||||
read_base = ut_readv(0, 1024, dif_iovs, 4);
|
||||
CU_ASSERT(read_base == 1024);
|
||||
|
||||
rc = spdk_dif_generate_stream(buf1, (4096 + 128) * 4, 0, 1024, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov1, 1, 0, 1024, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 4, &iov1, 1,
|
||||
@ -1437,7 +1437,7 @@ set_md_interleave_iovs_test(void)
|
||||
read_base += ut_readv(read_base, 3071, dif_iovs, 4);
|
||||
CU_ASSERT(read_base == 4095);
|
||||
|
||||
rc = spdk_dif_generate_stream(buf1, (4096 + 128) * 4, 1024, 3071, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov1, 1, 1024, 3071, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 4, &iov1, 1,
|
||||
@ -1452,7 +1452,7 @@ set_md_interleave_iovs_test(void)
|
||||
read_base += ut_readv(read_base, 1 + 4096 * 2 + 512, dif_iovs, 4);
|
||||
CU_ASSERT(read_base == 4096 * 3 + 512);
|
||||
|
||||
rc = spdk_dif_generate_stream(buf1, (4096 + 128) * 4, 4095, 1 + 4096 * 2 + 512, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov1, 1, 4095, 1 + 4096 * 2 + 512, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_set_md_interleave_iovs(dif_iovs, 4, &iov1, 1,
|
||||
@ -1464,7 +1464,7 @@ set_md_interleave_iovs_test(void)
|
||||
read_base += ut_readv(read_base, 3584, dif_iovs, 1);
|
||||
CU_ASSERT(read_base == 4096 * 4);
|
||||
|
||||
rc = spdk_dif_generate_stream(buf1, (4096 + 128) * 4, 4096 * 3 + 512, 3584, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov1, 1, 4096 * 3 + 512, 3584, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
/* The second data buffer:
|
||||
@ -1604,25 +1604,25 @@ dif_generate_stream_test(void)
|
||||
22, 0xFFFF, 0x22, GUARD_SEED);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 0, 511, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 0, 511, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 511, 1, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 511, 1, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 512, 256, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 512, 256, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 768, 512, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 768, 512, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 1280, 1024, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 1280, 1024, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 2304, 256, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 2304, 256, &ctx);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
rc = spdk_dif_generate_stream(iov.iov_base, (512 + 8) * 5, 2560, 512, &ctx);
|
||||
rc = spdk_dif_generate_stream(&iov, 1, 2560, 512, &ctx);
|
||||
CU_ASSERT(rc == -ERANGE);
|
||||
|
||||
rc = spdk_dif_verify(&iov, 1, 5, &ctx, &err_blk);
|
||||
|
Loading…
Reference in New Issue
Block a user