Commit 89de425e authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

bdevperf: break out prep work from bdevperf_submit_single



This prepares for upcoming patches which handle -ENOMEM
from the SPDK bdev io submit function.  When we retry
submitting the I/O, we do not want to "re-prepare" the
I/O - i.e. we don't want to calculate a new offset or
memset the buffer again for verify workloads.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I0265651cb1fad372bf3e801c262dc159058a2a1d

Reviewed-on: https://review.gerrithub.io/415300


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 67bc354c
Loading
Loading
Loading
Loading
+28 −20
Original line number Diff line number Diff line
@@ -355,27 +355,10 @@ bdevperf_verify_write_complete(struct spdk_bdev_io *bdev_io, bool success,
static __thread unsigned int seed = 0;

static void
bdevperf_submit_single(struct io_target *target, struct bdevperf_task *task)
bdevperf_prep_task(struct bdevperf_task *task)
{
	spdk_bdev_io_completion_cb cb_fn;
	struct spdk_bdev_desc	*desc;
	struct spdk_io_channel	*ch;
	struct io_target *target = task->target;
	uint64_t offset_in_ios;
	void			*rbuf;
	int			rc;

	desc = target->bdev_desc;
	ch = target->ch;

	if (!task) {
		if (!TAILQ_EMPTY(&target->task_list)) {
			task = TAILQ_FIRST(&target->task_list);
			TAILQ_REMOVE(&target->task_list, task, link);
		} else {
			printf("Task allocation failed\n");
			abort();
		}
	}

	if (g_is_random) {
		offset_in_ios = rand_r(&seed) % target->size_in_ios;
@@ -404,6 +387,31 @@ bdevperf_submit_single(struct io_target *target, struct bdevperf_task *task)
		task->iov.iov_len = g_io_size;
		task->io_type = SPDK_BDEV_IO_TYPE_WRITE;
	}
}

static void
bdevperf_submit_single(struct io_target *target, struct bdevperf_task *task)
{
	spdk_bdev_io_completion_cb cb_fn;
	struct spdk_bdev_desc	*desc;
	struct spdk_io_channel	*ch;
	void			*rbuf;
	int			rc;

	desc = target->bdev_desc;
	ch = target->ch;

	if (!task) {
		if (!TAILQ_EMPTY(&target->task_list)) {
			task = TAILQ_FIRST(&target->task_list);
			TAILQ_REMOVE(&target->task_list, task, link);
		} else {
			printf("Task allocation failed\n");
			abort();
		}
	}

	bdevperf_prep_task(task);

	switch (task->io_type) {
	case SPDK_BDEV_IO_TYPE_WRITE: