From 89de425ed49ecdefe58d9d94db924f79ccc70203 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 14 Jun 2018 01:59:35 -0700 Subject: [PATCH] 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: Jim Harris Change-Id: I0265651cb1fad372bf3e801c262dc159058a2a1d Reviewed-on: https://review.gerrithub.io/415300 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- test/bdev/bdevperf/bdevperf.c | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/test/bdev/bdevperf/bdevperf.c b/test/bdev/bdevperf/bdevperf.c index 9ea518f5e..00318cf02 100644 --- a/test/bdev/bdevperf/bdevperf.c +++ b/test/bdev/bdevperf/bdevperf.c @@ -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; - 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(); - } - } + struct io_target *target = task->target; + uint64_t offset_in_ios; 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: