dif: Minor cleanup of spdk_dif_set_md_interleave_iovs
Four variables head_unalign, tail_unalign, num_blocks, and offset_blocks became unuseful by the last patch. Hence reduce them to buf_len and buf_offset in this patch. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I04fc1e442be6569a96533cdfe36b27fcc78e98d4 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457876 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
8b24fc4a31
commit
f1344911ea
@ -1398,8 +1398,7 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
|||||||
uint32_t *_mapped_len,
|
uint32_t *_mapped_len,
|
||||||
const struct spdk_dif_ctx *ctx)
|
const struct spdk_dif_ctx *ctx)
|
||||||
{
|
{
|
||||||
uint32_t data_block_size, head_unalign, tail_unalign;
|
uint32_t data_block_size, buf_len, buf_offset, len;
|
||||||
uint32_t num_blocks, offset_blocks, len;
|
|
||||||
struct _dif_sgl dif_sgl;
|
struct _dif_sgl dif_sgl;
|
||||||
struct _dif_sgl buf_sgl;
|
struct _dif_sgl buf_sgl;
|
||||||
|
|
||||||
@ -1409,21 +1408,21 @@ spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
|||||||
|
|
||||||
data_block_size = ctx->block_size - ctx->md_size;
|
data_block_size = ctx->block_size - ctx->md_size;
|
||||||
|
|
||||||
num_blocks = (data_offset + data_len) / data_block_size;
|
buf_len = ((data_offset + data_len) / data_block_size) * ctx->block_size +
|
||||||
tail_unalign = (data_offset + data_len) % data_block_size;
|
((data_offset + data_len) % data_block_size);
|
||||||
|
|
||||||
_dif_sgl_init(&dif_sgl, iovs, iovcnt);
|
_dif_sgl_init(&dif_sgl, iovs, iovcnt);
|
||||||
_dif_sgl_init(&buf_sgl, buf_iovs, buf_iovcnt);
|
_dif_sgl_init(&buf_sgl, buf_iovs, buf_iovcnt);
|
||||||
|
|
||||||
if (!_dif_sgl_is_valid(&buf_sgl, num_blocks * ctx->block_size + tail_unalign)) {
|
if (!_dif_sgl_is_valid(&buf_sgl, buf_len)) {
|
||||||
SPDK_ERRLOG("Buffer overflow will occur.\n");
|
SPDK_ERRLOG("Buffer overflow will occur.\n");
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_blocks = data_offset / data_block_size;
|
buf_offset = (data_offset / data_block_size) * ctx->block_size +
|
||||||
head_unalign = data_offset % data_block_size;
|
(data_offset % data_block_size);
|
||||||
|
|
||||||
_dif_sgl_advance(&buf_sgl, offset_blocks * ctx->block_size + head_unalign);
|
_dif_sgl_advance(&buf_sgl, buf_offset);
|
||||||
|
|
||||||
while (data_len != 0) {
|
while (data_len != 0) {
|
||||||
len = spdk_min(data_len, _to_next_boundary(data_offset, data_block_size));
|
len = spdk_min(data_len, _to_next_boundary(data_offset, data_block_size));
|
||||||
|
Loading…
Reference in New Issue
Block a user