Commit 0ee9e404 authored by Jim Harris's avatar Jim Harris Committed by Ben Walker
Browse files

bdev: keep a count of each channel's outstanding IO



There are several possible usages of this information -
the first will be related to starting a poller for a bdev
channel when there are I/O that need to be retried.
Usually we can retry an I/O when a previous I/O completes,
but if there are no outstanding I/O, we need to start a
poller.  This count will help us make that decision.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ifff7d99970510785a1cf30d20b86b3974ce8a106
Reviewed-on: https://review.gerrithub.io/362235


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 7a7593c0
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -99,6 +99,12 @@ struct spdk_bdev_channel {

	struct spdk_bdev_io_stat stat;

	/*
	 * Count of I/O submitted to bdev module and waiting for completion.
	 * Incremented before submit_request() is called on an spdk_bdev_io.
	 */
	uint64_t		io_outstanding;

#ifdef SPDK_CONFIG_VTUNE
	uint64_t		start_tsc;
	uint64_t		interval_tsc;
@@ -483,6 +489,7 @@ __submit_request(struct spdk_bdev *bdev, struct spdk_bdev_io *bdev_io)

	ch = bdev_io->ch->channel;

	bdev_io->ch->io_outstanding++;
	bdev_io->in_submit_request = true;
	bdev->fn_table->submit_request(ch, bdev_io);
	bdev_io->in_submit_request = false;
@@ -509,6 +516,12 @@ spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev *new_bdev)
	 */
	bdev_io->gencnt = new_bdev->gencnt;

	/*
	 * This bdev_io was already submitted so decrement io_outstanding to ensure it
	 *  does not get double-counted.
	 */
	assert(bdev_io->ch->io_outstanding > 0);
	bdev_io->ch->io_outstanding--;
	__submit_request(new_bdev, bdev_io);
}

@@ -583,6 +596,7 @@ spdk_bdev_channel_create(void *io_device, void *ctx_buf)
	ch->channel = bdev->fn_table->get_io_channel(bdev->ctxt);
	ch->mgmt_channel = spdk_get_io_channel(&g_bdev_mgr);
	memset(&ch->stat, 0, sizeof(ch->stat));
	ch->io_outstanding = 0;

#ifdef SPDK_CONFIG_VTUNE
	{
@@ -626,6 +640,7 @@ spdk_bdev_channel_destroy(void *io_device, void *ctx_buf)
	_spdk_bdev_abort_io(&mgmt_channel->need_buf_small, ch);
	_spdk_bdev_abort_io(&mgmt_channel->need_buf_large, ch);

	assert(ch->io_outstanding == 0);
	spdk_put_io_channel(ch->channel);
	spdk_put_io_channel(ch->mgmt_channel);
}
@@ -1132,6 +1147,8 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta
		return;
	}

	assert(bdev_io->ch->io_outstanding > 0);
	bdev_io->ch->io_outstanding--;
	if (bdev_io->type == SPDK_BDEV_IO_TYPE_RESET) {
		/* Successful reset */
		if (status == SPDK_BDEV_IO_STATUS_SUCCESS) {