diff options
author | Brian Behlendorf <behlendorf1@llnl.gov> | 2015-06-03 10:42:36 -0700 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2015-06-10 16:35:48 -0700 |
commit | 86c16c59fe0d78d44e9f3ebb10ee740bb1028045 (patch) | |
tree | 4641127d1ff933df2257f780382de666f7a0a04d | |
parent | a876b0305e94eea9505e7ecbae93cf7a1d24f743 (diff) |
Retire rwsem_is_locked() compat
Stock Linux 2.6.32 and earlier kernels contained a broken version of
rwsem_is_locked() which could return an incorrect value. Because of
this compatibility code was added to detect the broken implementation
and replace it with our own if needed.
The fix for this issue was merged in to the mainline Linux kernel as
of 2.6.33 and the major enterprise distributions based on 2.6.32 have
all backported the fix. Therefore there is no longer a need to carry
this code and it can be removed.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #454
-rw-r--r-- | config/spl-build.m4 | 22 | ||||
-rw-r--r-- | include/linux/rwsem_compat.h | 24 | ||||
-rw-r--r-- | include/sys/rwlock.h | 6 |
3 files changed, 2 insertions, 50 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4 index 3bfc1e232..9999d480d 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -33,7 +33,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_FS_STRUCT_SPINLOCK SPL_AC_KUIDGID_T SPL_AC_PUT_TASK_STRUCT - SPL_AC_EXPORTED_RWSEM_IS_LOCKED SPL_AC_KERNEL_FALLOCATE SPL_AC_CONFIG_ZLIB_INFLATE SPL_AC_CONFIG_ZLIB_DEFLATE @@ -1202,27 +1201,6 @@ AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [ ]) dnl # -dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. -dnl # Earlier versions of rwsem_is_locked() were inline and had a race -dnl # condition. The fixed version is exported as a symbol. The race -dnl # condition is fixed by acquiring sem->wait_lock, so we must not -dnl # call that version while holding sem->wait_lock. -dnl # -AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], - [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock]) - SPL_LINUX_TRY_COMPILE_SYMBOL([ - #include <linux/rwsem.h> - int rwsem_is_locked(struct rw_semaphore *sem) { return 0; } - ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1, - [rwsem_is_locked() acquires sem->wait_lock]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - -dnl # dnl # zlib inflate compat, dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled. dnl # diff --git a/include/linux/rwsem_compat.h b/include/linux/rwsem_compat.h index 80f348e4c..5841d7c28 100644 --- a/include/linux/rwsem_compat.h +++ b/include/linux/rwsem_compat.h @@ -37,30 +37,6 @@ #define spl_rwsem_trylock_irqsave(lk, fl) spin_trylock_irqsave(lk, fl) #endif /* RWSEM_SPINLOCK_IS_RAW */ -/* - * Prior to Linux 2.6.33 there existed a race condition in rwsem_is_locked(). - * The semaphore's activity was checked outside of the wait_lock which - * could result in some readers getting the incorrect activity value. - * - * When a kernel without this fix is detected the SPL takes responsibility - * for acquiring the wait_lock to avoid this race. - */ -#if defined(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK) #define spl_rwsem_is_locked(rwsem) rwsem_is_locked(rwsem) -#else -static inline int -spl_rwsem_is_locked(struct rw_semaphore *rwsem) -{ - unsigned long flags; - int rc = 1; - - if (spl_rwsem_trylock_irqsave(&rwsem->wait_lock, flags)) { - rc = rwsem_is_locked(rwsem); - spl_rwsem_unlock_irqrestore(&rwsem->wait_lock, flags); - } - - return (rc); -} -#endif /* RWSEM_IS_LOCKED_TAKES_WAIT_LOCK */ #endif /* _SPL_RWSEM_COMPAT_H */ diff --git a/include/sys/rwlock.h b/include/sys/rwlock.h index 9dfbfe545..7064e8f1f 100644 --- a/include/sys/rwlock.h +++ b/include/sys/rwlock.h @@ -83,15 +83,13 @@ rw_owner(krwlock_t *rwp) static inline int RW_READ_HELD(krwlock_t *rwp) { - return (spl_rwsem_is_locked(SEM(rwp)) && - rw_owner(rwp) == NULL); + return (spl_rwsem_is_locked(SEM(rwp)) && rw_owner(rwp) == NULL); } static inline int RW_WRITE_HELD(krwlock_t *rwp) { - return (spl_rwsem_is_locked(SEM(rwp)) && - rw_owner(rwp) == current); + return (spl_rwsem_is_locked(SEM(rwp)) && rw_owner(rwp) == current); } static inline int |