bdevperf: Factor out getting free task from io_target to a function

This patch and the next patch will simplify the nesting of task
submission.

Factor out the operation to get free task from io_target into a
helper function bdevperf_target_get_task(). Use
bdevperf_target_get_task() in bdevperf_submit_single() and
reset_target().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I4cb147a5a6c84cc2b0e517dc35a106d37affaa10
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478689
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Seth Howell <seth.howell@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-12-22 18:03:27 -05:00 committed by Tomasz Zawadzki
parent b8d72590b3
commit 50b79fa639

View File

@ -774,6 +774,21 @@ bdevperf_prep_zcopy_write_task(void *arg)
target->current_queue_depth++;
}
static struct bdevperf_task *
bdevperf_target_get_task(struct io_target *target)
{
struct bdevperf_task *task;
task = TAILQ_FIRST(&target->task_list);
if (!task) {
printf("Task allocation failed\n");
abort();
}
TAILQ_REMOVE(&target->task_list, task, link);
return task;
}
static __thread unsigned int seed = 0;
static void
@ -832,13 +847,7 @@ static void
bdevperf_submit_single(struct io_target *target, struct bdevperf_task *task)
{
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();
}
task = bdevperf_target_get_task(target);
}
bdevperf_prep_task(task);
@ -892,19 +901,13 @@ static int
reset_target(void *arg)
{
struct io_target *target = arg;
struct bdevperf_task *task = NULL;
struct bdevperf_task *task;
int rc;
spdk_poller_unregister(&target->reset_timer);
/* Do reset. */
task = TAILQ_FIRST(&target->task_list);
if (!task) {
printf("Task allocation failed\n");
abort();
}
TAILQ_REMOVE(&target->task_list, task, link);
task = bdevperf_target_get_task(target);
rc = spdk_bdev_reset(target->bdev_desc, target->ch,
reset_cb, task);
if (rc) {