bdevperf: Factor out creating tasks on group into a helper function
This is a preparation to make bdevperf_construct_targets_tasks() asynchronous by using spdk_for_each_channel() in the next patch. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I76c827550b2920abcba14abd7f15a3111ad10d39 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/643 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
52d8f11ea8
commit
19367440b6
@ -939,13 +939,35 @@ static struct bdevperf_task *bdevperf_construct_task_on_target(struct io_target
|
||||
return task;
|
||||
}
|
||||
|
||||
static int
|
||||
bdevperf_construct_tasks_on_group(struct io_target_group *group)
|
||||
{
|
||||
struct io_target *target;
|
||||
struct bdevperf_task *task;
|
||||
int i, task_num = g_queue_depth;
|
||||
|
||||
if (g_reset) {
|
||||
task_num += 1;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(target, &group->targets, link) {
|
||||
for (i = 0; i < task_num; i++) {
|
||||
task = bdevperf_construct_task_on_target(target);
|
||||
if (task == NULL) {
|
||||
return -1;
|
||||
}
|
||||
TAILQ_INSERT_TAIL(&target->task_list, task, link);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
bdevperf_construct_targets_tasks(void)
|
||||
{
|
||||
struct io_target_group *group;
|
||||
struct io_target *target;
|
||||
struct bdevperf_task *task;
|
||||
int i, task_num = g_queue_depth;
|
||||
int rc;
|
||||
|
||||
if (g_target_count == 0) {
|
||||
fprintf(stderr, "No valid bdevs found.\n");
|
||||
@ -954,25 +976,16 @@ bdevperf_construct_targets_tasks(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_reset) {
|
||||
task_num += 1;
|
||||
}
|
||||
|
||||
/* Initialize task list for each target */
|
||||
TAILQ_FOREACH(group, &g_bdevperf.groups, link) {
|
||||
TAILQ_FOREACH(target, &group->targets, link) {
|
||||
for (i = 0; i < task_num; i++) {
|
||||
task = bdevperf_construct_task_on_target(target);
|
||||
if (task == NULL) {
|
||||
rc = bdevperf_construct_tasks_on_group(group);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "Bdevperf program exits due to memory allocation issue\n");
|
||||
fprintf(stderr, "Use -d XXX to allocate more huge pages, e.g., -d 4096\n");
|
||||
g_run_rc = -1;
|
||||
g_run_rc = rc;
|
||||
bdevperf_test_done();
|
||||
return;
|
||||
}
|
||||
TAILQ_INSERT_TAIL(&target->task_list, task, link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bdevperf_test();
|
||||
|
Loading…
Reference in New Issue
Block a user