]> git.proxmox.com Git - mirror_spl-debian.git/blobdiff - module/splat/splat-rwlock.c
New upstream version 0.7.2
[mirror_spl-debian.git] / module / splat / splat-rwlock.c
index 4576f20c7d006a9aee0ae4ce1aa07b0d2e0b935e..5d3ffb195115a9aec4cf090fabd8123ffb663dda 100644 (file)
@@ -76,7 +76,7 @@ typedef struct rw_priv {
        struct file *rw_file;
        krwlock_t rw_rwlock;
        spinlock_t rw_lock;
-       wait_queue_head_t rw_waitq;
+       spl_wait_queue_head_t rw_waitq;
        int rw_completed;
        int rw_holders;
        int rw_waiters;
@@ -106,6 +106,17 @@ void splat_init_rw_priv(rw_priv_t *rwp, struct file *file)
        rwp->rw_type = 0;
 }
 
+#if defined(CONFIG_PREEMPT_RT_FULL)
+static int
+splat_rwlock_test1(struct file *file, void *arg)
+{
+       /*
+        * This test will never succeed on PREEMPT_RT_FULL because these
+        * kernels only allow a single thread to hold the lock.
+        */
+       return 0;
+}
+#else
 static int
 splat_rwlock_wr_thr(void *arg)
 {
@@ -297,6 +308,7 @@ splat_rwlock_test1(struct file *file, void *arg)
 
        return rc;
 }
+#endif
 
 static void
 splat_rwlock_test2_func(void *arg)
@@ -348,7 +360,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 +482,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;
@@ -513,11 +526,22 @@ splat_rwlock_test4(struct file *file, void *arg)
 
        splat_init_rw_priv(rwp, file);
 
-       /* Validate all combinations of rw_tryenter() contention */
+       /*
+        * Validate all combinations of rw_tryenter() contention.
+        *
+        * The concurrent reader test is modified for PREEMPT_RT_FULL
+        * kernels which do not permit concurrent read locks to be taken
+        * from different threads.  The same thread is allowed to take
+        * the read lock multiple times.
+        */
        rc1 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_WRITER, RW_WRITER);
        rc2 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_WRITER, RW_READER);
        rc3 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_READER, RW_WRITER);
+#if defined(CONFIG_PREEMPT_RT_FULL)
+       rc4 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_READER, RW_READER);
+#else
        rc4 = splat_rwlock_test4_type(tq, rwp, 0,      RW_READER, RW_READER);
+#endif
        rc5 = splat_rwlock_test4_type(tq, rwp, 0,      RW_NONE,   RW_WRITER);
        rc6 = splat_rwlock_test4_type(tq, rwp, 0,      RW_NONE,   RW_READER);
 
@@ -685,19 +709,19 @@ splat_rwlock_init(void)
        spin_lock_init(&sub->test_lock);
        sub->desc.id = SPLAT_SUBSYSTEM_RWLOCK;
 
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST1_NAME, SPLAT_RWLOCK_TEST1_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST1_NAME, SPLAT_RWLOCK_TEST1_DESC,
                      SPLAT_RWLOCK_TEST1_ID, splat_rwlock_test1);
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST2_NAME, SPLAT_RWLOCK_TEST2_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST2_NAME, SPLAT_RWLOCK_TEST2_DESC,
                      SPLAT_RWLOCK_TEST2_ID, splat_rwlock_test2);
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST3_NAME, SPLAT_RWLOCK_TEST3_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST3_NAME, SPLAT_RWLOCK_TEST3_DESC,
                      SPLAT_RWLOCK_TEST3_ID, splat_rwlock_test3);
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST4_NAME, SPLAT_RWLOCK_TEST4_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST4_NAME, SPLAT_RWLOCK_TEST4_DESC,
                      SPLAT_RWLOCK_TEST4_ID, splat_rwlock_test4);
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST5_NAME, SPLAT_RWLOCK_TEST5_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST5_NAME, SPLAT_RWLOCK_TEST5_DESC,
                      SPLAT_RWLOCK_TEST5_ID, splat_rwlock_test5);
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST6_NAME, SPLAT_RWLOCK_TEST6_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST6_NAME, SPLAT_RWLOCK_TEST6_DESC,
                      SPLAT_RWLOCK_TEST6_ID, splat_rwlock_test6);
-       SPLAT_TEST_INIT(sub, SPLAT_RWLOCK_TEST7_NAME, SPLAT_RWLOCK_TEST7_DESC,
+       splat_test_init(sub, SPLAT_RWLOCK_TEST7_NAME, SPLAT_RWLOCK_TEST7_DESC,
                      SPLAT_RWLOCK_TEST7_ID, splat_rwlock_test7);
 
        return sub;
@@ -707,13 +731,13 @@ void
 splat_rwlock_fini(splat_subsystem_t *sub)
 {
        ASSERT(sub);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST7_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST6_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST5_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST4_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST3_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST2_ID);
-       SPLAT_TEST_FINI(sub, SPLAT_RWLOCK_TEST1_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST7_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST6_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST5_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST4_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST3_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST2_ID);
+       splat_test_fini(sub, SPLAT_RWLOCK_TEST1_ID);
        kfree(sub);
 }