]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/aufs/rwsem.h
2 * Copyright (C) 2005-2017 Junjiro R. Okajima
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * simple read-write semaphore wrappers
22 #ifndef __AUFS_RWSEM_H__
23 #define __AUFS_RWSEM_H__
29 /* in the futre, the name 'au_rwsem' will be totally gone */
30 #define au_rwsem rw_semaphore
32 /* to debug easier, do not make them inlined functions */
33 #define AuRwMustNoWaiters(rw) AuDebugOn(rwsem_is_contended(rw))
34 /* rwsem_is_locked() is unusable */
35 #define AuRwMustReadLock(rw) AuDebugOn(!lockdep_recursing(current) \
37 && !lockdep_is_held_type(rw, 1))
38 #define AuRwMustWriteLock(rw) AuDebugOn(!lockdep_recursing(current) \
40 && !lockdep_is_held_type(rw, 0))
41 #define AuRwMustAnyLock(rw) AuDebugOn(!lockdep_recursing(current) \
43 && !lockdep_is_held(rw))
44 #define AuRwDestroy(rw) AuDebugOn(!lockdep_recursing(current) \
46 && lockdep_is_held(rw))
48 #define au_rw_init(rw) init_rwsem(rw)
50 #define au_rw_init_wlock(rw) do { \
55 #define au_rw_init_wlock_nested(rw, lsc) do { \
57 down_write_nested(rw, lsc); \
60 #define au_rw_read_lock(rw) down_read(rw)
61 #define au_rw_read_lock_nested(rw, lsc) down_read_nested(rw, lsc)
62 #define au_rw_read_unlock(rw) up_read(rw)
63 #define au_rw_dgrade_lock(rw) downgrade_write(rw)
64 #define au_rw_write_lock(rw) down_write(rw)
65 #define au_rw_write_lock_nested(rw, lsc) down_write_nested(rw, lsc)
66 #define au_rw_write_unlock(rw) up_write(rw)
67 /* why is not _nested version defined? */
68 #define au_rw_read_trylock(rw) down_read_trylock(rw)
69 #define au_rw_write_trylock(rw) down_write_trylock(rw)
71 #endif /* __KERNEL__ */
72 #endif /* __AUFS_RWSEM_H__ */