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_VNODE_H__ |
| 19 | #define __XFS_VNODE_H__ |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | struct file; |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 22 | struct bhv_vfs; |
| 23 | struct bhv_vattr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | struct xfs_iomap; |
| 25 | struct attrlist_cursor_kern; |
| 26 | |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 27 | typedef struct dentry bhv_vname_t; |
| 28 | typedef __u64 bhv_vnumber_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 30 | typedef enum bhv_vflags { |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 31 | VMODIFIED = 0x08, /* XFS inode state possibly differs */ |
| 32 | /* to the Linux inode state. */ |
| 33 | VTRUNCATED = 0x40, /* truncated down so flush-on-close */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 34 | } bhv_vflags_t; |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | /* |
| 37 | * MP locking protocols: |
| 38 | * v_flag, v_vfsp VN_LOCK/VN_UNLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 40 | typedef struct bhv_vnode { |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 41 | bhv_vflags_t v_flag; /* vnode flags (see above) */ |
| 42 | bhv_vfs_t *v_vfsp; /* ptr to containing VFS */ |
| 43 | bhv_vnumber_t v_number; /* in-core vnode number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */ |
Christoph Hellwig | 51c91ed5 | 2005-09-02 16:58:38 +1000 | [diff] [blame] | 45 | atomic_t v_iocount; /* outstanding I/O count */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #ifdef XFS_VNODE_TRACE |
| 47 | struct ktrace *v_trace; /* trace header structure */ |
| 48 | #endif |
Eric Sandeen | 9effd8e | 2005-05-05 13:26:18 -0700 | [diff] [blame] | 49 | struct inode v_inode; /* Linux inode */ |
| 50 | /* inode MUST be last */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 51 | } bhv_vnode_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Christoph Hellwig | 0432dab | 2005-09-02 16:46:51 +1000 | [diff] [blame] | 53 | #define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode) |
| 54 | #define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode) |
| 55 | #define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode) |
| 56 | #define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode) |
| 57 | #define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode) |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | /* |
| 60 | * Vnode to Linux inode mapping. |
| 61 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 62 | static inline struct bhv_vnode *vn_from_inode(struct inode *inode) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 63 | { |
Alexey Dobriyan | 71306f3 | 2006-06-27 14:10:29 +1000 | [diff] [blame] | 64 | return container_of(inode, bhv_vnode_t, v_inode); |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 65 | } |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 66 | static inline struct inode *vn_to_inode(struct bhv_vnode *vnode) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 67 | { |
| 68 | return &vnode->v_inode; |
| 69 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 72 | * Values for the vop_rwlock/rwunlock flags parameter. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 74 | typedef enum bhv_vrwlock { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | VRWLOCK_NONE, |
| 76 | VRWLOCK_READ, |
| 77 | VRWLOCK_WRITE, |
| 78 | VRWLOCK_WRITE_DIRECT, |
| 79 | VRWLOCK_TRY_READ, |
| 80 | VRWLOCK_TRY_WRITE |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 81 | } bhv_vrwlock_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | /* |
Christoph Hellwig | 739bfb2 | 2007-08-29 10:58:01 +1000 | [diff] [blame^] | 84 | * Return values for xfs_inactive. A return value of |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | * VN_INACTIVE_NOCACHE implies that the file system behavior |
| 86 | * has disassociated its state and bhv_desc_t from the vnode. |
| 87 | */ |
| 88 | #define VN_INACTIVE_CACHE 0 |
| 89 | #define VN_INACTIVE_NOCACHE 1 |
| 90 | |
| 91 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | * Flags for read/write calls - same values as IRIX |
| 93 | */ |
| 94 | #define IO_ISAIO 0x00001 /* don't wait for completion */ |
| 95 | #define IO_ISDIRECT 0x00004 /* bypass page cache */ |
| 96 | #define IO_INVIS 0x00020 /* don't update inode timestamps */ |
| 97 | |
| 98 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 99 | * Flags for vop_iflush call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | */ |
| 101 | #define FLUSH_SYNC 1 /* wait for flush to complete */ |
| 102 | #define FLUSH_INODE 2 /* flush the inode itself */ |
| 103 | #define FLUSH_LOG 4 /* force the last log entry for |
| 104 | * this inode out to disk */ |
| 105 | |
| 106 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 107 | * Flush/Invalidate options for vop_toss/flush/flushinval_pages. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | */ |
| 109 | #define FI_NONE 0 /* none */ |
| 110 | #define FI_REMAPF 1 /* Do a remapf prior to the operation */ |
| 111 | #define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation. |
| 112 | Prevent VM access to the pages until |
| 113 | the operation completes. */ |
| 114 | |
| 115 | /* |
| 116 | * Vnode attributes. va_mask indicates those attributes the caller |
| 117 | * wants to set or extract. |
| 118 | */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 119 | typedef struct bhv_vattr { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | int va_mask; /* bit-mask of attributes present */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | mode_t va_mode; /* file access mode and type */ |
Nathan Scott | 31b084a | 2005-05-05 13:25:00 -0700 | [diff] [blame] | 122 | xfs_nlink_t va_nlink; /* number of references to file */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | uid_t va_uid; /* owner user id */ |
| 124 | gid_t va_gid; /* owner group id */ |
| 125 | xfs_ino_t va_nodeid; /* file id */ |
| 126 | xfs_off_t va_size; /* file size in bytes */ |
| 127 | u_long va_blocksize; /* blocksize preferred for i/o */ |
| 128 | struct timespec va_atime; /* time of last access */ |
| 129 | struct timespec va_mtime; /* time of last modification */ |
| 130 | struct timespec va_ctime; /* time file changed */ |
| 131 | u_int va_gen; /* generation number of file */ |
| 132 | xfs_dev_t va_rdev; /* device the special file represents */ |
| 133 | __int64_t va_nblocks; /* number of blocks allocated */ |
| 134 | u_long va_xflags; /* random extended file flags */ |
| 135 | u_long va_extsize; /* file extent size */ |
| 136 | u_long va_nextents; /* number of extents in file */ |
| 137 | u_long va_anextents; /* number of attr extents in file */ |
Nathan Scott | b74e215 | 2005-06-21 13:21:49 +1000 | [diff] [blame] | 138 | prid_t va_projid; /* project id */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 139 | } bhv_vattr_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | /* |
| 142 | * setattr or getattr attributes |
| 143 | */ |
| 144 | #define XFS_AT_TYPE 0x00000001 |
| 145 | #define XFS_AT_MODE 0x00000002 |
| 146 | #define XFS_AT_UID 0x00000004 |
| 147 | #define XFS_AT_GID 0x00000008 |
| 148 | #define XFS_AT_FSID 0x00000010 |
| 149 | #define XFS_AT_NODEID 0x00000020 |
| 150 | #define XFS_AT_NLINK 0x00000040 |
| 151 | #define XFS_AT_SIZE 0x00000080 |
| 152 | #define XFS_AT_ATIME 0x00000100 |
| 153 | #define XFS_AT_MTIME 0x00000200 |
| 154 | #define XFS_AT_CTIME 0x00000400 |
| 155 | #define XFS_AT_RDEV 0x00000800 |
| 156 | #define XFS_AT_BLKSIZE 0x00001000 |
| 157 | #define XFS_AT_NBLOCKS 0x00002000 |
| 158 | #define XFS_AT_VCODE 0x00004000 |
| 159 | #define XFS_AT_MAC 0x00008000 |
| 160 | #define XFS_AT_UPDATIME 0x00010000 |
| 161 | #define XFS_AT_UPDMTIME 0x00020000 |
| 162 | #define XFS_AT_UPDCTIME 0x00040000 |
| 163 | #define XFS_AT_ACL 0x00080000 |
| 164 | #define XFS_AT_CAP 0x00100000 |
| 165 | #define XFS_AT_INF 0x00200000 |
| 166 | #define XFS_AT_XFLAGS 0x00400000 |
| 167 | #define XFS_AT_EXTSIZE 0x00800000 |
| 168 | #define XFS_AT_NEXTENTS 0x01000000 |
| 169 | #define XFS_AT_ANEXTENTS 0x02000000 |
| 170 | #define XFS_AT_PROJID 0x04000000 |
| 171 | #define XFS_AT_SIZE_NOPERM 0x08000000 |
| 172 | #define XFS_AT_GENCOUNT 0x10000000 |
| 173 | |
| 174 | #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\ |
| 175 | XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\ |
| 176 | XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\ |
| 177 | XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\ |
| 178 | XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\ |
| 179 | XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT) |
| 180 | |
| 181 | #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\ |
| 182 | XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\ |
| 183 | XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\ |
| 184 | XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID) |
| 185 | |
| 186 | #define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME) |
| 187 | |
| 188 | #define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME) |
| 189 | |
| 190 | #define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\ |
| 191 | XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\ |
| 192 | XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT) |
| 193 | |
| 194 | /* |
| 195 | * Modes. |
| 196 | */ |
| 197 | #define VSUID S_ISUID /* set user id on execution */ |
| 198 | #define VSGID S_ISGID /* set group id on execution */ |
| 199 | #define VSVTX S_ISVTX /* save swapped text even after use */ |
| 200 | #define VREAD S_IRUSR /* read, write, execute permissions */ |
| 201 | #define VWRITE S_IWUSR |
| 202 | #define VEXEC S_IXUSR |
| 203 | |
| 204 | #define MODEMASK S_IALLUGO /* mode bits plus permission bits */ |
| 205 | |
| 206 | /* |
| 207 | * Check whether mandatory file locking is enabled. |
| 208 | */ |
| 209 | #define MANDLOCK(vp, mode) \ |
Christoph Hellwig | 0432dab | 2005-09-02 16:46:51 +1000 | [diff] [blame] | 210 | (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
| 212 | extern void vn_init(void); |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 213 | extern bhv_vnode_t *vn_initialize(struct inode *); |
| 214 | extern int vn_revalidate(struct bhv_vnode *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 215 | extern int __vn_revalidate(struct bhv_vnode *, bhv_vattr_t *); |
| 216 | extern void vn_revalidate_core(struct bhv_vnode *, bhv_vattr_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 218 | extern void vn_iowait(struct bhv_vnode *vp); |
| 219 | extern void vn_iowake(struct bhv_vnode *vp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 221 | extern void vn_ioerror(struct bhv_vnode *vp, int error, char *f, int l); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 223 | static inline int vn_count(struct bhv_vnode *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 225 | return atomic_read(&vn_to_inode(vp)->i_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | /* |
| 229 | * Vnode reference counting functions (and macros for compatibility). |
| 230 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 231 | extern bhv_vnode_t *vn_hold(struct bhv_vnode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
| 233 | #if defined(XFS_VNODE_TRACE) |
| 234 | #define VN_HOLD(vp) \ |
| 235 | ((void)vn_hold(vp), \ |
| 236 | vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address)) |
| 237 | #define VN_RELE(vp) \ |
| 238 | (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \ |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 239 | iput(vn_to_inode(vp))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | #else |
| 241 | #define VN_HOLD(vp) ((void)vn_hold(vp)) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 242 | #define VN_RELE(vp) (iput(vn_to_inode(vp))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | #endif |
| 244 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 245 | static inline struct bhv_vnode *vn_grab(struct bhv_vnode *vp) |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 246 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 247 | struct inode *inode = igrab(vn_to_inode(vp)); |
| 248 | return inode ? vn_from_inode(inode) : NULL; |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 249 | } |
| 250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | /* |
| 252 | * Vname handling macros. |
| 253 | */ |
| 254 | #define VNAME(dentry) ((char *) (dentry)->d_name.name) |
| 255 | #define VNAMELEN(dentry) ((dentry)->d_name.len) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 256 | #define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
| 258 | /* |
| 259 | * Vnode spinlock manipulation. |
| 260 | */ |
| 261 | #define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock) |
| 262 | #define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 264 | STATIC_INLINE void vn_flagset(struct bhv_vnode *vp, uint flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | { |
| 266 | spin_lock(&vp->v_lock); |
| 267 | vp->v_flag |= flag; |
| 268 | spin_unlock(&vp->v_lock); |
| 269 | } |
| 270 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 271 | STATIC_INLINE uint vn_flagclr(struct bhv_vnode *vp, uint flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | { |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 273 | uint cleared; |
| 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | spin_lock(&vp->v_lock); |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 276 | cleared = (vp->v_flag & flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | vp->v_flag &= ~flag; |
| 278 | spin_unlock(&vp->v_lock); |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 279 | return cleared; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 282 | #define VMODIFY(vp) vn_flagset(vp, VMODIFIED) |
| 283 | #define VUNMODIFY(vp) vn_flagclr(vp, VMODIFIED) |
| 284 | #define VTRUNCATE(vp) vn_flagset(vp, VTRUNCATED) |
| 285 | #define VUNTRUNCATE(vp) vn_flagclr(vp, VTRUNCATED) |
| 286 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | * Dealing with bad inodes |
| 289 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 290 | static inline void vn_mark_bad(struct bhv_vnode *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 292 | make_bad_inode(vn_to_inode(vp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 295 | static inline int VN_BAD(struct bhv_vnode *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 297 | return is_bad_inode(vn_to_inode(vp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /* |
Nathan Scott | ca5ccbf | 2006-01-11 21:03:04 +1100 | [diff] [blame] | 301 | * Extracting atime values in various formats |
| 302 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 303 | static inline void vn_atime_to_bstime(bhv_vnode_t *vp, xfs_bstime_t *bs_atime) |
Nathan Scott | ca5ccbf | 2006-01-11 21:03:04 +1100 | [diff] [blame] | 304 | { |
| 305 | bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec; |
| 306 | bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec; |
| 307 | } |
| 308 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 309 | static inline void vn_atime_to_timespec(bhv_vnode_t *vp, struct timespec *ts) |
Nathan Scott | ca5ccbf | 2006-01-11 21:03:04 +1100 | [diff] [blame] | 310 | { |
| 311 | *ts = vp->v_inode.i_atime; |
| 312 | } |
| 313 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 314 | static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt) |
Nathan Scott | ca5ccbf | 2006-01-11 21:03:04 +1100 | [diff] [blame] | 315 | { |
| 316 | *tt = vp->v_inode.i_atime.tv_sec; |
| 317 | } |
| 318 | |
| 319 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | * Some useful predicates. |
| 321 | */ |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 322 | #define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping) |
| 323 | #define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages) |
| 324 | #define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | PAGECACHE_TAG_DIRTY) |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 326 | #define VN_TRUNC(vp) ((vp)->v_flag & VTRUNCATED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | |
| 328 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 329 | * Flags to vop_setattr/getattr. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | */ |
| 331 | #define ATTR_UTIME 0x01 /* non-default utime(2) request */ |
| 332 | #define ATTR_DMI 0x08 /* invocation from a DMI function */ |
| 333 | #define ATTR_LAZY 0x80 /* set/get attributes lazily */ |
| 334 | #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ |
Dean Roehrich | 5fcbab3 | 2005-05-05 13:27:19 -0700 | [diff] [blame] | 335 | #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ |
Eric Sandeen | 1f730e3 | 2005-11-02 15:08:10 +1100 | [diff] [blame] | 336 | #define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
| 338 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 339 | * Flags to vop_fsync/reclaim. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | */ |
| 341 | #define FSYNC_NOWAIT 0 /* asynchronous flush */ |
| 342 | #define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */ |
| 343 | #define FSYNC_INVAL 0x2 /* flush and invalidate cached data */ |
| 344 | #define FSYNC_DATA 0x4 /* synchronous fsync of data only */ |
| 345 | |
| 346 | /* |
| 347 | * Tracking vnode activity. |
| 348 | */ |
| 349 | #if defined(XFS_VNODE_TRACE) |
| 350 | |
| 351 | #define VNODE_TRACE_SIZE 16 /* number of trace entries */ |
| 352 | #define VNODE_KTRACE_ENTRY 1 |
| 353 | #define VNODE_KTRACE_EXIT 2 |
| 354 | #define VNODE_KTRACE_HOLD 3 |
| 355 | #define VNODE_KTRACE_REF 4 |
| 356 | #define VNODE_KTRACE_RELE 5 |
| 357 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 358 | extern void vn_trace_entry(struct bhv_vnode *, const char *, inst_t *); |
| 359 | extern void vn_trace_exit(struct bhv_vnode *, const char *, inst_t *); |
| 360 | extern void vn_trace_hold(struct bhv_vnode *, char *, int, inst_t *); |
| 361 | extern void vn_trace_ref(struct bhv_vnode *, char *, int, inst_t *); |
| 362 | extern void vn_trace_rele(struct bhv_vnode *, char *, int, inst_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
| 364 | #define VN_TRACE(vp) \ |
| 365 | vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address) |
| 366 | #else |
| 367 | #define vn_trace_entry(a,b,c) |
| 368 | #define vn_trace_exit(a,b,c) |
| 369 | #define vn_trace_hold(a,b,c,d) |
| 370 | #define vn_trace_ref(a,b,c,d) |
| 371 | #define vn_trace_rele(a,b,c,d) |
| 372 | #define VN_TRACE(vp) |
| 373 | #endif |
| 374 | |
| 375 | #endif /* __XFS_VNODE_H__ */ |