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 <james.r.harris@intel.com>
Change-Id: I0265651cb1fad372bf3e801c262dc159058a2a1d

Reviewed-on: https://review.gerrithub.io/415300
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2018-06-14 01:59:35 -07:00 committed by Daniel Verkamp
parent 67bc354c37
commit 89de425ed4

View File

@ -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: