aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/mrlock.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-08-12 17:21:35 -0400
committerAlex Elder <aelder@sgi.com>2011-08-12 17:21:35 -0400
commitc59d87c460767bc35dafd490139d3cfe78fb8da4 (patch)
tree2aad8261f86488e501d9645bd35d1398906da46d /fs/xfs/mrlock.h
parent06f8e2d6754dc631732415b741b5aa58a0f7133f (diff)
xfs: remove subdirectories
Use the move from Linux 2.6 to Linux 3.x as an excuse to kill the annoying subdirectories in the XFS source code. Besides the large amount of file rename the only changes are to the Makefile, a few files including headers with the subdirectory prefix, and the binary sysctl compat code that includes a header under fs/xfs/ from kernel/. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/mrlock.h')
-rw-r--r--fs/xfs/mrlock.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/fs/xfs/mrlock.h b/fs/xfs/mrlock.h
new file mode 100644
index 000000000000..ff6a19873e5c
--- /dev/null
+++ b/fs/xfs/mrlock.h
@@ -0,0 +1,90 @@
1/*
2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would 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.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_SUPPORT_MRLOCK_H__
19#define __XFS_SUPPORT_MRLOCK_H__
20
21#include <linux/rwsem.h>
22
23typedef struct {
24 struct rw_semaphore mr_lock;
25#ifdef DEBUG
26 int mr_writer;
27#endif
28} mrlock_t;
29
30#ifdef DEBUG
31#define mrinit(mrp, name) \
32 do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0)
33#else
34#define mrinit(mrp, name) \
35 do { init_rwsem(&(mrp)->mr_lock); } while (0)
36#endif
37
38#define mrlock_init(mrp, t,n,s) mrinit(mrp, n)
39#define mrfree(mrp) do { } while (0)
40
41static inline void mraccess_nested(mrlock_t *mrp, int subclass)
42{
43 down_read_nested(&mrp->mr_lock, subclass);
44}
45
46static inline void mrupdate_nested(mrlock_t *mrp, int subclass)
47{
48 down_write_nested(&mrp->mr_lock, subclass);
49#ifdef DEBUG
50 mrp->mr_writer = 1;
51#endif
52}
53
54static inline int mrtryaccess(mrlock_t *mrp)
55{
56 return down_read_trylock(&mrp->mr_lock);
57}
58
59static inline int mrtryupdate(mrlock_t *mrp)
60{
61 if (!down_write_trylock(&mrp->mr_lock))
62 return 0;
63#ifdef DEBUG
64 mrp->mr_writer = 1;
65#endif
66 return 1;
67}
68
69static inline void mrunlock_excl(mrlock_t *mrp)
70{
71#ifdef DEBUG
72 mrp->mr_writer = 0;
73#endif
74 up_write(&mrp->mr_lock);
75}
76
77static inline void mrunlock_shared(mrlock_t *mrp)
78{
79 up_read(&mrp->mr_lock);
80}
81
82static inline void mrdemote(mrlock_t *mrp)
83{
84#ifdef DEBUG
85 mrp->mr_writer = 0;
86#endif
87 downgrade_write(&mrp->mr_lock);
88}
89
90#endif /* __XFS_SUPPORT_MRLOCK_H__ */