[XFS] remove unessecary vfs argument to DM_EVENT_ENABLED
[safe/jmp/linux-2.6] / fs / xfs / xfs_dmapi.h
1 /*
2  * Copyright (c) 2000-2005 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_DMAPI_H__
19 #define __XFS_DMAPI_H__
20
21 #include <linux/version.h>
22 /*      Values used to define the on-disk version of dm_attrname_t. All
23  *      on-disk attribute names start with the 8-byte string "SGI_DMI_".
24  *
25  *      In the on-disk inode, DMAPI attribute names consist of the user-provided
26  *      name with the DMATTR_PREFIXSTRING pre-pended.  This string must NEVER be
27  *      changed.
28  */
29
30 #define DMATTR_PREFIXLEN        8
31 #define DMATTR_PREFIXSTRING     "SGI_DMI_"
32
33 typedef enum {
34         DM_EVENT_INVALID        = -1,
35         DM_EVENT_CANCEL         = 0,            /* not supported */
36         DM_EVENT_MOUNT          = 1,
37         DM_EVENT_PREUNMOUNT     = 2,
38         DM_EVENT_UNMOUNT        = 3,
39         DM_EVENT_DEBUT          = 4,            /* not supported */
40         DM_EVENT_CREATE         = 5,
41         DM_EVENT_CLOSE          = 6,            /* not supported */
42         DM_EVENT_POSTCREATE     = 7,
43         DM_EVENT_REMOVE         = 8,
44         DM_EVENT_POSTREMOVE     = 9,
45         DM_EVENT_RENAME         = 10,
46         DM_EVENT_POSTRENAME     = 11,
47         DM_EVENT_LINK           = 12,
48         DM_EVENT_POSTLINK       = 13,
49         DM_EVENT_SYMLINK        = 14,
50         DM_EVENT_POSTSYMLINK    = 15,
51         DM_EVENT_READ           = 16,
52         DM_EVENT_WRITE          = 17,
53         DM_EVENT_TRUNCATE       = 18,
54         DM_EVENT_ATTRIBUTE      = 19,
55         DM_EVENT_DESTROY        = 20,
56         DM_EVENT_NOSPACE        = 21,
57         DM_EVENT_USER           = 22,
58         DM_EVENT_MAX            = 23
59 } dm_eventtype_t;
60 #define HAVE_DM_EVENTTYPE_T
61
62 typedef enum {
63         DM_RIGHT_NULL,
64         DM_RIGHT_SHARED,
65         DM_RIGHT_EXCL
66 } dm_right_t;
67 #define HAVE_DM_RIGHT_T
68
69 /* Defines for determining if an event message should be sent. */
70 #define DM_EVENT_ENABLED(ip, event) ( \
71         unlikely (XFS_MTOVFS((ip)->i_mount)->vfs_flag & VFS_DMI) && \
72                 ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
73                   ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
74         )
75
76 #define DM_XFS_VALID_FS_EVENTS          ( \
77         (1 << DM_EVENT_PREUNMOUNT)      | \
78         (1 << DM_EVENT_UNMOUNT)         | \
79         (1 << DM_EVENT_NOSPACE)         | \
80         (1 << DM_EVENT_DEBUT)           | \
81         (1 << DM_EVENT_CREATE)          | \
82         (1 << DM_EVENT_POSTCREATE)      | \
83         (1 << DM_EVENT_REMOVE)          | \
84         (1 << DM_EVENT_POSTREMOVE)      | \
85         (1 << DM_EVENT_RENAME)          | \
86         (1 << DM_EVENT_POSTRENAME)      | \
87         (1 << DM_EVENT_LINK)            | \
88         (1 << DM_EVENT_POSTLINK)        | \
89         (1 << DM_EVENT_SYMLINK)         | \
90         (1 << DM_EVENT_POSTSYMLINK)     | \
91         (1 << DM_EVENT_ATTRIBUTE)       | \
92         (1 << DM_EVENT_DESTROY)         )
93
94 /* Events valid in dm_set_eventlist() when called with a file handle for
95    a regular file or a symlink.  These events are persistent.
96 */
97
98 #define DM_XFS_VALID_FILE_EVENTS        ( \
99         (1 << DM_EVENT_ATTRIBUTE)       | \
100         (1 << DM_EVENT_DESTROY)         )
101
102 /* Events valid in dm_set_eventlist() when called with a file handle for
103    a directory.  These events are persistent.
104 */
105
106 #define DM_XFS_VALID_DIRECTORY_EVENTS   ( \
107         (1 << DM_EVENT_CREATE)          | \
108         (1 << DM_EVENT_POSTCREATE)      | \
109         (1 << DM_EVENT_REMOVE)          | \
110         (1 << DM_EVENT_POSTREMOVE)      | \
111         (1 << DM_EVENT_RENAME)          | \
112         (1 << DM_EVENT_POSTRENAME)      | \
113         (1 << DM_EVENT_LINK)            | \
114         (1 << DM_EVENT_POSTLINK)        | \
115         (1 << DM_EVENT_SYMLINK)         | \
116         (1 << DM_EVENT_POSTSYMLINK)     | \
117         (1 << DM_EVENT_ATTRIBUTE)       | \
118         (1 << DM_EVENT_DESTROY)         )
119
120 /* Events supported by the XFS filesystem. */
121 #define DM_XFS_SUPPORTED_EVENTS         ( \
122         (1 << DM_EVENT_MOUNT)           | \
123         (1 << DM_EVENT_PREUNMOUNT)      | \
124         (1 << DM_EVENT_UNMOUNT)         | \
125         (1 << DM_EVENT_NOSPACE)         | \
126         (1 << DM_EVENT_CREATE)          | \
127         (1 << DM_EVENT_POSTCREATE)      | \
128         (1 << DM_EVENT_REMOVE)          | \
129         (1 << DM_EVENT_POSTREMOVE)      | \
130         (1 << DM_EVENT_RENAME)          | \
131         (1 << DM_EVENT_POSTRENAME)      | \
132         (1 << DM_EVENT_LINK)            | \
133         (1 << DM_EVENT_POSTLINK)        | \
134         (1 << DM_EVENT_SYMLINK)         | \
135         (1 << DM_EVENT_POSTSYMLINK)     | \
136         (1 << DM_EVENT_READ)            | \
137         (1 << DM_EVENT_WRITE)           | \
138         (1 << DM_EVENT_TRUNCATE)        | \
139         (1 << DM_EVENT_ATTRIBUTE)       | \
140         (1 << DM_EVENT_DESTROY)         )
141
142
143 /*
144  *      Definitions used for the flags field on dm_send_*_event().
145  */
146
147 #define DM_FLAGS_NDELAY         0x001   /* return EAGAIN after dm_pending() */
148 #define DM_FLAGS_UNWANTED       0x002   /* event not in fsys dm_eventset_t */
149 #define DM_FLAGS_IMUX           0x004   /* thread holds i_mutex */
150 #define DM_FLAGS_IALLOCSEM_RD   0x010   /* thread holds i_alloc_sem rd */
151 #define DM_FLAGS_IALLOCSEM_WR   0x020   /* thread holds i_alloc_sem wr */
152
153 /*
154  *      Pull in platform specific event flags defines
155  */
156 #include "xfs_dmapi_priv.h"
157
158 /*
159  *      Macros to turn caller specified delay/block flags into
160  *      dm_send_xxxx_event flag DM_FLAGS_NDELAY.
161  */
162
163 #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
164                         DM_FLAGS_NDELAY : 0)
165 #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
166
167
168 extern struct bhv_module_vfsops xfs_dmops;
169
170 #endif  /* __XFS_DMAPI_H__ */