dif: Factor out SGL append opeartion when splitting data buffer
The subsequent patches will refine spdk_dif_set_md_interleave_iovs to change the data_len parameter to be the remaining length, and to remove alignment constraint completely. This patch is a preparation to subsequent patches. This patch doesn't change any behavior. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I0e9be7e66d313f3ec2bd8c55cce8bb18e4fff892 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457721 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:
parent
45f480535b
commit
2bb4fb4c8c
@ -90,7 +90,6 @@ _dif_sgl_get_buf(struct _dif_sgl *s, void **_buf, uint32_t *_buf_len)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline bool
|
||||
_dif_sgl_append(struct _dif_sgl *s, uint8_t *data, uint32_t data_len)
|
||||
{
|
||||
@ -108,6 +107,27 @@ _dif_sgl_append(struct _dif_sgl *s, uint8_t *data, uint32_t data_len)
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
_dif_sgl_append_split(struct _dif_sgl *dst, struct _dif_sgl *src, uint32_t data_len)
|
||||
{
|
||||
uint8_t *buf;
|
||||
uint32_t buf_len;
|
||||
|
||||
while (data_len != 0) {
|
||||
_dif_sgl_get_buf(src, (void *)&buf, &buf_len);
|
||||
buf_len = spdk_min(buf_len, data_len);
|
||||
|
||||
if (!_dif_sgl_append(dst, buf, buf_len)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_dif_sgl_advance(src, buf_len);
|
||||
data_len -= buf_len;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This function must be used before starting iteration. */
|
||||
static bool
|
||||
_dif_sgl_is_bytes_multiple(struct _dif_sgl *s, uint32_t bytes)
|
||||
@ -1376,8 +1396,6 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
||||
uint32_t num_blocks, offset_blocks;
|
||||
struct _dif_sgl dif_sgl;
|
||||
struct _dif_sgl buf_sgl;
|
||||
uint8_t *buf;
|
||||
uint32_t buf_len, remaining;
|
||||
|
||||
if (iovs == NULL || iovcnt == 0 || buf_iovs == NULL || buf_iovcnt == 0) {
|
||||
return -EINVAL;
|
||||
@ -1408,16 +1426,9 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
||||
while (offset_blocks < num_blocks) {
|
||||
_dif_sgl_advance(&buf_sgl, head_unalign);
|
||||
|
||||
remaining = data_block_size - head_unalign;
|
||||
while (remaining != 0) {
|
||||
_dif_sgl_get_buf(&buf_sgl, (void *)&buf, &buf_len);
|
||||
buf_len = spdk_min(buf_len, remaining);
|
||||
|
||||
if (!_dif_sgl_append(&dif_sgl, buf, buf_len)) {
|
||||
goto end;
|
||||
}
|
||||
_dif_sgl_advance(&buf_sgl, buf_len);
|
||||
remaining -= buf_len;
|
||||
if (!_dif_sgl_append_split(&dif_sgl, &buf_sgl,
|
||||
data_block_size - head_unalign)) {
|
||||
break;
|
||||
}
|
||||
_dif_sgl_advance(&buf_sgl, ctx->md_size);
|
||||
offset_blocks++;
|
||||
@ -1425,7 +1436,6 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
||||
head_unalign = 0;
|
||||
}
|
||||
|
||||
end:
|
||||
if (_mapped_len != NULL) {
|
||||
*_mapped_len = dif_sgl.total_size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user