Commit 72a6fff8 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

bdev: move pulling data to bounce buffer to a function



Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Idbabcd5bd812cede6f5159ba0691b2dc28a4022a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17674


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent eb8f9bbc
Loading
Loading
Loading
Loading
+24 −14
Original line number Diff line number Diff line
@@ -1128,23 +1128,11 @@ _bdev_io_pull_bounce_data_buf_done(void *ctx, int rc)
}

static void
_bdev_io_pull_bounce_data_buf(struct spdk_bdev_io *bdev_io, void *buf, size_t len,
			      bdev_copy_bounce_buffer_cpl cpl_cb)
bdev_io_pull_data(struct spdk_bdev_io *bdev_io)
{
	struct spdk_bdev_channel *ch = bdev_io->internal.ch;
	int rc = 0;

	bdev_io->internal.data_transfer_cpl = cpl_cb;
	/* save original iovec */
	bdev_io->internal.orig_iovs = bdev_io->u.bdev.iovs;
	bdev_io->internal.orig_iovcnt = bdev_io->u.bdev.iovcnt;
	/* set bounce iov */
	bdev_io->u.bdev.iovs = &bdev_io->internal.bounce_iov;
	bdev_io->u.bdev.iovcnt = 1;
	/* set bounce buffer for this operation */
	bdev_io->u.bdev.iovs[0].iov_base = buf;
	bdev_io->u.bdev.iovs[0].iov_len = len;

	/* If we need to exec an accel sequence, append a copy operation making accel change the
	 * src/dst buffers of the previous operation */
	if (bdev_io_needs_sequence_exec(bdev_io->internal.desc, bdev_io)) {
@@ -1190,13 +1178,35 @@ _bdev_io_pull_bounce_data_buf(struct spdk_bdev_io *bdev_io, void *buf, size_t le
			SPDK_ERRLOG("Failed to pull data from memory domain %s\n",
				    spdk_memory_domain_get_dma_device_id(bdev_io->internal.memory_domain));
		} else {
			spdk_copy_iovs_to_buf(buf, len, bdev_io->internal.orig_iovs, bdev_io->internal.orig_iovcnt);
			assert(bdev_io->u.bdev.iovcnt == 1);
			spdk_copy_iovs_to_buf(bdev_io->u.bdev.iovs[0].iov_base,
					      bdev_io->u.bdev.iovs[0].iov_len,
					      bdev_io->internal.orig_iovs,
					      bdev_io->internal.orig_iovcnt);
		}
	}

	_bdev_io_pull_bounce_data_buf_done(bdev_io, rc);
}

static void
_bdev_io_pull_bounce_data_buf(struct spdk_bdev_io *bdev_io, void *buf, size_t len,
			      bdev_copy_bounce_buffer_cpl cpl_cb)
{
	bdev_io->internal.data_transfer_cpl = cpl_cb;
	/* save original iovec */
	bdev_io->internal.orig_iovs = bdev_io->u.bdev.iovs;
	bdev_io->internal.orig_iovcnt = bdev_io->u.bdev.iovcnt;
	/* set bounce iov */
	bdev_io->u.bdev.iovs = &bdev_io->internal.bounce_iov;
	bdev_io->u.bdev.iovcnt = 1;
	/* set bounce buffer for this operation */
	bdev_io->u.bdev.iovs[0].iov_base = buf;
	bdev_io->u.bdev.iovs[0].iov_len = len;

	bdev_io_pull_data(bdev_io);
}

static void
_bdev_io_set_buf(struct spdk_bdev_io *bdev_io, void *buf, uint64_t len)
{