Commit 9e68223c authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

dif: Merge _dif_sgl_advance and _dif_sgl_fast_forward



_dif_sgl_fast_forward covers _dif_sgl_advance. Hence this patch
merges two into _dif_sgl_fast_forward and renames it to
_dif_sgl_advance.

Change-Id: I4949f3028b08cec8df8c9037c983d840d0a1eaaa
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456184


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent efa4259f
Loading
Loading
Loading
Loading
+12 −23
Original line number Diff line number Diff line
@@ -63,15 +63,18 @@ _dif_sgl_init(struct _dif_sgl *s, struct iovec *iovs, int iovcnt)
	s->total_size = 0;
}

static inline void
static void
_dif_sgl_advance(struct _dif_sgl *s, uint32_t step)
{
	s->iov_offset += step;
	if (s->iov_offset == s->iov->iov_len) {
	while (s->iovcnt != 0) {
		if (s->iov_offset < s->iov->iov_len) {
			break;
		}

		s->iov_offset -= s->iov->iov_len;
		s->iov++;
		assert(s->iovcnt > 0);
		s->iovcnt--;
		s->iov_offset = 0;
	}
}

@@ -86,20 +89,6 @@ _dif_sgl_get_buf(struct _dif_sgl *s, void **_buf, uint32_t *_buf_len)
	}
}

static void
_dif_sgl_fast_forward(struct _dif_sgl *s, uint32_t offset)
{
	s->iov_offset += offset;
	while (s->iovcnt != 0) {
		if (s->iov_offset < s->iov->iov_len) {
			break;
		}

		s->iov_offset -= s->iov->iov_len;
		s->iov++;
		s->iovcnt--;
	}
}

static inline bool
_dif_sgl_append(struct _dif_sgl *s, uint8_t *data, uint32_t data_len)
@@ -878,7 +867,7 @@ _dif_inject_error(struct _dif_sgl *sgl,
	uint32_t offset_in_block, buf_len;
	void *buf;

	_dif_sgl_fast_forward(sgl, block_size * inject_offset_blocks);
	_dif_sgl_advance(sgl, block_size * inject_offset_blocks);

	offset_in_block = 0;

@@ -1361,10 +1350,10 @@ dif_set_md_interleave_iovs_split(struct iovec *iovs, int iovcnt,
	offset_blocks = data_offset / data_block_size;
	head_unalign = data_offset % data_block_size;

	_dif_sgl_fast_forward(&buf_sgl, offset_blocks * ctx->block_size);
	_dif_sgl_advance(&buf_sgl, offset_blocks * ctx->block_size);

	while (offset_blocks < num_blocks) {
		_dif_sgl_fast_forward(&buf_sgl, head_unalign);
		_dif_sgl_advance(&buf_sgl, head_unalign);

		remaining = data_block_size - head_unalign;
		while (remaining != 0) {
@@ -1377,7 +1366,7 @@ dif_set_md_interleave_iovs_split(struct iovec *iovs, int iovcnt,
			_dif_sgl_advance(&buf_sgl, buf_len);
			remaining -= buf_len;
		}
		_dif_sgl_fast_forward(&buf_sgl, ctx->md_size);
		_dif_sgl_advance(&buf_sgl, ctx->md_size);
		offset_blocks++;

		head_unalign = 0;
@@ -1483,7 +1472,7 @@ dif_generate_stream_split(struct iovec *iovs, int iovcnt,
		return -ERANGE;
	}

	_dif_sgl_fast_forward(&sgl, offset);
	_dif_sgl_advance(&sgl, offset);

	for (i = 0; i < num_blocks; i++) {
		_dif_generate_split(&sgl, offset_blocks + i, ctx);