Commit 0d7d3a05 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

bdev: consolidate I/O completion message passing



Simplify the handling of I/O completions that need to be sent as a
message so that they are handled in a single place in
_spdk_bdev_io_complete().

Change-Id: Ic94354ad947d0f1f11241f728aa194a105ff96c4
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/404184


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent b20b983b
Loading
Loading
Loading
Loading
+23 −27
Original line number Diff line number Diff line
@@ -2061,31 +2061,36 @@ _spdk_bdev_ch_retry_io(struct spdk_bdev_channel *bdev_ch)
	}
}

static void
_spdk_bdev_qos_io_complete(void *ctx)
{
	struct spdk_bdev_io *bdev_io = ctx;

	bdev_io->cb(bdev_io, bdev_io->status == SPDK_BDEV_IO_STATUS_SUCCESS, bdev_io->caller_ctx);
}

static void
static inline void
_spdk_bdev_io_complete(void *ctx)
{
	struct spdk_bdev_io *bdev_io = ctx;

	assert(bdev_io->cb != NULL);

	if (spdk_unlikely(bdev_io->in_submit_request || bdev_io->io_submit_ch)) {
		/*
		 * Send the completion to the thread that originally submitted the I/O,
		 * which may not be the current thread in the case of QoS.
		 */
		if (bdev_io->io_submit_ch) {
			bdev_io->ch = bdev_io->io_submit_ch;
			bdev_io->io_submit_ch = NULL;
		}

		/*
		 * Defer completion to avoid potential infinite recursion if the
		 * user's completion callback issues a new I/O.
		 */
		spdk_thread_send_msg(spdk_io_channel_get_thread(bdev_io->ch->channel),
				     _spdk_bdev_qos_io_complete, bdev_io);
	} else {
				     _spdk_bdev_io_complete, bdev_io);
		return;
	}

	assert(bdev_io->cb != NULL);
	assert(spdk_get_thread() == spdk_io_channel_get_thread(bdev_io->ch->channel));

	bdev_io->cb(bdev_io, bdev_io->status == SPDK_BDEV_IO_STATUS_SUCCESS,
		    bdev_io->caller_ctx);
}
}

static void
_spdk_bdev_reset_complete(struct spdk_io_channel_iter *i, int status)
@@ -2200,17 +2205,8 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta
	}
#endif

	if (bdev_io->in_submit_request) {
		/*
		 * Defer completion to avoid potential infinite recursion if the
		 * user's completion callback issues a new I/O.
		 */
		spdk_thread_send_msg(spdk_io_channel_get_thread(bdev_ch->channel),
				     _spdk_bdev_io_complete, bdev_io);
	} else {
	_spdk_bdev_io_complete(bdev_io);
}
}

void
spdk_bdev_io_complete_scsi_status(struct spdk_bdev_io *bdev_io, enum spdk_scsi_status sc,