]> git.proxmox.com Git - mirror_zfs.git/blob - modules/spl/spl-rwlock.c
Reorganize /include/ to add a /sys/, this way we don't need to
[mirror_zfs.git] / modules / spl / spl-rwlock.c
1 #include <sys/rwlock.h>
2
3 int
4 rw_lock_held(krwlock_t *rwlp)
5 {
6 BUG_ON(rwlp->rw_magic != RW_MAGIC);
7
8 #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
9 if (rwlp->rw_sem.activity != 0) {
10 #else
11 if (rwlp->rw_sem.count != 0) {
12 #endif
13 return 1;
14 }
15
16 return 0;
17 }
18
19 int
20 rw_read_held(krwlock_t *rwlp)
21 {
22 BUG_ON(rwlp->rw_magic != RW_MAGIC);
23
24 if (rw_lock_held(rwlp) && rwlp->rw_owner == NULL) {
25 return 1;
26 }
27
28 return 0;
29 }
30
31 int
32 rw_write_held(krwlock_t *rwlp)
33 {
34 BUG_ON(rwlp->rw_magic != RW_MAGIC);
35
36 if (rwlp->rw_owner == current) {
37 return 1;
38 }
39
40 return 0;
41 }