Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_DMAPI_H__ |
| 19 | #define __XFS_DMAPI_H__ |
| 20 | |
Olaf Hering | 733482e | 2005-11-08 21:34:55 -0800 | [diff] [blame] | 21 | #include <linux/version.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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(vfsp, ip, event) ( \ |
| 71 | unlikely ((vfsp)->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_EVENT_ENABLED_IO(vfsp, io, event) ( \ |
| 77 | unlikely ((vfsp)->vfs_flag & VFS_DMI) && \ |
| 78 | ( ((io)->io_dmevmask & (1 << event)) || \ |
| 79 | ((io)->io_mount->m_dmevmask & (1 << event)) ) \ |
| 80 | ) |
| 81 | |
| 82 | #define DM_XFS_VALID_FS_EVENTS ( \ |
| 83 | (1 << DM_EVENT_PREUNMOUNT) | \ |
| 84 | (1 << DM_EVENT_UNMOUNT) | \ |
| 85 | (1 << DM_EVENT_NOSPACE) | \ |
| 86 | (1 << DM_EVENT_DEBUT) | \ |
| 87 | (1 << DM_EVENT_CREATE) | \ |
| 88 | (1 << DM_EVENT_POSTCREATE) | \ |
| 89 | (1 << DM_EVENT_REMOVE) | \ |
| 90 | (1 << DM_EVENT_POSTREMOVE) | \ |
| 91 | (1 << DM_EVENT_RENAME) | \ |
| 92 | (1 << DM_EVENT_POSTRENAME) | \ |
| 93 | (1 << DM_EVENT_LINK) | \ |
| 94 | (1 << DM_EVENT_POSTLINK) | \ |
| 95 | (1 << DM_EVENT_SYMLINK) | \ |
| 96 | (1 << DM_EVENT_POSTSYMLINK) | \ |
| 97 | (1 << DM_EVENT_ATTRIBUTE) | \ |
| 98 | (1 << DM_EVENT_DESTROY) ) |
| 99 | |
| 100 | /* Events valid in dm_set_eventlist() when called with a file handle for |
| 101 | a regular file or a symlink. These events are persistent. |
| 102 | */ |
| 103 | |
| 104 | #define DM_XFS_VALID_FILE_EVENTS ( \ |
| 105 | (1 << DM_EVENT_ATTRIBUTE) | \ |
| 106 | (1 << DM_EVENT_DESTROY) ) |
| 107 | |
| 108 | /* Events valid in dm_set_eventlist() when called with a file handle for |
| 109 | a directory. These events are persistent. |
| 110 | */ |
| 111 | |
| 112 | #define DM_XFS_VALID_DIRECTORY_EVENTS ( \ |
| 113 | (1 << DM_EVENT_CREATE) | \ |
| 114 | (1 << DM_EVENT_POSTCREATE) | \ |
| 115 | (1 << DM_EVENT_REMOVE) | \ |
| 116 | (1 << DM_EVENT_POSTREMOVE) | \ |
| 117 | (1 << DM_EVENT_RENAME) | \ |
| 118 | (1 << DM_EVENT_POSTRENAME) | \ |
| 119 | (1 << DM_EVENT_LINK) | \ |
| 120 | (1 << DM_EVENT_POSTLINK) | \ |
| 121 | (1 << DM_EVENT_SYMLINK) | \ |
| 122 | (1 << DM_EVENT_POSTSYMLINK) | \ |
| 123 | (1 << DM_EVENT_ATTRIBUTE) | \ |
| 124 | (1 << DM_EVENT_DESTROY) ) |
| 125 | |
| 126 | /* Events supported by the XFS filesystem. */ |
| 127 | #define DM_XFS_SUPPORTED_EVENTS ( \ |
| 128 | (1 << DM_EVENT_MOUNT) | \ |
| 129 | (1 << DM_EVENT_PREUNMOUNT) | \ |
| 130 | (1 << DM_EVENT_UNMOUNT) | \ |
| 131 | (1 << DM_EVENT_NOSPACE) | \ |
| 132 | (1 << DM_EVENT_CREATE) | \ |
| 133 | (1 << DM_EVENT_POSTCREATE) | \ |
| 134 | (1 << DM_EVENT_REMOVE) | \ |
| 135 | (1 << DM_EVENT_POSTREMOVE) | \ |
| 136 | (1 << DM_EVENT_RENAME) | \ |
| 137 | (1 << DM_EVENT_POSTRENAME) | \ |
| 138 | (1 << DM_EVENT_LINK) | \ |
| 139 | (1 << DM_EVENT_POSTLINK) | \ |
| 140 | (1 << DM_EVENT_SYMLINK) | \ |
| 141 | (1 << DM_EVENT_POSTSYMLINK) | \ |
| 142 | (1 << DM_EVENT_READ) | \ |
| 143 | (1 << DM_EVENT_WRITE) | \ |
| 144 | (1 << DM_EVENT_TRUNCATE) | \ |
| 145 | (1 << DM_EVENT_ATTRIBUTE) | \ |
| 146 | (1 << DM_EVENT_DESTROY) ) |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | * Definitions used for the flags field on dm_send_*_event(). |
| 151 | */ |
| 152 | |
| 153 | #define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */ |
| 154 | #define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */ |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 155 | #define DM_FLAGS_IMUX 0x004 /* thread holds i_mutex */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */ |
| 157 | #define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | /* |
| 160 | * Based on IO_ISDIRECT, decide which i_ flag is set. |
| 161 | */ |
Dean Roehrich | e1a40fa | 2005-06-22 10:20:44 +1000 | [diff] [blame] | 162 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) |
| 163 | #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 164 | DM_FLAGS_IMUX : 0) |
| 165 | #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX) |
Dean Roehrich | e1a40fa | 2005-06-22 10:20:44 +1000 | [diff] [blame] | 166 | #endif |
| 167 | |
| 168 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \ |
| 169 | (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 171 | DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_IMUX) |
| 172 | #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX) |
Dean Roehrich | e1a40fa | 2005-06-22 10:20:44 +1000 | [diff] [blame] | 173 | #endif |
| 174 | |
| 175 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 177 | 0 : DM_FLAGS_IMUX) |
| 178 | #define DM_SEM_FLAG_WR (DM_FLAGS_IMUX) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | #endif |
| 180 | |
Dean Roehrich | e1a40fa | 2005-06-22 10:20:44 +1000 | [diff] [blame] | 181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | /* |
| 183 | * Macros to turn caller specified delay/block flags into |
| 184 | * dm_send_xxxx_event flag DM_FLAGS_NDELAY. |
| 185 | */ |
| 186 | |
| 187 | #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \ |
| 188 | DM_FLAGS_NDELAY : 0) |
| 189 | #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0) |
| 190 | |
| 191 | |
| 192 | extern struct bhv_vfsops xfs_dmops; |
| 193 | |
| 194 | #ifdef CONFIG_XFS_DMAPI |
| 195 | void xfs_dm_init(struct file_system_type *); |
| 196 | void xfs_dm_exit(struct file_system_type *); |
| 197 | #define XFS_DM_INIT(fstype) xfs_dm_init(fstype) |
| 198 | #define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype) |
| 199 | #else |
| 200 | #define XFS_DM_INIT(fstype) |
| 201 | #define XFS_DM_EXIT(fstype) |
| 202 | #endif |
| 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | #endif /* __XFS_DMAPI_H__ */ |