From a32e9c354f4edbce1e6050103462565ecd4b3c92 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Tue, 19 Jun 2018 16:57:20 -0700 Subject: [PATCH] bdev: encapsulate spdk_bdev_io callback function This should be set from bdev.c and does not need to be accessed further from bdev modules. Change-Id: I2174ed2378d986cec291e7f29e64fe13a5f7df6d Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/416060 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System --- include/spdk/bdev_module.h | 12 ++++++------ lib/bdev/bdev.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index c5d194d5f..6abe97859 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -305,12 +305,6 @@ struct spdk_bdev_io { /** The bdev I/O channel that this was submitted on. */ struct spdk_bdev_channel *io_submit_ch; - /** User function that will be called when this completes */ - spdk_bdev_io_completion_cb cb; - - /** Context that will be passed to the completion callback */ - void *caller_ctx; - /** Error information from a device */ union { /** Only valid when status is SPDK_BDEV_IO_STATUS_NVME_ERROR */ @@ -394,6 +388,12 @@ struct spdk_bdev_io { * must not read or write to these fields. */ struct __bdev_io_internal_fields { + /** User function that will be called when this completes */ + spdk_bdev_io_completion_cb cb; + + /** Context that will be passed to the completion callback */ + void *caller_ctx; + /** Current tsc at submit time. Used to calculate latency at completion. */ uint64_t submit_tsc; diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index d71ef584f..1c9de4741 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -1093,8 +1093,8 @@ spdk_bdev_io_init(struct spdk_bdev_io *bdev_io, spdk_bdev_io_completion_cb cb) { bdev_io->bdev = bdev; - bdev_io->caller_ctx = cb_arg; - bdev_io->cb = cb; + bdev_io->internal.caller_ctx = cb_arg; + bdev_io->internal.cb = cb; bdev_io->internal.status = SPDK_BDEV_IO_STATUS_PENDING; bdev_io->internal.in_submit_request = false; bdev_io->internal.buf = NULL; @@ -2396,11 +2396,11 @@ _spdk_bdev_io_complete(void *ctx) } #endif - assert(bdev_io->cb != NULL); + assert(bdev_io->internal.cb != NULL); assert(spdk_get_thread() == spdk_io_channel_get_thread(bdev_io->ch->channel)); - bdev_io->cb(bdev_io, bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS, - bdev_io->caller_ctx); + bdev_io->internal.cb(bdev_io, bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS, + bdev_io->internal.caller_ctx); } static void @@ -3122,7 +3122,7 @@ spdk_bdev_write_zeroes_split(struct spdk_bdev_io *bdev_io, bool success, void *c uint64_t len; if (!success) { - bdev_io->cb = bdev_io->u.bdev.stored_user_cb; + bdev_io->internal.cb = bdev_io->u.bdev.stored_user_cb; _spdk_bdev_io_complete(bdev_io); return; }