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