Commit a32e9c35 authored by Seth Howell's avatar Seth Howell Committed by Jim Harris
Browse files

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: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/416060


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 6e456969
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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;

+6 −6
Original line number Diff line number Diff line
@@ -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;
	}