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 <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/416060 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
6e456969ab
commit
a32e9c354f
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user