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 | |
| 21 | struct uio; |
| 22 | struct file; |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 23 | struct bhv_vfs; |
| 24 | struct bhv_vattr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | struct xfs_iomap; |
| 26 | struct attrlist_cursor_kern; |
| 27 | |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 28 | typedef struct dentry bhv_vname_t; |
| 29 | typedef __u64 bhv_vnumber_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 31 | typedef enum bhv_vflags { |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 32 | VMODIFIED = 0x08, /* XFS inode state possibly differs */ |
| 33 | /* to the Linux inode state. */ |
| 34 | VTRUNCATED = 0x40, /* truncated down so flush-on-close */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 35 | } bhv_vflags_t; |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | /* |
| 38 | * MP locking protocols: |
| 39 | * v_flag, v_vfsp VN_LOCK/VN_UNLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 41 | typedef struct bhv_vnode { |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 42 | bhv_vflags_t v_flag; /* vnode flags (see above) */ |
| 43 | bhv_vfs_t *v_vfsp; /* ptr to containing VFS */ |
| 44 | bhv_vnumber_t v_number; /* in-core vnode number */ |
| 45 | bhv_head_t v_bh; /* behavior head */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */ |
Christoph Hellwig | 51c91ed5 | 2005-09-02 16:58:38 +1000 | [diff] [blame] | 47 | atomic_t v_iocount; /* outstanding I/O count */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #ifdef XFS_VNODE_TRACE |
| 49 | struct ktrace *v_trace; /* trace header structure */ |
| 50 | #endif |
Eric Sandeen | 9effd8e | 2005-05-05 13:26:18 -0700 | [diff] [blame] | 51 | struct inode v_inode; /* Linux inode */ |
| 52 | /* inode MUST be last */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 53 | } bhv_vnode_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Christoph Hellwig | 0432dab | 2005-09-02 16:46:51 +1000 | [diff] [blame] | 55 | #define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode) |
| 56 | #define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode) |
| 57 | #define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode) |
| 58 | #define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode) |
| 59 | #define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode) |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */ |
| 62 | #define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */ |
| 63 | #define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */ |
| 64 | |
| 65 | typedef enum { |
| 66 | VN_BHV_UNKNOWN, /* not specified */ |
| 67 | VN_BHV_XFS, /* xfs */ |
| 68 | VN_BHV_DM, /* data migration */ |
| 69 | VN_BHV_QM, /* quota manager */ |
| 70 | VN_BHV_IO, /* IO path */ |
| 71 | VN_BHV_END /* housekeeping end-of-range */ |
| 72 | } vn_bhv_t; |
| 73 | |
| 74 | #define VNODE_POSITION_XFS (VNODE_POSITION_BASE) |
| 75 | #define VNODE_POSITION_DM (VNODE_POSITION_BASE+10) |
| 76 | #define VNODE_POSITION_QM (VNODE_POSITION_BASE+20) |
| 77 | #define VNODE_POSITION_IO (VNODE_POSITION_BASE+30) |
| 78 | |
| 79 | /* |
| 80 | * Macros for dealing with the behavior descriptor inside of the vnode. |
| 81 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 82 | #define BHV_TO_VNODE(bdp) ((bhv_vnode_t *)BHV_VOBJ(bdp)) |
| 83 | #define BHV_TO_VNODE_NULL(bdp) ((bhv_vnode_t *)BHV_VOBJNULL(bdp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | #define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh))) |
| 86 | #define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name) |
| 87 | #define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp) |
| 88 | #define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops) |
| 89 | #define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops) |
| 90 | |
| 91 | /* |
| 92 | * Vnode to Linux inode mapping. |
| 93 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 94 | static inline struct bhv_vnode *vn_from_inode(struct inode *inode) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 95 | { |
Alexey Dobriyan | 71306f3 | 2006-06-27 14:10:29 +1000 | [diff] [blame^] | 96 | return container_of(inode, bhv_vnode_t, v_inode); |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 97 | } |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 98 | static inline struct inode *vn_to_inode(struct bhv_vnode *vnode) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 99 | { |
| 100 | return &vnode->v_inode; |
| 101 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 104 | * Values for the vop_rwlock/rwunlock flags parameter. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 106 | typedef enum bhv_vrwlock { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | VRWLOCK_NONE, |
| 108 | VRWLOCK_READ, |
| 109 | VRWLOCK_WRITE, |
| 110 | VRWLOCK_WRITE_DIRECT, |
| 111 | VRWLOCK_TRY_READ, |
| 112 | VRWLOCK_TRY_WRITE |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 113 | } bhv_vrwlock_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 116 | * Return values for bhv_vop_inactive. A return value of |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | * VN_INACTIVE_NOCACHE implies that the file system behavior |
| 118 | * has disassociated its state and bhv_desc_t from the vnode. |
| 119 | */ |
| 120 | #define VN_INACTIVE_CACHE 0 |
| 121 | #define VN_INACTIVE_NOCACHE 1 |
| 122 | |
| 123 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 124 | * Values for the cmd code given to vop_vnode_change. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 126 | typedef enum bhv_vchange { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | VCHANGE_FLAGS_FRLOCKS = 0, |
| 128 | VCHANGE_FLAGS_ENF_LOCKING = 1, |
| 129 | VCHANGE_FLAGS_TRUNCATED = 2, |
| 130 | VCHANGE_FLAGS_PAGE_DIRTY = 3, |
| 131 | VCHANGE_FLAGS_IOEXCL_COUNT = 4 |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 132 | } bhv_vchange_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 134 | typedef enum { L_FALSE, L_TRUE } lastclose_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | typedef int (*vop_open_t)(bhv_desc_t *, struct cred *); |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 137 | typedef int (*vop_close_t)(bhv_desc_t *, int, lastclose_t, struct cred *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *, |
| 139 | const struct iovec *, unsigned int, |
| 140 | loff_t *, int, struct cred *); |
| 141 | typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct kiocb *, |
| 142 | const struct iovec *, unsigned int, |
| 143 | loff_t *, int, struct cred *); |
| 144 | typedef ssize_t (*vop_sendfile_t)(bhv_desc_t *, struct file *, |
| 145 | loff_t *, int, size_t, read_actor_t, |
| 146 | void *, struct cred *); |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 147 | typedef ssize_t (*vop_splice_read_t)(bhv_desc_t *, struct file *, loff_t *, |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 148 | struct pipe_inode_info *, size_t, int, int, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 149 | struct cred *); |
Ingo Molnar | 3a326a2 | 2006-04-10 15:18:35 +0200 | [diff] [blame] | 150 | typedef ssize_t (*vop_splice_write_t)(bhv_desc_t *, struct pipe_inode_info *, |
Jens Axboe | cbb7e57 | 2006-04-11 14:57:50 +0200 | [diff] [blame] | 151 | struct file *, loff_t *, size_t, int, int, |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 152 | struct cred *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | typedef int (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *, |
| 154 | int, unsigned int, void __user *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 155 | typedef int (*vop_getattr_t)(bhv_desc_t *, struct bhv_vattr *, int, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | struct cred *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 157 | typedef int (*vop_setattr_t)(bhv_desc_t *, struct bhv_vattr *, int, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | struct cred *); |
| 159 | typedef int (*vop_access_t)(bhv_desc_t *, int, struct cred *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 160 | typedef int (*vop_lookup_t)(bhv_desc_t *, bhv_vname_t *, bhv_vnode_t **, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 161 | int, bhv_vnode_t *, struct cred *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 162 | typedef int (*vop_create_t)(bhv_desc_t *, bhv_vname_t *, struct bhv_vattr *, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 163 | bhv_vnode_t **, struct cred *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 164 | typedef int (*vop_remove_t)(bhv_desc_t *, bhv_vname_t *, struct cred *); |
| 165 | typedef int (*vop_link_t)(bhv_desc_t *, bhv_vnode_t *, bhv_vname_t *, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | struct cred *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 167 | typedef int (*vop_rename_t)(bhv_desc_t *, bhv_vname_t *, bhv_vnode_t *, |
| 168 | bhv_vname_t *, struct cred *); |
| 169 | typedef int (*vop_mkdir_t)(bhv_desc_t *, bhv_vname_t *, struct bhv_vattr *, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 170 | bhv_vnode_t **, struct cred *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 171 | typedef int (*vop_rmdir_t)(bhv_desc_t *, bhv_vname_t *, struct cred *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | typedef int (*vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *, |
| 173 | int *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 174 | typedef int (*vop_symlink_t)(bhv_desc_t *, bhv_vname_t *, struct bhv_vattr*, |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 175 | char *, bhv_vnode_t **, struct cred *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | typedef int (*vop_readlink_t)(bhv_desc_t *, struct uio *, int, |
| 177 | struct cred *); |
| 178 | typedef int (*vop_fsync_t)(bhv_desc_t *, int, struct cred *, |
| 179 | xfs_off_t, xfs_off_t); |
| 180 | typedef int (*vop_inactive_t)(bhv_desc_t *, struct cred *); |
| 181 | typedef int (*vop_fid2_t)(bhv_desc_t *, struct fid *); |
| 182 | typedef int (*vop_release_t)(bhv_desc_t *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 183 | typedef int (*vop_rwlock_t)(bhv_desc_t *, bhv_vrwlock_t); |
| 184 | typedef void (*vop_rwunlock_t)(bhv_desc_t *, bhv_vrwlock_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, |
| 186 | struct xfs_iomap *, int *); |
| 187 | typedef int (*vop_reclaim_t)(bhv_desc_t *); |
Nathan Scott | 80cce77 | 2005-11-02 11:43:04 +1100 | [diff] [blame] | 188 | typedef int (*vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *, |
| 189 | int, struct cred *); |
| 190 | typedef int (*vop_attr_set_t)(bhv_desc_t *, const char *, char *, int, |
| 191 | int, struct cred *); |
| 192 | typedef int (*vop_attr_remove_t)(bhv_desc_t *, const char *, |
| 193 | int, struct cred *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, |
| 195 | struct attrlist_cursor_kern *, struct cred *); |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 196 | typedef void (*vop_link_removed_t)(bhv_desc_t *, bhv_vnode_t *, int); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 197 | typedef void (*vop_vnode_change_t)(bhv_desc_t *, bhv_vchange_t, __psint_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
| 199 | typedef void (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
| 200 | typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, |
| 201 | uint64_t, int); |
| 202 | typedef int (*vop_iflush_t)(bhv_desc_t *, int); |
| 203 | |
| 204 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 205 | typedef struct bhv_vnodeops { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | bhv_position_t vn_position; /* position within behavior chain */ |
| 207 | vop_open_t vop_open; |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 208 | vop_close_t vop_close; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | vop_read_t vop_read; |
| 210 | vop_write_t vop_write; |
| 211 | vop_sendfile_t vop_sendfile; |
Nathan Scott | 1b89584 | 2006-03-31 13:08:59 +1000 | [diff] [blame] | 212 | vop_splice_read_t vop_splice_read; |
| 213 | vop_splice_write_t vop_splice_write; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | vop_ioctl_t vop_ioctl; |
| 215 | vop_getattr_t vop_getattr; |
| 216 | vop_setattr_t vop_setattr; |
| 217 | vop_access_t vop_access; |
| 218 | vop_lookup_t vop_lookup; |
| 219 | vop_create_t vop_create; |
| 220 | vop_remove_t vop_remove; |
| 221 | vop_link_t vop_link; |
| 222 | vop_rename_t vop_rename; |
| 223 | vop_mkdir_t vop_mkdir; |
| 224 | vop_rmdir_t vop_rmdir; |
| 225 | vop_readdir_t vop_readdir; |
| 226 | vop_symlink_t vop_symlink; |
| 227 | vop_readlink_t vop_readlink; |
| 228 | vop_fsync_t vop_fsync; |
| 229 | vop_inactive_t vop_inactive; |
| 230 | vop_fid2_t vop_fid2; |
| 231 | vop_rwlock_t vop_rwlock; |
| 232 | vop_rwunlock_t vop_rwunlock; |
| 233 | vop_bmap_t vop_bmap; |
| 234 | vop_reclaim_t vop_reclaim; |
| 235 | vop_attr_get_t vop_attr_get; |
| 236 | vop_attr_set_t vop_attr_set; |
| 237 | vop_attr_remove_t vop_attr_remove; |
| 238 | vop_attr_list_t vop_attr_list; |
| 239 | vop_link_removed_t vop_link_removed; |
| 240 | vop_vnode_change_t vop_vnode_change; |
| 241 | vop_ptossvp_t vop_tosspages; |
| 242 | vop_pflushinvalvp_t vop_flushinval_pages; |
| 243 | vop_pflushvp_t vop_flush_pages; |
| 244 | vop_release_t vop_release; |
| 245 | vop_iflush_t vop_iflush; |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 246 | } bhv_vnodeops_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
| 248 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 249 | * Virtual node operations, operating from head bhv. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 251 | #define VNHEAD(vp) ((vp)->v_bh.bh_first) |
| 252 | #define VOP(op, vp) (*((bhv_vnodeops_t *)VNHEAD(vp)->bd_ops)->op) |
| 253 | #define bhv_vop_open(vp, cr) VOP(vop_open, vp)(VNHEAD(vp),cr) |
| 254 | #define bhv_vop_close(vp, f,last,cr) VOP(vop_close, vp)(VNHEAD(vp),f,last,cr) |
| 255 | #define bhv_vop_read(vp,file,iov,segs,offset,ioflags,cr) \ |
| 256 | VOP(vop_read, vp)(VNHEAD(vp),file,iov,segs,offset,ioflags,cr) |
| 257 | #define bhv_vop_write(vp,file,iov,segs,offset,ioflags,cr) \ |
| 258 | VOP(vop_write, vp)(VNHEAD(vp),file,iov,segs,offset,ioflags,cr) |
| 259 | #define bhv_vop_sendfile(vp,f,off,ioflags,cnt,act,targ,cr) \ |
| 260 | VOP(vop_sendfile, vp)(VNHEAD(vp),f,off,ioflags,cnt,act,targ,cr) |
| 261 | #define bhv_vop_splice_read(vp,f,o,pipe,cnt,fl,iofl,cr) \ |
| 262 | VOP(vop_splice_read, vp)(VNHEAD(vp),f,o,pipe,cnt,fl,iofl,cr) |
| 263 | #define bhv_vop_splice_write(vp,f,o,pipe,cnt,fl,iofl,cr) \ |
| 264 | VOP(vop_splice_write, vp)(VNHEAD(vp),f,o,pipe,cnt,fl,iofl,cr) |
| 265 | #define bhv_vop_bmap(vp,of,sz,rw,b,n) \ |
| 266 | VOP(vop_bmap, vp)(VNHEAD(vp),of,sz,rw,b,n) |
| 267 | #define bhv_vop_getattr(vp, vap,f,cr) \ |
| 268 | VOP(vop_getattr, vp)(VNHEAD(vp), vap,f,cr) |
| 269 | #define bhv_vop_setattr(vp, vap,f,cr) \ |
| 270 | VOP(vop_setattr, vp)(VNHEAD(vp), vap,f,cr) |
| 271 | #define bhv_vop_access(vp, mode,cr) VOP(vop_access, vp)(VNHEAD(vp), mode,cr) |
| 272 | #define bhv_vop_lookup(vp,d,vpp,f,rdir,cr) \ |
| 273 | VOP(vop_lookup, vp)(VNHEAD(vp),d,vpp,f,rdir,cr) |
| 274 | #define bhv_vop_create(dvp,d,vap,vpp,cr) \ |
| 275 | VOP(vop_create, dvp)(VNHEAD(dvp),d,vap,vpp,cr) |
| 276 | #define bhv_vop_remove(dvp,d,cr) VOP(vop_remove, dvp)(VNHEAD(dvp),d,cr) |
| 277 | #define bhv_vop_link(dvp,fvp,d,cr) VOP(vop_link, dvp)(VNHEAD(dvp),fvp,d,cr) |
| 278 | #define bhv_vop_rename(fvp,fnm,tdvp,tnm,cr) \ |
| 279 | VOP(vop_rename, fvp)(VNHEAD(fvp),fnm,tdvp,tnm,cr) |
| 280 | #define bhv_vop_mkdir(dp,d,vap,vpp,cr) \ |
| 281 | VOP(vop_mkdir, dp)(VNHEAD(dp),d,vap,vpp,cr) |
| 282 | #define bhv_vop_rmdir(dp,d,cr) VOP(vop_rmdir, dp)(VNHEAD(dp),d,cr) |
| 283 | #define bhv_vop_readdir(vp,uiop,cr,eofp) \ |
| 284 | VOP(vop_readdir, vp)(VNHEAD(vp),uiop,cr,eofp) |
| 285 | #define bhv_vop_symlink(dvp,d,vap,tnm,vpp,cr) \ |
| 286 | VOP(vop_symlink, dvp)(VNHEAD(dvp),d,vap,tnm,vpp,cr) |
| 287 | #define bhv_vop_readlink(vp,uiop,fl,cr) \ |
| 288 | VOP(vop_readlink, vp)(VNHEAD(vp),uiop,fl,cr) |
| 289 | #define bhv_vop_fsync(vp,f,cr,b,e) VOP(vop_fsync, vp)(VNHEAD(vp),f,cr,b,e) |
| 290 | #define bhv_vop_inactive(vp,cr) VOP(vop_inactive, vp)(VNHEAD(vp),cr) |
| 291 | #define bhv_vop_release(vp) VOP(vop_release, vp)(VNHEAD(vp)) |
| 292 | #define bhv_vop_fid2(vp,fidp) VOP(vop_fid2, vp)(VNHEAD(vp),fidp) |
| 293 | #define bhv_vop_rwlock(vp,i) VOP(vop_rwlock, vp)(VNHEAD(vp),i) |
| 294 | #define bhv_vop_rwlock_try(vp,i) VOP(vop_rwlock, vp)(VNHEAD(vp),i) |
| 295 | #define bhv_vop_rwunlock(vp,i) VOP(vop_rwunlock, vp)(VNHEAD(vp),i) |
| 296 | #define bhv_vop_frlock(vp,c,fl,flags,offset,fr) \ |
| 297 | VOP(vop_frlock, vp)(VNHEAD(vp),c,fl,flags,offset,fr) |
| 298 | #define bhv_vop_reclaim(vp) VOP(vop_reclaim, vp)(VNHEAD(vp)) |
| 299 | #define bhv_vop_attr_get(vp, name, val, vallenp, fl, cred) \ |
| 300 | VOP(vop_attr_get, vp)(VNHEAD(vp),name,val,vallenp,fl,cred) |
| 301 | #define bhv_vop_attr_set(vp, name, val, vallen, fl, cred) \ |
| 302 | VOP(vop_attr_set, vp)(VNHEAD(vp),name,val,vallen,fl,cred) |
| 303 | #define bhv_vop_attr_remove(vp, name, flags, cred) \ |
| 304 | VOP(vop_attr_remove, vp)(VNHEAD(vp),name,flags,cred) |
| 305 | #define bhv_vop_attr_list(vp, buf, buflen, fl, cursor, cred) \ |
| 306 | VOP(vop_attr_list, vp)(VNHEAD(vp),buf,buflen,fl,cursor,cred) |
| 307 | #define bhv_vop_link_removed(vp, dvp, linkzero) \ |
| 308 | VOP(vop_link_removed, vp)(VNHEAD(vp), dvp, linkzero) |
| 309 | #define bhv_vop_vnode_change(vp, cmd, val) \ |
| 310 | VOP(vop_vnode_change, vp)(VNHEAD(vp), cmd, val) |
| 311 | #define bhv_vop_toss_pages(vp, first, last, fiopt) \ |
| 312 | VOP(vop_tosspages, vp)(VNHEAD(vp), first, last, fiopt) |
| 313 | #define bhv_vop_flushinval_pages(vp, first, last, fiopt) \ |
| 314 | VOP(vop_flushinval_pages, vp)(VNHEAD(vp),first,last,fiopt) |
| 315 | #define bhv_vop_flush_pages(vp, first, last, flags, fiopt) \ |
| 316 | VOP(vop_flush_pages, vp)(VNHEAD(vp),first,last,flags,fiopt) |
| 317 | #define bhv_vop_ioctl(vp, inode, filp, fl, cmd, arg) \ |
| 318 | VOP(vop_ioctl, vp)(VNHEAD(vp),inode,filp,fl,cmd,arg) |
| 319 | #define bhv_vop_iflush(vp, flags) VOP(vop_iflush, vp)(VNHEAD(vp), flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | |
| 321 | /* |
| 322 | * Flags for read/write calls - same values as IRIX |
| 323 | */ |
| 324 | #define IO_ISAIO 0x00001 /* don't wait for completion */ |
| 325 | #define IO_ISDIRECT 0x00004 /* bypass page cache */ |
| 326 | #define IO_INVIS 0x00020 /* don't update inode timestamps */ |
| 327 | |
| 328 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 329 | * Flags for vop_iflush call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | */ |
| 331 | #define FLUSH_SYNC 1 /* wait for flush to complete */ |
| 332 | #define FLUSH_INODE 2 /* flush the inode itself */ |
| 333 | #define FLUSH_LOG 4 /* force the last log entry for |
| 334 | * this inode out to disk */ |
| 335 | |
| 336 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 337 | * Flush/Invalidate options for vop_toss/flush/flushinval_pages. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | */ |
| 339 | #define FI_NONE 0 /* none */ |
| 340 | #define FI_REMAPF 1 /* Do a remapf prior to the operation */ |
| 341 | #define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation. |
| 342 | Prevent VM access to the pages until |
| 343 | the operation completes. */ |
| 344 | |
| 345 | /* |
| 346 | * Vnode attributes. va_mask indicates those attributes the caller |
| 347 | * wants to set or extract. |
| 348 | */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 349 | typedef struct bhv_vattr { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | int va_mask; /* bit-mask of attributes present */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | mode_t va_mode; /* file access mode and type */ |
Nathan Scott | 31b084a | 2005-05-05 13:25:00 -0700 | [diff] [blame] | 352 | xfs_nlink_t va_nlink; /* number of references to file */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | uid_t va_uid; /* owner user id */ |
| 354 | gid_t va_gid; /* owner group id */ |
| 355 | xfs_ino_t va_nodeid; /* file id */ |
| 356 | xfs_off_t va_size; /* file size in bytes */ |
| 357 | u_long va_blocksize; /* blocksize preferred for i/o */ |
| 358 | struct timespec va_atime; /* time of last access */ |
| 359 | struct timespec va_mtime; /* time of last modification */ |
| 360 | struct timespec va_ctime; /* time file changed */ |
| 361 | u_int va_gen; /* generation number of file */ |
| 362 | xfs_dev_t va_rdev; /* device the special file represents */ |
| 363 | __int64_t va_nblocks; /* number of blocks allocated */ |
| 364 | u_long va_xflags; /* random extended file flags */ |
| 365 | u_long va_extsize; /* file extent size */ |
| 366 | u_long va_nextents; /* number of extents in file */ |
| 367 | u_long va_anextents; /* number of attr extents in file */ |
Nathan Scott | b74e215 | 2005-06-21 13:21:49 +1000 | [diff] [blame] | 368 | prid_t va_projid; /* project id */ |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 369 | } bhv_vattr_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
| 371 | /* |
| 372 | * setattr or getattr attributes |
| 373 | */ |
| 374 | #define XFS_AT_TYPE 0x00000001 |
| 375 | #define XFS_AT_MODE 0x00000002 |
| 376 | #define XFS_AT_UID 0x00000004 |
| 377 | #define XFS_AT_GID 0x00000008 |
| 378 | #define XFS_AT_FSID 0x00000010 |
| 379 | #define XFS_AT_NODEID 0x00000020 |
| 380 | #define XFS_AT_NLINK 0x00000040 |
| 381 | #define XFS_AT_SIZE 0x00000080 |
| 382 | #define XFS_AT_ATIME 0x00000100 |
| 383 | #define XFS_AT_MTIME 0x00000200 |
| 384 | #define XFS_AT_CTIME 0x00000400 |
| 385 | #define XFS_AT_RDEV 0x00000800 |
| 386 | #define XFS_AT_BLKSIZE 0x00001000 |
| 387 | #define XFS_AT_NBLOCKS 0x00002000 |
| 388 | #define XFS_AT_VCODE 0x00004000 |
| 389 | #define XFS_AT_MAC 0x00008000 |
| 390 | #define XFS_AT_UPDATIME 0x00010000 |
| 391 | #define XFS_AT_UPDMTIME 0x00020000 |
| 392 | #define XFS_AT_UPDCTIME 0x00040000 |
| 393 | #define XFS_AT_ACL 0x00080000 |
| 394 | #define XFS_AT_CAP 0x00100000 |
| 395 | #define XFS_AT_INF 0x00200000 |
| 396 | #define XFS_AT_XFLAGS 0x00400000 |
| 397 | #define XFS_AT_EXTSIZE 0x00800000 |
| 398 | #define XFS_AT_NEXTENTS 0x01000000 |
| 399 | #define XFS_AT_ANEXTENTS 0x02000000 |
| 400 | #define XFS_AT_PROJID 0x04000000 |
| 401 | #define XFS_AT_SIZE_NOPERM 0x08000000 |
| 402 | #define XFS_AT_GENCOUNT 0x10000000 |
| 403 | |
| 404 | #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\ |
| 405 | XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\ |
| 406 | XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\ |
| 407 | XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\ |
| 408 | XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\ |
| 409 | XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT) |
| 410 | |
| 411 | #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\ |
| 412 | XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\ |
| 413 | XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\ |
| 414 | XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID) |
| 415 | |
| 416 | #define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME) |
| 417 | |
| 418 | #define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME) |
| 419 | |
| 420 | #define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\ |
| 421 | XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\ |
| 422 | XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT) |
| 423 | |
| 424 | /* |
| 425 | * Modes. |
| 426 | */ |
| 427 | #define VSUID S_ISUID /* set user id on execution */ |
| 428 | #define VSGID S_ISGID /* set group id on execution */ |
| 429 | #define VSVTX S_ISVTX /* save swapped text even after use */ |
| 430 | #define VREAD S_IRUSR /* read, write, execute permissions */ |
| 431 | #define VWRITE S_IWUSR |
| 432 | #define VEXEC S_IXUSR |
| 433 | |
| 434 | #define MODEMASK S_IALLUGO /* mode bits plus permission bits */ |
| 435 | |
| 436 | /* |
| 437 | * Check whether mandatory file locking is enabled. |
| 438 | */ |
| 439 | #define MANDLOCK(vp, mode) \ |
Christoph Hellwig | 0432dab | 2005-09-02 16:46:51 +1000 | [diff] [blame] | 440 | (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
| 442 | extern void vn_init(void); |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 443 | extern bhv_vnode_t *vn_initialize(struct inode *); |
| 444 | extern int vn_revalidate(struct bhv_vnode *); |
Nathan Scott | 8285fb5 | 2006-06-09 17:07:12 +1000 | [diff] [blame] | 445 | extern int __vn_revalidate(struct bhv_vnode *, bhv_vattr_t *); |
| 446 | extern void vn_revalidate_core(struct bhv_vnode *, bhv_vattr_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 448 | extern void vn_iowait(struct bhv_vnode *vp); |
| 449 | extern void vn_iowake(struct bhv_vnode *vp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 451 | 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] | 452 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 453 | static inline int vn_count(struct bhv_vnode *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 455 | return atomic_read(&vn_to_inode(vp)->i_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | /* |
| 459 | * Vnode reference counting functions (and macros for compatibility). |
| 460 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 461 | extern bhv_vnode_t *vn_hold(struct bhv_vnode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | |
| 463 | #if defined(XFS_VNODE_TRACE) |
| 464 | #define VN_HOLD(vp) \ |
| 465 | ((void)vn_hold(vp), \ |
| 466 | vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address)) |
| 467 | #define VN_RELE(vp) \ |
| 468 | (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \ |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 469 | iput(vn_to_inode(vp))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | #else |
| 471 | #define VN_HOLD(vp) ((void)vn_hold(vp)) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 472 | #define VN_RELE(vp) (iput(vn_to_inode(vp))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | #endif |
| 474 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 475 | static inline struct bhv_vnode *vn_grab(struct bhv_vnode *vp) |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 476 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 477 | struct inode *inode = igrab(vn_to_inode(vp)); |
| 478 | return inode ? vn_from_inode(inode) : NULL; |
Christoph Hellwig | cdb6268 | 2005-09-02 16:24:19 +1000 | [diff] [blame] | 479 | } |
| 480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | /* |
| 482 | * Vname handling macros. |
| 483 | */ |
| 484 | #define VNAME(dentry) ((char *) (dentry)->d_name.name) |
| 485 | #define VNAMELEN(dentry) ((dentry)->d_name.len) |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 486 | #define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
| 488 | /* |
| 489 | * Vnode spinlock manipulation. |
| 490 | */ |
| 491 | #define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock) |
| 492 | #define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 494 | static __inline__ void vn_flagset(struct bhv_vnode *vp, uint flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | { |
| 496 | spin_lock(&vp->v_lock); |
| 497 | vp->v_flag |= flag; |
| 498 | spin_unlock(&vp->v_lock); |
| 499 | } |
| 500 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 501 | static __inline__ uint vn_flagclr(struct bhv_vnode *vp, uint flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | { |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 503 | uint cleared; |
| 504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | spin_lock(&vp->v_lock); |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 506 | cleared = (vp->v_flag & flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | vp->v_flag &= ~flag; |
| 508 | spin_unlock(&vp->v_lock); |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 509 | return cleared; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | } |
| 511 | |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 512 | #define VMODIFY(vp) vn_flagset(vp, VMODIFIED) |
| 513 | #define VUNMODIFY(vp) vn_flagclr(vp, VMODIFIED) |
| 514 | #define VTRUNCATE(vp) vn_flagset(vp, VTRUNCATED) |
| 515 | #define VUNTRUNCATE(vp) vn_flagclr(vp, VTRUNCATED) |
| 516 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | * Dealing with bad inodes |
| 519 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 520 | static inline void vn_mark_bad(struct bhv_vnode *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 522 | make_bad_inode(vn_to_inode(vp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 525 | static inline int VN_BAD(struct bhv_vnode *vp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | { |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 527 | return is_bad_inode(vn_to_inode(vp)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /* |
Nathan Scott | ca5ccbf | 2006-01-11 21:03:04 +1100 | [diff] [blame] | 531 | * Extracting atime values in various formats |
| 532 | */ |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 533 | 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] | 534 | { |
| 535 | bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec; |
| 536 | bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec; |
| 537 | } |
| 538 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 539 | 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] | 540 | { |
| 541 | *ts = vp->v_inode.i_atime; |
| 542 | } |
| 543 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 544 | 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] | 545 | { |
| 546 | *tt = vp->v_inode.i_atime.tv_sec; |
| 547 | } |
| 548 | |
| 549 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | * Some useful predicates. |
| 551 | */ |
Nathan Scott | ec86dc0 | 2006-03-17 17:25:36 +1100 | [diff] [blame] | 552 | #define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping) |
| 553 | #define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages) |
| 554 | #define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | PAGECACHE_TAG_DIRTY) |
Nathan Scott | 7d4fb40 | 2006-06-09 15:27:16 +1000 | [diff] [blame] | 556 | #define VN_TRUNC(vp) ((vp)->v_flag & VTRUNCATED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
| 558 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 559 | * Flags to vop_setattr/getattr. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | */ |
| 561 | #define ATTR_UTIME 0x01 /* non-default utime(2) request */ |
| 562 | #define ATTR_DMI 0x08 /* invocation from a DMI function */ |
| 563 | #define ATTR_LAZY 0x80 /* set/get attributes lazily */ |
| 564 | #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ |
Dean Roehrich | 5fcbab3 | 2005-05-05 13:27:19 -0700 | [diff] [blame] | 565 | #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ |
Eric Sandeen | 1f730e3 | 2005-11-02 15:08:10 +1100 | [diff] [blame] | 566 | #define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
| 568 | /* |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 569 | * Flags to vop_fsync/reclaim. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | */ |
| 571 | #define FSYNC_NOWAIT 0 /* asynchronous flush */ |
| 572 | #define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */ |
| 573 | #define FSYNC_INVAL 0x2 /* flush and invalidate cached data */ |
| 574 | #define FSYNC_DATA 0x4 /* synchronous fsync of data only */ |
| 575 | |
| 576 | /* |
| 577 | * Tracking vnode activity. |
| 578 | */ |
| 579 | #if defined(XFS_VNODE_TRACE) |
| 580 | |
| 581 | #define VNODE_TRACE_SIZE 16 /* number of trace entries */ |
| 582 | #define VNODE_KTRACE_ENTRY 1 |
| 583 | #define VNODE_KTRACE_EXIT 2 |
| 584 | #define VNODE_KTRACE_HOLD 3 |
| 585 | #define VNODE_KTRACE_REF 4 |
| 586 | #define VNODE_KTRACE_RELE 5 |
| 587 | |
Nathan Scott | 67fcaa7 | 2006-06-09 17:00:52 +1000 | [diff] [blame] | 588 | extern void vn_trace_entry(struct bhv_vnode *, const char *, inst_t *); |
| 589 | extern void vn_trace_exit(struct bhv_vnode *, const char *, inst_t *); |
| 590 | extern void vn_trace_hold(struct bhv_vnode *, char *, int, inst_t *); |
| 591 | extern void vn_trace_ref(struct bhv_vnode *, char *, int, inst_t *); |
| 592 | extern void vn_trace_rele(struct bhv_vnode *, char *, int, inst_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
| 594 | #define VN_TRACE(vp) \ |
| 595 | vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address) |
| 596 | #else |
| 597 | #define vn_trace_entry(a,b,c) |
| 598 | #define vn_trace_exit(a,b,c) |
| 599 | #define vn_trace_hold(a,b,c,d) |
| 600 | #define vn_trace_ref(a,b,c,d) |
| 601 | #define vn_trace_rele(a,b,c,d) |
| 602 | #define VN_TRACE(vp) |
| 603 | #endif |
| 604 | |
| 605 | #endif /* __XFS_VNODE_H__ */ |