diff options
-rw-r--r-- | module/splat/splat-taskq.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/module/splat/splat-taskq.c b/module/splat/splat-taskq.c index 8229fed39..2787bf401 100644 --- a/module/splat/splat-taskq.c +++ b/module/splat/splat-taskq.c @@ -231,7 +231,7 @@ static int splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { taskq_t *tq[TEST2_TASKQS] = { NULL }; taskqid_t id; - splat_taskq_arg_t tq_args[TEST2_TASKQS]; + splat_taskq_arg_t *tq_args[TEST2_TASKQS] = { NULL }; taskq_ent_t *func1_tqes = NULL; taskq_ent_t *func2_tqes = NULL; int i, rc = 0; @@ -252,6 +252,12 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { taskq_init_ent(&func1_tqes[i]); taskq_init_ent(&func2_tqes[i]); + tq_args[i] = kmalloc(sizeof (splat_taskq_arg_t), GFP_KERNEL); + if (tq_args[i] == NULL) { + rc = -ENOMEM; + break; + } + splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' creating (%s dispatch)\n", SPLAT_TASKQ_TEST2_NAME, i, @@ -267,28 +273,28 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { break; } - tq_args[i].flag = i; - tq_args[i].id = i; - tq_args[i].file = file; - tq_args[i].name = SPLAT_TASKQ_TEST2_NAME; + tq_args[i]->flag = i; + tq_args[i]->id = i; + tq_args[i]->file = file; + tq_args[i]->name = SPLAT_TASKQ_TEST2_NAME; splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' function '%s' dispatching\n", - tq_args[i].name, tq_args[i].id, + tq_args[i]->name, tq_args[i]->id, sym2str(splat_taskq_test2_func1)); if (prealloc) { taskq_dispatch_ent(tq[i], splat_taskq_test2_func1, - &tq_args[i], TQ_SLEEP, &func1_tqes[i]); + tq_args[i], TQ_SLEEP, &func1_tqes[i]); id = func1_tqes[i].tqent_id; } else { id = taskq_dispatch(tq[i], splat_taskq_test2_func1, - &tq_args[i], TQ_SLEEP); + tq_args[i], TQ_SLEEP); } if (id == 0) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' function '%s' dispatch " - "failed\n", tq_args[i].name, tq_args[i].id, + "failed\n", tq_args[i]->name, tq_args[i]->id, sym2str(splat_taskq_test2_func1)); rc = -EINVAL; break; @@ -296,21 +302,21 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' function '%s' dispatching\n", - tq_args[i].name, tq_args[i].id, + tq_args[i]->name, tq_args[i]->id, sym2str(splat_taskq_test2_func2)); if (prealloc) { taskq_dispatch_ent(tq[i], splat_taskq_test2_func2, - &tq_args[i], TQ_SLEEP, &func2_tqes[i]); + tq_args[i], TQ_SLEEP, &func2_tqes[i]); id = func2_tqes[i].tqent_id; } else { id = taskq_dispatch(tq[i], splat_taskq_test2_func2, - &tq_args[i], TQ_SLEEP); + tq_args[i], TQ_SLEEP); } if (id == 0) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq " "'%s/%d' function '%s' dispatch failed\n", - tq_args[i].name, tq_args[i].id, + tq_args[i]->name, tq_args[i]->id, sym2str(splat_taskq_test2_func2)); rc = -EINVAL; break; @@ -320,31 +326,36 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { /* When rc is set we're effectively just doing cleanup here, so * ignore new errors in that case. They just cause noise. */ for (i = 0; i < TEST2_TASKQS; i++) { + if (tq_args[i] == NULL) + continue; + if (tq[i] != NULL) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' waiting\n", - tq_args[i].name, tq_args[i].id); + tq_args[i]->name, tq_args[i]->id); taskq_wait(tq[i]); splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d; destroying\n", - tq_args[i].name, tq_args[i].id); + tq_args[i]->name, tq_args[i]->id); taskq_destroy(tq[i]); - if (!rc && tq_args[i].flag != ((i * 2) + 1)) { + if (!rc && tq_args[i]->flag != ((i * 2) + 1)) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' processed tasks " "out of order; %d != %d\n", - tq_args[i].name, tq_args[i].id, - tq_args[i].flag, i * 2 + 1); + tq_args[i]->name, tq_args[i]->id, + tq_args[i]->flag, i * 2 + 1); rc = -EINVAL; } else { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' processed tasks " "in the correct order; %d == %d\n", - tq_args[i].name, tq_args[i].id, - tq_args[i].flag, i * 2 + 1); + tq_args[i]->name, tq_args[i]->id, + tq_args[i]->flag, i * 2 + 1); } + + kfree(tq_args[i]); } } out: |