blob: 5a5c7a63e80b80a356ef0f27a7f134c2646140ed [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_DMAPI_H__
19#define __XFS_DMAPI_H__
20
21/* Values used to define the on-disk version of dm_attrname_t. All
22 * on-disk attribute names start with the 8-byte string "SGI_DMI_".
23 *
24 * In the on-disk inode, DMAPI attribute names consist of the user-provided
25 * name with the DMATTR_PREFIXSTRING pre-pended. This string must NEVER be
26 * changed.
27 */
28
29#define DMATTR_PREFIXLEN 8
30#define DMATTR_PREFIXSTRING "SGI_DMI_"
31
32typedef enum {
33 DM_EVENT_INVALID = -1,
34 DM_EVENT_CANCEL = 0, /* not supported */
35 DM_EVENT_MOUNT = 1,
36 DM_EVENT_PREUNMOUNT = 2,
37 DM_EVENT_UNMOUNT = 3,
38 DM_EVENT_DEBUT = 4, /* not supported */
39 DM_EVENT_CREATE = 5,
40 DM_EVENT_CLOSE = 6, /* not supported */
41 DM_EVENT_POSTCREATE = 7,
42 DM_EVENT_REMOVE = 8,
43 DM_EVENT_POSTREMOVE = 9,
44 DM_EVENT_RENAME = 10,
45 DM_EVENT_POSTRENAME = 11,
46 DM_EVENT_LINK = 12,
47 DM_EVENT_POSTLINK = 13,
48 DM_EVENT_SYMLINK = 14,
49 DM_EVENT_POSTSYMLINK = 15,
50 DM_EVENT_READ = 16,
51 DM_EVENT_WRITE = 17,
52 DM_EVENT_TRUNCATE = 18,
53 DM_EVENT_ATTRIBUTE = 19,
54 DM_EVENT_DESTROY = 20,
55 DM_EVENT_NOSPACE = 21,
56 DM_EVENT_USER = 22,
57 DM_EVENT_MAX = 23
58} dm_eventtype_t;
59#define HAVE_DM_EVENTTYPE_T
60
61typedef enum {
62 DM_RIGHT_NULL,
63 DM_RIGHT_SHARED,
64 DM_RIGHT_EXCL
65} dm_right_t;
66#define HAVE_DM_RIGHT_T
67
68/* Defines for determining if an event message should be sent. */
69#define DM_EVENT_ENABLED(vfsp, ip, event) ( \
70 unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
71 ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
72 ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
73 )
74
75#define DM_EVENT_ENABLED_IO(vfsp, io, event) ( \
76 unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
77 ( ((io)->io_dmevmask & (1 << event)) || \
78 ((io)->io_mount->m_dmevmask & (1 << event)) ) \
79 )
80
81#define DM_XFS_VALID_FS_EVENTS ( \
82 (1 << DM_EVENT_PREUNMOUNT) | \
83 (1 << DM_EVENT_UNMOUNT) | \
84 (1 << DM_EVENT_NOSPACE) | \
85 (1 << DM_EVENT_DEBUT) | \
86 (1 << DM_EVENT_CREATE) | \
87 (1 << DM_EVENT_POSTCREATE) | \
88 (1 << DM_EVENT_REMOVE) | \
89 (1 << DM_EVENT_POSTREMOVE) | \
90 (1 << DM_EVENT_RENAME) | \
91 (1 << DM_EVENT_POSTRENAME) | \
92 (1 << DM_EVENT_LINK) | \
93 (1 << DM_EVENT_POSTLINK) | \
94 (1 << DM_EVENT_SYMLINK) | \
95 (1 << DM_EVENT_POSTSYMLINK) | \
96 (1 << DM_EVENT_ATTRIBUTE) | \
97 (1 << DM_EVENT_DESTROY) )
98
99/* Events valid in dm_set_eventlist() when called with a file handle for
100 a regular file or a symlink. These events are persistent.
101*/
102
103#define DM_XFS_VALID_FILE_EVENTS ( \
104 (1 << DM_EVENT_ATTRIBUTE) | \
105 (1 << DM_EVENT_DESTROY) )
106
107/* Events valid in dm_set_eventlist() when called with a file handle for
108 a directory. These events are persistent.
109*/
110
111#define DM_XFS_VALID_DIRECTORY_EVENTS ( \
112 (1 << DM_EVENT_CREATE) | \
113 (1 << DM_EVENT_POSTCREATE) | \
114 (1 << DM_EVENT_REMOVE) | \
115 (1 << DM_EVENT_POSTREMOVE) | \
116 (1 << DM_EVENT_RENAME) | \
117 (1 << DM_EVENT_POSTRENAME) | \
118 (1 << DM_EVENT_LINK) | \
119 (1 << DM_EVENT_POSTLINK) | \
120 (1 << DM_EVENT_SYMLINK) | \
121 (1 << DM_EVENT_POSTSYMLINK) | \
122 (1 << DM_EVENT_ATTRIBUTE) | \
123 (1 << DM_EVENT_DESTROY) )
124
125/* Events supported by the XFS filesystem. */
126#define DM_XFS_SUPPORTED_EVENTS ( \
127 (1 << DM_EVENT_MOUNT) | \
128 (1 << DM_EVENT_PREUNMOUNT) | \
129 (1 << DM_EVENT_UNMOUNT) | \
130 (1 << DM_EVENT_NOSPACE) | \
131 (1 << DM_EVENT_CREATE) | \
132 (1 << DM_EVENT_POSTCREATE) | \
133 (1 << DM_EVENT_REMOVE) | \
134 (1 << DM_EVENT_POSTREMOVE) | \
135 (1 << DM_EVENT_RENAME) | \
136 (1 << DM_EVENT_POSTRENAME) | \
137 (1 << DM_EVENT_LINK) | \
138 (1 << DM_EVENT_POSTLINK) | \
139 (1 << DM_EVENT_SYMLINK) | \
140 (1 << DM_EVENT_POSTSYMLINK) | \
141 (1 << DM_EVENT_READ) | \
142 (1 << DM_EVENT_WRITE) | \
143 (1 << DM_EVENT_TRUNCATE) | \
144 (1 << DM_EVENT_ATTRIBUTE) | \
145 (1 << DM_EVENT_DESTROY) )
146
147
148/*
149 * Definitions used for the flags field on dm_send_*_event().
150 */
151
152#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
153#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
154#define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
156#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
158/*
159 * Based on IO_ISDIRECT, decide which i_ flag is set.
160 */
Dean Roehriche1a40fa2005-06-22 10:20:44 +1000161#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
162#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
163 DM_FLAGS_ISEM : 0)
164#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
165#endif
166
167#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
168 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
170 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM)
171#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
Dean Roehriche1a40fa2005-06-22 10:20:44 +1000172#endif
173
174#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
176 0 : DM_FLAGS_ISEM)
177#define DM_SEM_FLAG_WR (DM_FLAGS_ISEM)
178#endif
179
Dean Roehriche1a40fa2005-06-22 10:20:44 +1000180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181/*
182 * Macros to turn caller specified delay/block flags into
183 * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
184 */
185
186#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
187 DM_FLAGS_NDELAY : 0)
188#define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
189
190
191extern struct bhv_vfsops xfs_dmops;
192
193#ifdef CONFIG_XFS_DMAPI
194void xfs_dm_init(struct file_system_type *);
195void xfs_dm_exit(struct file_system_type *);
196#define XFS_DM_INIT(fstype) xfs_dm_init(fstype)
197#define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype)
198#else
199#define XFS_DM_INIT(fstype)
200#define XFS_DM_EXIT(fstype)
201#endif
202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203#endif /* __XFS_DMAPI_H__ */