* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
- * For details, see <http://github.com/behlendorf/spl/>.
+ * For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
#include <sys/mutex.h>
#include <sys/taskq.h>
+#include <linux/delay.h>
+#include <linux/mm_compat.h>
#include "splat-internal.h"
#define SPLAT_MUTEX_NAME "mutex"
{
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)
return -ENOMEM;
- tq = taskq_create(SPLAT_MUTEX_TEST_TASKQ, 1, maxclsyspri,
+ tq = taskq_create(SPLAT_MUTEX_TEST_TASKQ, 1, defclsyspri,
50, INT_MAX, TASKQ_PREPOPULATE);
if (tq == NULL) {
rc = -ENOMEM;
* 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");
/* 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 {
* 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;
/* 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",
{
mutex_priv_t *mp;
taskq_t *tq;
+ taskqid_t id;
int i, rc = 0;
mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL);
/* Create several threads allowing tasks to race with each other */
tq = taskq_create(SPLAT_MUTEX_TEST_TASKQ, num_online_cpus(),
- maxclsyspri, 50, INT_MAX, TASKQ_PREPOPULATE);
+ defclsyspri, 50, INT_MAX, TASKQ_PREPOPULATE);
if (tq == NULL) {
rc = -ENOMEM;
goto out;
* 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;
{
mutex_priv_t mp;
taskq_t *tq;
+ taskqid_t id;
int rc = 0;
mp.mp_magic = SPLAT_MUTEX_TEST_MAGIC;
mp.mp_file = file;
mutex_init(&mp.mp_mtx, SPLAT_MUTEX_TEST_NAME, MUTEX_DEFAULT, NULL);
- if ((tq = taskq_create(SPLAT_MUTEX_TEST_NAME, 1, maxclsyspri,
+ if ((tq = taskq_create(SPLAT_MUTEX_TEST_NAME, 1, defclsyspri,
50, INT_MAX, TASKQ_PREPOPULATE)) == NULL) {
splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Taskq '%s' "
"create failed\n", SPLAT_MUTEX_TEST3_NAME);
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));
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));