- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / include / linux / locks.h
blob9d342e6694041a8b63e942a9959a0a3f5cbc43b0
1 #ifndef _LINUX_LOCKS_H
2 #define _LINUX_LOCKS_H
4 #ifndef _LINUX_MM_H
5 #include <linux/mm.h>
6 #endif
7 #ifndef _LINUX_PAGEMAP_H
8 #include <linux/pagemap.h>
9 #endif
12 * Buffer cache locking - note that interrupts may only unlock, not
13 * lock buffers.
15 extern void __wait_on_buffer(struct buffer_head *);
17 extern inline void wait_on_buffer(struct buffer_head * bh)
19 if (test_bit(BH_Lock, &bh->b_state))
20 __wait_on_buffer(bh);
23 extern inline void lock_buffer(struct buffer_head * bh)
25 while (test_and_set_bit(BH_Lock, &bh->b_state))
26 __wait_on_buffer(bh);
29 extern inline void unlock_buffer(struct buffer_head *bh)
31 clear_bit(BH_Lock, &bh->b_state);
32 smp_mb__after_clear_bit();
33 if (waitqueue_active(&bh->b_wait))
34 wake_up(&bh->b_wait);
38 * super-block locking. Again, interrupts may only unlock
39 * a super-block (although even this isn't done right now.
40 * nfs may need it).
42 extern void __wait_on_super(struct super_block *);
44 extern inline void wait_on_super(struct super_block * sb)
46 if (sb->s_lock)
47 __wait_on_super(sb);
50 extern inline void lock_super(struct super_block * sb)
52 if (sb->s_lock)
53 __wait_on_super(sb);
54 sb->s_lock = 1;
57 extern inline void unlock_super(struct super_block * sb)
59 sb->s_lock = 0;
61 * No need of any barrier, we're protected by
62 * the big kernel lock here... unfortunately :)
64 if (waitqueue_active(&sb->s_wait))
65 wake_up(&sb->s_wait);
68 #endif /* _LINUX_LOCKS_H */