aboutsummaryrefslogtreecommitdiffstats
path: root/module/spl/spl-rwlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/spl/spl-rwlock.c')
-rw-r--r--module/spl/spl-rwlock.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/module/spl/spl-rwlock.c b/module/spl/spl-rwlock.c
index 9b356a843..77f46f2d6 100644
--- a/module/spl/spl-rwlock.c
+++ b/module/spl/spl-rwlock.c
@@ -32,7 +32,7 @@
#define DEBUG_SUBSYSTEM S_RWLOCK
-#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
+#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
static int
__rwsem_tryupgrade(struct rw_semaphore *rwsem)
{
@@ -47,6 +47,15 @@ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
spl_rwsem_unlock_irqrestore(&rwsem->wait_lock, flags);
return (ret);
}
+#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
+static int
+__rwsem_tryupgrade(struct rw_semaphore *rwsem)
+{
+ long val;
+ val = atomic_long_cmpxchg(&rwsem->count, SPL_RWSEM_SINGLE_READER_VALUE,
+ SPL_RWSEM_SINGLE_WRITER_VALUE);
+ return (val == SPL_RWSEM_SINGLE_READER_VALUE);
+}
#else
static int
__rwsem_tryupgrade(struct rw_semaphore *rwsem)