diff options
author | Brian Behlendorf <[email protected]> | 2016-07-26 23:37:46 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-07-29 14:17:53 -0700 |
commit | b7c7008ba28ca926fbda929aec52f3761d72cffe (patch) | |
tree | 21c4186bf940b6ed92a72960559bac0e4be31f90 /module/spl/spl-rwlock.c | |
parent | d2f97b2a2651d8e1a6e9e1dcb07cfe8570efcfff (diff) |
Linux 4.8 compat: rw_semaphore atomic_long_t count
For non-rwsem-spinlocks the "count" member was changed from a
"long" to "atomic_long_t" type. A configure check has been
added to detect this change along with new versions of the
_rwsem_tryupgrade() function and RWSEM_COUNT() macro. See
https://github.com/torvalds/linux/commit/8ee62b18 for complete
details.
Signed-off-by: Tim Chase <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #563
Diffstat (limited to 'module/spl/spl-rwlock.c')
-rw-r--r-- | module/spl/spl-rwlock.c | 11 |
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) |