mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Add TASKQID_INVALID and TASKQID_INITIAL macros
Add the TASKQID_INVALID and TASKQID_INITIAL macros and update the taskq implementation and test cases to use them. This is solely for the purposes of readability and introduces no functional change. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
+18
-12
@@ -81,7 +81,8 @@ splat_mutex_test1(struct file *file, void *arg)
|
||||
{
|
||||
mutex_priv_t *mp;
|
||||
taskq_t *tq;
|
||||
int id, rc = 0;
|
||||
taskqid_t id;
|
||||
int rc = 0;
|
||||
|
||||
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
|
||||
if (mp == NULL)
|
||||
@@ -105,8 +106,8 @@ splat_mutex_test1(struct file *file, void *arg)
|
||||
* function will indicate this status in the passed private data.
|
||||
*/
|
||||
mp->mp_rc = -EINVAL;
|
||||
id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP);
|
||||
if (id == 0) {
|
||||
id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP);
|
||||
if (id == TASKQID_INVALID) {
|
||||
mutex_exit(&mp->mp_mtx);
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s",
|
||||
"taskq_dispatch() failed\n");
|
||||
@@ -120,8 +121,8 @@ splat_mutex_test1(struct file *file, void *arg)
|
||||
/* Task function successfully acquired mutex, very bad! */
|
||||
if (mp->mp_rc != -EBUSY) {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST1_NAME,
|
||||
"mutex_trylock() incorrectly succeeded when "
|
||||
"the mutex was held, %d/%d\n", id, mp->mp_rc);
|
||||
"mutex_trylock() incorrectly succeeded when "
|
||||
"the mutex was held, %d/%d\n", (int)id, mp->mp_rc);
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
} else {
|
||||
@@ -136,8 +137,8 @@ splat_mutex_test1(struct file *file, void *arg)
|
||||
* can be verified by checking the private data.
|
||||
*/
|
||||
mp->mp_rc = -EINVAL;
|
||||
id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP);
|
||||
if (id == 0) {
|
||||
id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP);
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s",
|
||||
"taskq_dispatch() failed\n");
|
||||
rc = -EINVAL;
|
||||
@@ -149,8 +150,8 @@ splat_mutex_test1(struct file *file, void *arg)
|
||||
/* Task function failed to acquire mutex, very bad! */
|
||||
if (mp->mp_rc != 0) {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST1_NAME,
|
||||
"mutex_trylock() incorrectly failed when "
|
||||
"the mutex was not held, %d/%d\n", id, mp->mp_rc);
|
||||
"mutex_trylock() incorrectly failed when the mutex "
|
||||
"was not held, %d/%d\n", (int)id, mp->mp_rc);
|
||||
rc = -EINVAL;
|
||||
} else {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s",
|
||||
@@ -188,6 +189,7 @@ splat_mutex_test2(struct file *file, void *arg)
|
||||
{
|
||||
mutex_priv_t *mp;
|
||||
taskq_t *tq;
|
||||
taskqid_t id;
|
||||
int i, rc = 0;
|
||||
|
||||
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
|
||||
@@ -218,7 +220,8 @@ splat_mutex_test2(struct file *file, void *arg)
|
||||
* mutex is implemented right this will never happy, that's a pass.
|
||||
*/
|
||||
for (i = 0; i < SPLAT_MUTEX_TEST_COUNT; i++) {
|
||||
if (!taskq_dispatch(tq, splat_mutex_test2_func, mp, TQ_SLEEP)) {
|
||||
id = taskq_dispatch(tq, splat_mutex_test2_func, mp, TQ_SLEEP);
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST2_NAME,
|
||||
"Failed to queue task %d\n", i);
|
||||
rc = -EINVAL;
|
||||
@@ -260,6 +263,7 @@ splat_mutex_test3(struct file *file, void *arg)
|
||||
{
|
||||
mutex_priv_t mp;
|
||||
taskq_t *tq;
|
||||
taskqid_t id;
|
||||
int rc = 0;
|
||||
|
||||
mp.mp_magic = SPLAT_MUTEX_TEST_MAGIC;
|
||||
@@ -283,7 +287,8 @@ splat_mutex_test3(struct file *file, void *arg)
|
||||
goto out_exit;
|
||||
}
|
||||
|
||||
if (taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP) == 0) {
|
||||
id = taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP);
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Failed to "
|
||||
"dispatch function '%s' to taskq\n",
|
||||
sym2str(splat_mutex_owned));
|
||||
@@ -310,7 +315,8 @@ splat_mutex_test3(struct file *file, void *arg)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP) == 0) {
|
||||
id = taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP);
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Failed to "
|
||||
"dispatch function '%s' to taskq\n",
|
||||
sym2str(splat_mutex_owned));
|
||||
|
||||
@@ -348,7 +348,8 @@ splat_rwlock_test2(struct file *file, void *arg)
|
||||
* rwlock is implemented right this will never happy, that's a pass.
|
||||
*/
|
||||
for (i = 0; i < tq_count; i++) {
|
||||
if (!taskq_dispatch(tq,splat_rwlock_test2_func,rwp,TQ_SLEEP)) {
|
||||
if (taskq_dispatch(tq, splat_rwlock_test2_func, rwp,
|
||||
TQ_SLEEP) == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_RWLOCK_TEST2_NAME,
|
||||
"Failed to queue task %d\n", i);
|
||||
rc = -EINVAL;
|
||||
@@ -469,7 +470,7 @@ splat_rwlock_test4_type(taskq_t *tq, rw_priv_t *rwp, int expected_rc,
|
||||
rw_enter(&rwp->rw_rwlock, holder_type);
|
||||
|
||||
id = taskq_dispatch(tq, splat_rwlock_test4_func, rwp, TQ_SLEEP);
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(rwp->rw_file, SPLAT_RWLOCK_TEST4_NAME, "%s",
|
||||
"taskq_dispatch() failed\n");
|
||||
rc = -EINVAL;
|
||||
|
||||
+13
-13
@@ -160,7 +160,7 @@ splat_taskq_test1_impl(struct file *file, void *arg, boolean_t prealloc)
|
||||
&tq_arg, TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST1_NAME,
|
||||
"Taskq '%s' function '%s' dispatch failed\n",
|
||||
tq_arg.name, sym2str(splat_taskq_test13_func));
|
||||
@@ -296,7 +296,7 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) {
|
||||
tq_args[i], TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
|
||||
"Taskq '%s/%d' function '%s' dispatch "
|
||||
"failed\n", tq_args[i]->name, tq_args[i]->id,
|
||||
@@ -318,7 +318,7 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) {
|
||||
tq_args[i], TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq "
|
||||
"'%s/%d' function '%s' dispatch failed\n",
|
||||
tq_args[i]->name, tq_args[i]->id,
|
||||
@@ -420,7 +420,7 @@ splat_taskq_test3_impl(struct file *file, void *arg, boolean_t prealloc)
|
||||
tq_arg, TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST3_NAME,
|
||||
"Taskq '%s' function '%s' dispatch failed\n",
|
||||
tq_arg->name, sym2str(splat_taskq_test13_func));
|
||||
@@ -525,7 +525,7 @@ splat_taskq_test4_common(struct file *file, void *arg, int minalloc,
|
||||
&tq_arg, TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST4_NAME,
|
||||
"Taskq '%s' function '%s' dispatch "
|
||||
"%d failed\n", tq_arg.name,
|
||||
@@ -741,7 +741,7 @@ splat_taskq_test5_impl(struct file *file, void *arg, boolean_t prealloc)
|
||||
&tq_id[i], TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST5_NAME,
|
||||
"Taskq '%s' function '%s' dispatch failed\n",
|
||||
tq_arg.name, sym2str(splat_taskq_test5_func));
|
||||
@@ -905,7 +905,7 @@ splat_taskq_test6_impl(struct file *file, void *arg, boolean_t prealloc)
|
||||
&tq_id[i], tflags);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST6_NAME,
|
||||
"Taskq '%s' function '%s' dispatch failed\n",
|
||||
tq_arg.name, sym2str(splat_taskq_test6_func));
|
||||
@@ -983,7 +983,7 @@ splat_taskq_test7_func(void *arg)
|
||||
tq_arg, TQ_SLEEP);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST7_NAME,
|
||||
"Taskq '%s' function '%s' dispatch failed "
|
||||
"(depth = %u)\n", tq_arg->name,
|
||||
@@ -1121,7 +1121,7 @@ splat_taskq_throughput(struct file *file, void *arg, const char *name,
|
||||
&tq_arg, TQ_SLEEP, tqes[i]);
|
||||
id = tqes[i]->tqent_id;
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, name, "Taskq '%s' function '%s' "
|
||||
"dispatch %d failed\n", tq_arg.name,
|
||||
sym2str(splat_taskq_throughput_func), i);
|
||||
@@ -1235,7 +1235,7 @@ splat_taskq_test9(struct file *file, void *arg)
|
||||
id = taskq_dispatch_delay(tq, splat_taskq_test9_func,
|
||||
tq_arg, TQ_SLEEP, ddi_get_lbolt() + rnd);
|
||||
|
||||
if (id == 0) {
|
||||
if (id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST9_NAME,
|
||||
"Taskq '%s' delay dispatch failed\n",
|
||||
SPLAT_TASKQ_TEST9_NAME);
|
||||
@@ -1344,7 +1344,7 @@ splat_taskq_test10(struct file *file, void *arg)
|
||||
tq_arg, TQ_SLEEP, ddi_get_lbolt() + rnd);
|
||||
}
|
||||
|
||||
if (tq_arg->id == 0) {
|
||||
if (tq_arg->id == TASKQID_INVALID) {
|
||||
splat_vprint(file, SPLAT_TASKQ_TEST10_NAME,
|
||||
"Taskq '%s' dispatch failed\n",
|
||||
SPLAT_TASKQ_TEST10_NAME);
|
||||
@@ -1473,8 +1473,8 @@ splat_taskq_test11(struct file *file, void *arg)
|
||||
dynamic.tv_sec, dynamic.tv_nsec);
|
||||
|
||||
/* A 10x increase in runtime is used to indicate a core problem. */
|
||||
if ((dynamic.tv_sec * NANOSEC + dynamic.tv_nsec) >
|
||||
((normal.tv_sec * NANOSEC + normal.tv_nsec) * 10))
|
||||
if (((int64_t)dynamic.tv_sec * NANOSEC + (int64_t)dynamic.tv_nsec) >
|
||||
(((int64_t)normal.tv_sec * NANOSEC + (int64_t)normal.tv_nsec) * 10))
|
||||
error = -ETIME;
|
||||
|
||||
return (error);
|
||||
|
||||
Reference in New Issue
Block a user