1 /* 2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 3 * 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. 7 * 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. 11 * 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. 18 * 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. 22 * 23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 24 * Mountain View, CA 94043, or: 25 * 26 * http://www.sgi.com 27 * 28 * For further information regarding this notice, see: 29 * 30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ 31 */ 32 #ifndef __XFS_DMAPI_H__ 33 #define __XFS_DMAPI_H__ 34 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_". 37 * 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 40 * changed. 41 */ 42 43 #define DMATTR_PREFIXLEN 8 44 #define DMATTR_PREFIXSTRING "SGI_DMI_" 45 46 typedef enum { 47 DM_EVENT_INVALID = -1, 48 DM_EVENT_CANCEL = 0, /* not supported */ 49 DM_EVENT_MOUNT = 1, 50 DM_EVENT_PREUNMOUNT = 2, 51 DM_EVENT_UNMOUNT = 3, 52 DM_EVENT_DEBUT = 4, /* not supported */ 53 DM_EVENT_CREATE = 5, 54 DM_EVENT_CLOSE = 6, /* not supported */ 55 DM_EVENT_POSTCREATE = 7, 56 DM_EVENT_REMOVE = 8, 57 DM_EVENT_POSTREMOVE = 9, 58 DM_EVENT_RENAME = 10, 59 DM_EVENT_POSTRENAME = 11, 60 DM_EVENT_LINK = 12, 61 DM_EVENT_POSTLINK = 13, 62 DM_EVENT_SYMLINK = 14, 63 DM_EVENT_POSTSYMLINK = 15, 64 DM_EVENT_READ = 16, 65 DM_EVENT_WRITE = 17, 66 DM_EVENT_TRUNCATE = 18, 67 DM_EVENT_ATTRIBUTE = 19, 68 DM_EVENT_DESTROY = 20, 69 DM_EVENT_NOSPACE = 21, 70 DM_EVENT_USER = 22, 71 DM_EVENT_MAX = 23 72 } dm_eventtype_t; 73 #define HAVE_DM_EVENTTYPE_T 74 75 typedef enum { 76 DM_RIGHT_NULL, 77 DM_RIGHT_SHARED, 78 DM_RIGHT_EXCL 79 } dm_right_t; 80 #define HAVE_DM_RIGHT_T 81 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)) ) \ 87 ) 88 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)) ) \ 93 ) 94 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) ) 112 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. 115 */ 116 117 #define DM_XFS_VALID_FILE_EVENTS ( \ 118 (1 << DM_EVENT_ATTRIBUTE) | \ 119 (1 << DM_EVENT_DESTROY) ) 120 121 /* Events valid in dm_set_eventlist() when called with a file handle for 122 a directory. These events are persistent. 123 */ 124 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) ) 138 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) ) 160 161 162 /* 163 * Definitions used for the flags field on dm_send_*_event(). 164 */ 165 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 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) 170 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21) 171 /* i_alloc_sem was added in 2.4.22-pre1 */ 172 #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */ 173 #define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */ 174 #endif 175 #endif 176 177 /* 178 * Based on IO_ISDIRECT, decide which i_ flag is set. 179 */ 180 #ifdef DM_FLAGS_IALLOCSEM_RD 181 #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 182 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM) 183 #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM) 184 #else 185 #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 186 0 : DM_FLAGS_ISEM) 187 #define DM_SEM_FLAG_WR (DM_FLAGS_ISEM) 188 #endif 189 190 /* 191 * Macros to turn caller specified delay/block flags into 192 * dm_send_xxxx_event flag DM_FLAGS_NDELAY. 193 */ 194 195 #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \ 196 DM_FLAGS_NDELAY : 0) 197 #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0) 198 199 200 extern struct bhv_vfsops xfs_dmops; 201 202 #ifdef CONFIG_XFS_DMAPI 203 void xfs_dm_init(struct file_system_type *); 204 void xfs_dm_exit(struct file_system_type *); 205 #define XFS_DM_INIT(fstype) xfs_dm_init(fstype) 206 #define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype) 207 #else 208 #define XFS_DM_INIT(fstype) 209 #define XFS_DM_EXIT(fstype) 210 #endif 211 212 #endif /* __XFS_DMAPI_H__ */ 213