]> git.proxmox.com Git - mirror_spl.git/blame - src/spl/linux-rwlock.c
Initial commit. All spl source written up to this point wrapped
[mirror_spl.git] / src / spl / linux-rwlock.c
CommitLineData
f1ca4da6 1#include <sys/linux-rwlock.h>
2
3int
4rw_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
19int
20rw_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
31int
32rw_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}