summaryrefslogtreecommitdiffstats
path: root/modules/spl
diff options
context:
space:
mode:
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-04-07 23:54:34 +0000
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-04-07 23:54:34 +0000
commit79f92663e36969c0b6b1f8520b1171285ae3e1d3 (patch)
treeb9660ff597c7abb8044f035c80c4143a5d2ef582 /modules/spl
parent728b9dd80074bedef6136b6acf5cb86d707172ea (diff)
Fix race in rwlock implementation which can occur when
your task is rescheduled to a different cpu after you've taken the lock but before calling RW_LOCK_HELD is called. We need the spinlock to ensure there is a wmb() there. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@68 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
Diffstat (limited to 'modules/spl')
-rw-r--r--modules/spl/spl-rwlock.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/spl/spl-rwlock.c b/modules/spl/spl-rwlock.c
index fa78d4c14..2ca8306f7 100644
--- a/modules/spl/spl-rwlock.c
+++ b/modules/spl/spl-rwlock.c
@@ -29,16 +29,21 @@ EXPORT_SYMBOL(__rw_write_held);
int
__rw_lock_held(krwlock_t *rwlp)
{
+ int rc = 0;
+
BUG_ON(rwlp->rw_magic != RW_MAGIC);
+ spin_lock_irq(&(rwlp->rw_sem.wait_lock));
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
if (rwlp->rw_sem.activity != 0) {
#else
if (rwlp->rw_sem.count != 0) {
#endif
- return 1;
+ rc = 1;
}
- return 0;
+ spin_unlock_irq(&(rwlp->rw_sem.wait_lock));
+
+ return rc;
}
EXPORT_SYMBOL(__rw_lock_held);