mirror_zfs/modules/spl/spl-rwlock.c
behlendo 596e65b4e8 OK, I think this is the last of major cleanup and restructuring.
We've dropped all the linux- prefixes on the file in favor of spl-
which makes more sense.  And we've cleaned up some of the includes
so everybody should be including their own dependencies properly.
All a module which wants to use the spl support needs to do in
include spl.h and ensure it has access to Module.symvers.



git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@16 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
2008-02-28 00:48:31 +00:00

42 lines
541 B
C

#include <spl-rwlock.h>
int
rw_lock_held(krwlock_t *rwlp)
{
BUG_ON(rwlp->rw_magic != RW_MAGIC);
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
if (rwlp->rw_sem.activity != 0) {
#else
if (rwlp->rw_sem.count != 0) {
#endif
return 1;
}
return 0;
}
int
rw_read_held(krwlock_t *rwlp)
{
BUG_ON(rwlp->rw_magic != RW_MAGIC);
if (rw_lock_held(rwlp) && rwlp->rw_owner == NULL) {
return 1;
}
return 0;
}
int
rw_write_held(krwlock_t *rwlp)
{
BUG_ON(rwlp->rw_magic != RW_MAGIC);
if (rwlp->rw_owner == current) {
return 1;
}
return 0;
}