]> git.proxmox.com Git - mirror_spl.git/blobdiff - module/splat/splat-atomic.c
Make file headers conform to ZFS style standard
[mirror_spl.git] / module / splat / splat-atomic.c
index fd86a9fa86becf38d1dd111b92d9a8f9a486a4fe..8aaa0835d604417644ef9264312ae30f8064f715 100644 (file)
@@ -1,4 +1,4 @@
-/*****************************************************************************\
+/*
  *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -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
  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
  *****************************************************************************
  *  Solaris Porting LAyer Tests (SPLAT) Atomic Tests.
-\*****************************************************************************/
-
+ */
+
+#include <sys/atomic.h>
+#include <sys/thread.h>
+#include <sys/mutex.h>
+#include <linux/mm_compat.h>
+#include <linux/wait_compat.h>
+#include <linux/slab.h>
 #include "splat-internal.h"
 
 #define SPLAT_ATOMIC_NAME              "atomic"
@@ -49,8 +55,8 @@ typedef enum {
 typedef struct atomic_priv {
         unsigned long ap_magic;
         struct file *ap_file;
-       spinlock_t ap_lock;
-        wait_queue_head_t ap_waitq;
+       kmutex_t ap_lock;
+        spl_wait_queue_head_t ap_waitq;
        volatile uint64_t ap_atomic;
        volatile uint64_t ap_atomic_exited;
        atomic_op_t ap_op;
@@ -67,10 +73,10 @@ splat_atomic_work(void *priv)
        ap = (atomic_priv_t *)priv;
        ASSERT(ap->ap_magic == SPLAT_ATOMIC_TEST_MAGIC);
 
-       spin_lock(&ap->ap_lock);
+       mutex_enter(&ap->ap_lock);
        op = ap->ap_op;
        wake_up(&ap->ap_waitq);
-       spin_unlock(&ap->ap_lock);
+       mutex_exit(&ap->ap_lock);
 
         splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME,
                     "Thread %d successfully started: %lu/%lu\n", op,
@@ -109,7 +115,7 @@ splat_atomic_work(void *priv)
                                atomic_sub_64_nv(&ap->ap_atomic, 5);
                                break;
                        default:
-                               SBUG();
+                               PANIC("Undefined op %d\n", op);
                }
        }
 
@@ -140,28 +146,28 @@ splat_atomic_test1(struct file *file, void *arg)
 
        ap.ap_magic = SPLAT_ATOMIC_TEST_MAGIC;
        ap.ap_file = file;
-       spin_lock_init(&ap.ap_lock);
+       mutex_init(&ap.ap_lock, SPLAT_ATOMIC_TEST1_NAME, MUTEX_DEFAULT, NULL);
        init_waitqueue_head(&ap.ap_waitq);
        ap.ap_atomic = SPLAT_ATOMIC_INIT_VALUE;
        ap.ap_atomic_exited = 0;
 
        for (i = 0; i < SPLAT_ATOMIC_COUNT_64; i++) {
-               spin_lock(&ap.ap_lock);
+               mutex_enter(&ap.ap_lock);
                ap.ap_op = i;
 
                thr = (kthread_t *)thread_create(NULL, 0, splat_atomic_work,
                                                 &ap, 0, &p0, TS_RUN,
-                                                minclsyspri);
+                                                defclsyspri);
                if (thr == NULL) {
                        rc = -ESRCH;
-                       spin_unlock(&ap.ap_lock);
+                       mutex_exit(&ap.ap_lock);
                        break;
                }
 
                /* Prepare to wait, the new thread will wake us once it
                 * has made a copy of the unique private passed data */
                 prepare_to_wait(&ap.ap_waitq, &wait, TASK_UNINTERRUPTIBLE);
-               spin_unlock(&ap.ap_lock);
+               mutex_exit(&ap.ap_lock);
                schedule();
        }
 
@@ -184,6 +190,8 @@ splat_atomic_test1(struct file *file, void *arg)
                   "Success initial and final values match, %lu == %lu\n",
                   (long unsigned)ap.ap_atomic, SPLAT_ATOMIC_INIT_VALUE);
 
+       mutex_destroy(&ap.ap_lock);
+
        return 0;
 }
 
@@ -204,7 +212,7 @@ splat_atomic_init(void)
         spin_lock_init(&sub->test_lock);
         sub->desc.id = SPLAT_SUBSYSTEM_ATOMIC;
 
-        SPLAT_TEST_INIT(sub, SPLAT_ATOMIC_TEST1_NAME, SPLAT_ATOMIC_TEST1_DESC,
+        splat_test_init(sub, SPLAT_ATOMIC_TEST1_NAME, SPLAT_ATOMIC_TEST1_DESC,
                       SPLAT_ATOMIC_TEST1_ID, splat_atomic_test1);
 
         return sub;
@@ -214,7 +222,7 @@ void
 splat_atomic_fini(splat_subsystem_t *sub)
 {
         ASSERT(sub);
-        SPLAT_TEST_FINI(sub, SPLAT_ATOMIC_TEST1_ID);
+        splat_test_fini(sub, SPLAT_ATOMIC_TEST1_ID);
 
         kfree(sub);
 }