bdev: move parts of _bdev_io_unset_bounce_buf()

Move some of this code into separate functions.  There
is no change in functionality here - this just helps
reduce the size and complexity of an upcoming patch.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I72243f17312e66bb6ef2168b9b78076c9eb2e6f3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11531
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2022-02-10 08:02:36 +00:00
parent a91b4367ea
commit 5d68b11865

View File

@ -1052,29 +1052,9 @@ _bdev_io_handle_no_mem(struct spdk_bdev_io *bdev_io)
return false;
}
static void
_bdev_io_unset_bounce_buf(struct spdk_bdev_io *bdev_io)
static inline void
_bdev_io_push_bounce_md_buffer(struct spdk_bdev_io *bdev_io)
{
if (spdk_likely(bdev_io->internal.orig_iovcnt == 0)) {
assert(bdev_io->internal.orig_md_buf == NULL);
return;
}
/* if this is read path, copy data from bounce buffer to original buffer */
if (bdev_io->type == SPDK_BDEV_IO_TYPE_READ &&
bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS) {
_copy_buf_to_iovs(bdev_io->internal.orig_iovs,
bdev_io->internal.orig_iovcnt,
bdev_io->internal.bounce_iov.iov_base,
bdev_io->internal.bounce_iov.iov_len);
}
/* set original buffer for this io */
bdev_io->u.bdev.iovcnt = bdev_io->internal.orig_iovcnt;
bdev_io->u.bdev.iovs = bdev_io->internal.orig_iovs;
/* disable bouncing buffer for this io */
bdev_io->internal.orig_iovcnt = 0;
bdev_io->internal.orig_iovs = NULL;
/* do the same for metadata buffer */
if (spdk_unlikely(bdev_io->internal.orig_md_buf != NULL)) {
assert(spdk_bdev_is_md_separate(bdev_io->bdev));
@ -1095,6 +1075,41 @@ _bdev_io_unset_bounce_buf(struct spdk_bdev_io *bdev_io)
bdev_io_put_buf(bdev_io);
}
static void
_bdev_io_push_bounce_data_buffer_done(void *ctx)
{
struct spdk_bdev_io *bdev_io = ctx;
/* set original buffer for this io */
bdev_io->u.bdev.iovcnt = bdev_io->internal.orig_iovcnt;
bdev_io->u.bdev.iovs = bdev_io->internal.orig_iovs;
/* disable bouncing buffer for this io */
bdev_io->internal.orig_iovcnt = 0;
bdev_io->internal.orig_iovs = NULL;
_bdev_io_push_bounce_md_buffer(bdev_io);
}
static void
_bdev_io_unset_bounce_buf(struct spdk_bdev_io *bdev_io)
{
if (spdk_likely(bdev_io->internal.orig_iovcnt == 0)) {
assert(bdev_io->internal.orig_md_buf == NULL);
return;
}
/* if this is read path, copy data from bounce buffer to original buffer */
if (bdev_io->type == SPDK_BDEV_IO_TYPE_READ &&
bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS) {
_copy_buf_to_iovs(bdev_io->internal.orig_iovs,
bdev_io->internal.orig_iovcnt,
bdev_io->internal.bounce_iov.iov_base,
bdev_io->internal.bounce_iov.iov_len);
}
_bdev_io_push_bounce_data_buffer_done(bdev_io);
}
static void
bdev_io_get_buf(struct spdk_bdev_io *bdev_io, uint64_t len)
{