2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __XFS_DMAPI_H__
33 #define __XFS_DMAPI_H__
35 /* Values used to define the on-disk version of dm_attrname_t. All
36 * on-disk attribute names start with the 8-byte string "SGI_DMI_".
38 * In the on-disk inode, DMAPI attribute names consist of the user-provided
39 * name with the DMATTR_PREFIXSTRING pre-pended. This string must NEVER be
43 #define DMATTR_PREFIXLEN 8
44 #define DMATTR_PREFIXSTRING "SGI_DMI_"
47 DM_EVENT_INVALID = -1,
48 DM_EVENT_CANCEL = 0, /* not supported */
50 DM_EVENT_PREUNMOUNT = 2,
52 DM_EVENT_DEBUT = 4, /* not supported */
54 DM_EVENT_CLOSE = 6, /* not supported */
55 DM_EVENT_POSTCREATE = 7,
57 DM_EVENT_POSTREMOVE = 9,
59 DM_EVENT_POSTRENAME = 11,
61 DM_EVENT_POSTLINK = 13,
62 DM_EVENT_SYMLINK = 14,
63 DM_EVENT_POSTSYMLINK = 15,
66 DM_EVENT_TRUNCATE = 18,
67 DM_EVENT_ATTRIBUTE = 19,
68 DM_EVENT_DESTROY = 20,
69 DM_EVENT_NOSPACE = 21,
73 #define HAVE_DM_EVENTTYPE_T
80 #define HAVE_DM_RIGHT_T
82 /* Defines for determining if an event message should be sent. */
83 #define DM_EVENT_ENABLED(vfsp, ip, event) ( \
84 unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
85 ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
86 ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
89 #define DM_EVENT_ENABLED_IO(vfsp, io, event) ( \
90 unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
91 ( ((io)->io_dmevmask & (1 << event)) || \
92 ((io)->io_mount->m_dmevmask & (1 << event)) ) \
95 #define DM_XFS_VALID_FS_EVENTS ( \
96 (1 << DM_EVENT_PREUNMOUNT) | \
97 (1 << DM_EVENT_UNMOUNT) | \
98 (1 << DM_EVENT_NOSPACE) | \
99 (1 << DM_EVENT_DEBUT) | \
100 (1 << DM_EVENT_CREATE) | \
101 (1 << DM_EVENT_POSTCREATE) | \
102 (1 << DM_EVENT_REMOVE) | \
103 (1 << DM_EVENT_POSTREMOVE) | \
104 (1 << DM_EVENT_RENAME) | \
105 (1 << DM_EVENT_POSTRENAME) | \
106 (1 << DM_EVENT_LINK) | \
107 (1 << DM_EVENT_POSTLINK) | \
108 (1 << DM_EVENT_SYMLINK) | \
109 (1 << DM_EVENT_POSTSYMLINK) | \
110 (1 << DM_EVENT_ATTRIBUTE) | \
111 (1 << DM_EVENT_DESTROY) )
113 /* Events valid in dm_set_eventlist() when called with a file handle for
114 a regular file or a symlink. These events are persistent.
117 #define DM_XFS_VALID_FILE_EVENTS ( \
118 (1 << DM_EVENT_ATTRIBUTE) | \
119 (1 << DM_EVENT_DESTROY) )
121 /* Events valid in dm_set_eventlist() when called with a file handle for
122 a directory. These events are persistent.
125 #define DM_XFS_VALID_DIRECTORY_EVENTS ( \
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_ATTRIBUTE) | \
137 (1 << DM_EVENT_DESTROY) )
139 /* Events supported by the XFS filesystem. */
140 #define DM_XFS_SUPPORTED_EVENTS ( \
141 (1 << DM_EVENT_MOUNT) | \
142 (1 << DM_EVENT_PREUNMOUNT) | \
143 (1 << DM_EVENT_UNMOUNT) | \
144 (1 << DM_EVENT_NOSPACE) | \
145 (1 << DM_EVENT_CREATE) | \
146 (1 << DM_EVENT_POSTCREATE) | \
147 (1 << DM_EVENT_REMOVE) | \
148 (1 << DM_EVENT_POSTREMOVE) | \
149 (1 << DM_EVENT_RENAME) | \
150 (1 << DM_EVENT_POSTRENAME) | \
151 (1 << DM_EVENT_LINK) | \
152 (1 << DM_EVENT_POSTLINK) | \
153 (1 << DM_EVENT_SYMLINK) | \
154 (1 << DM_EVENT_POSTSYMLINK) | \
155 (1 << DM_EVENT_READ) | \
156 (1 << DM_EVENT_WRITE) | \
157 (1 << DM_EVENT_TRUNCATE) | \
158 (1 << DM_EVENT_ATTRIBUTE) | \
159 (1 << DM_EVENT_DESTROY) )
163 * Definitions used for the flags field on dm_send_*_event().
166 #define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
167 #define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
168 #define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */
169 #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
170 #define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
173 * Based on IO_ISDIRECT, decide which i_ flag is set.
175 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
176 #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
178 #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
181 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
182 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
183 #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
184 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM)
185 #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
188 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
189 #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
191 #define DM_SEM_FLAG_WR (DM_FLAGS_ISEM)
196 * Macros to turn caller specified delay/block flags into
197 * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
200 #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
202 #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
205 extern struct bhv_vfsops xfs_dmops;
207 #ifdef CONFIG_XFS_DMAPI
208 void xfs_dm_init(struct file_system_type *);
209 void xfs_dm_exit(struct file_system_type *);
210 #define XFS_DM_INIT(fstype) xfs_dm_init(fstype)
211 #define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype)
213 #define XFS_DM_INIT(fstype)
214 #define XFS_DM_EXIT(fstype)
217 #endif /* __XFS_DMAPI_H__ */