]> git.proxmox.com Git - mirror_spl.git/blobdiff - module/splat/splat-mutex.c
Add TASKQID_INVALID and TASKQID_INITIAL macros
[mirror_spl.git] / module / splat / splat-mutex.c
index 9e6b24708e15b00711624d9b93e7acedff1df386..d39551354a79332c12d1d69517069922e5f6e31d 100644 (file)
@@ -6,7 +6,7 @@
  *  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
@@ -26,6 +26,8 @@
 
 #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"
@@ -79,13 +81,14 @@ 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)
                 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;
@@ -103,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");
@@ -118,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 {
@@ -134,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;
@@ -147,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",
@@ -186,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);
@@ -194,7 +198,7 @@ splat_mutex_test2(struct file *file, void *arg)
 
         /* 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;
@@ -216,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;
@@ -258,13 +263,14 @@ 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;
         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);
@@ -281,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));
@@ -308,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));