2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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
7 * published by the Free Software Foundation.
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.
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
18 * Portions Copyright (c) 1989, 1993
19 * The Regents of the University of California. All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * 3. Neither the name of the University nor the names of its contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
33 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
37 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 #ifndef __XFS_VNODE_H__
46 #define __XFS_VNODE_H__
52 struct attrlist_cursor_kern;
55 typedef xfs_ino_t vnumber_t;
56 typedef struct dentry vname_t;
57 typedef bhv_head_t vn_bhv_head_t;
60 VMODIFIED = 0x08, /* XFS inode state possibly differs */
61 /* to the Linux inode state. */
62 VTRUNCATED = 0x40, /* truncated down so flush-on-close */
66 * MP locking protocols:
67 * v_flag, v_vfsp VN_LOCK/VN_UNLOCK
69 typedef struct vnode {
70 vflags_t v_flag; /* vnode flags (see above) */
71 struct vfs *v_vfsp; /* ptr to containing VFS */
72 vnumber_t v_number; /* in-core vnode number */
73 vn_bhv_head_t v_bh; /* behavior head */
74 spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */
75 atomic_t v_iocount; /* outstanding I/O count */
76 #ifdef XFS_VNODE_TRACE
77 struct ktrace *v_trace; /* trace header structure */
79 struct inode v_inode; /* Linux inode */
80 /* inode MUST be last */
83 #define VN_ISLNK(vp) S_ISLNK((vp)->v_inode.i_mode)
84 #define VN_ISREG(vp) S_ISREG((vp)->v_inode.i_mode)
85 #define VN_ISDIR(vp) S_ISDIR((vp)->v_inode.i_mode)
86 #define VN_ISCHR(vp) S_ISCHR((vp)->v_inode.i_mode)
87 #define VN_ISBLK(vp) S_ISBLK((vp)->v_inode.i_mode)
89 #define v_fbhv v_bh.bh_first /* first behavior */
90 #define v_fops v_bh.bh_first->bd_ops /* first behavior ops */
92 #define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
93 #define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */
94 #define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
97 VN_BHV_UNKNOWN, /* not specified */
99 VN_BHV_DM, /* data migration */
100 VN_BHV_QM, /* quota manager */
101 VN_BHV_IO, /* IO path */
102 VN_BHV_END /* housekeeping end-of-range */
105 #define VNODE_POSITION_XFS (VNODE_POSITION_BASE)
106 #define VNODE_POSITION_DM (VNODE_POSITION_BASE+10)
107 #define VNODE_POSITION_QM (VNODE_POSITION_BASE+20)
108 #define VNODE_POSITION_IO (VNODE_POSITION_BASE+30)
111 * Macros for dealing with the behavior descriptor inside of the vnode.
113 #define BHV_TO_VNODE(bdp) ((vnode_t *)BHV_VOBJ(bdp))
114 #define BHV_TO_VNODE_NULL(bdp) ((vnode_t *)BHV_VOBJNULL(bdp))
116 #define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh)))
117 #define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name)
118 #define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp)
119 #define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops)
120 #define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops)
123 * Vnode to Linux inode mapping.
125 static inline struct vnode *vn_from_inode(struct inode *inode)
127 return (vnode_t *)list_entry(inode, vnode_t, v_inode);
129 static inline struct inode *vn_to_inode(struct vnode *vnode)
131 return &vnode->v_inode;
135 * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter.
137 typedef enum vrwlock {
141 VRWLOCK_WRITE_DIRECT,
147 * Return values for VOP_INACTIVE. A return value of
148 * VN_INACTIVE_NOCACHE implies that the file system behavior
149 * has disassociated its state and bhv_desc_t from the vnode.
151 #define VN_INACTIVE_CACHE 0
152 #define VN_INACTIVE_NOCACHE 1
155 * Values for the cmd code given to VOP_VNODE_CHANGE.
157 typedef enum vchange {
158 VCHANGE_FLAGS_FRLOCKS = 0,
159 VCHANGE_FLAGS_ENF_LOCKING = 1,
160 VCHANGE_FLAGS_TRUNCATED = 2,
161 VCHANGE_FLAGS_PAGE_DIRTY = 3,
162 VCHANGE_FLAGS_IOEXCL_COUNT = 4
165 typedef enum { L_FALSE, L_TRUE } lastclose_t;
167 typedef int (*vop_open_t)(bhv_desc_t *, struct cred *);
168 typedef int (*vop_close_t)(bhv_desc_t *, int, lastclose_t, struct cred *);
169 typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *,
170 const struct iovec *, unsigned int,
171 loff_t *, int, struct cred *);
172 typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct kiocb *,
173 const struct iovec *, unsigned int,
174 loff_t *, int, struct cred *);
175 typedef ssize_t (*vop_sendfile_t)(bhv_desc_t *, struct file *,
176 loff_t *, int, size_t, read_actor_t,
177 void *, struct cred *);
178 typedef ssize_t (*vop_splice_read_t)(bhv_desc_t *, struct file *, loff_t *,
179 struct pipe_inode_info *, size_t, int, int,
181 typedef ssize_t (*vop_splice_write_t)(bhv_desc_t *, struct pipe_inode_info *,
182 struct file *, loff_t *, size_t, int, int,
184 typedef int (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *,
185 int, unsigned int, void __user *);
186 typedef int (*vop_getattr_t)(bhv_desc_t *, struct vattr *, int,
188 typedef int (*vop_setattr_t)(bhv_desc_t *, struct vattr *, int,
190 typedef int (*vop_access_t)(bhv_desc_t *, int, struct cred *);
191 typedef int (*vop_lookup_t)(bhv_desc_t *, vname_t *, vnode_t **,
192 int, vnode_t *, struct cred *);
193 typedef int (*vop_create_t)(bhv_desc_t *, vname_t *, struct vattr *,
194 vnode_t **, struct cred *);
195 typedef int (*vop_remove_t)(bhv_desc_t *, vname_t *, struct cred *);
196 typedef int (*vop_link_t)(bhv_desc_t *, vnode_t *, vname_t *,
198 typedef int (*vop_rename_t)(bhv_desc_t *, vname_t *, vnode_t *, vname_t *,
200 typedef int (*vop_mkdir_t)(bhv_desc_t *, vname_t *, struct vattr *,
201 vnode_t **, struct cred *);
202 typedef int (*vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *);
203 typedef int (*vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *,
205 typedef int (*vop_symlink_t)(bhv_desc_t *, vname_t *, struct vattr *,
206 char *, vnode_t **, struct cred *);
207 typedef int (*vop_readlink_t)(bhv_desc_t *, struct uio *, int,
209 typedef int (*vop_fsync_t)(bhv_desc_t *, int, struct cred *,
210 xfs_off_t, xfs_off_t);
211 typedef int (*vop_inactive_t)(bhv_desc_t *, struct cred *);
212 typedef int (*vop_fid2_t)(bhv_desc_t *, struct fid *);
213 typedef int (*vop_release_t)(bhv_desc_t *);
214 typedef int (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
215 typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
216 typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
217 struct xfs_iomap *, int *);
218 typedef int (*vop_reclaim_t)(bhv_desc_t *);
219 typedef int (*vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *,
221 typedef int (*vop_attr_set_t)(bhv_desc_t *, const char *, char *, int,
223 typedef int (*vop_attr_remove_t)(bhv_desc_t *, const char *,
225 typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
226 struct attrlist_cursor_kern *, struct cred *);
227 typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
228 typedef void (*vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t);
229 typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
230 typedef void (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
231 typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t,
233 typedef int (*vop_iflush_t)(bhv_desc_t *, int);
236 typedef struct vnodeops {
237 bhv_position_t vn_position; /* position within behavior chain */
239 vop_close_t vop_close;
241 vop_write_t vop_write;
242 vop_sendfile_t vop_sendfile;
243 vop_splice_read_t vop_splice_read;
244 vop_splice_write_t vop_splice_write;
245 vop_ioctl_t vop_ioctl;
246 vop_getattr_t vop_getattr;
247 vop_setattr_t vop_setattr;
248 vop_access_t vop_access;
249 vop_lookup_t vop_lookup;
250 vop_create_t vop_create;
251 vop_remove_t vop_remove;
253 vop_rename_t vop_rename;
254 vop_mkdir_t vop_mkdir;
255 vop_rmdir_t vop_rmdir;
256 vop_readdir_t vop_readdir;
257 vop_symlink_t vop_symlink;
258 vop_readlink_t vop_readlink;
259 vop_fsync_t vop_fsync;
260 vop_inactive_t vop_inactive;
262 vop_rwlock_t vop_rwlock;
263 vop_rwunlock_t vop_rwunlock;
265 vop_reclaim_t vop_reclaim;
266 vop_attr_get_t vop_attr_get;
267 vop_attr_set_t vop_attr_set;
268 vop_attr_remove_t vop_attr_remove;
269 vop_attr_list_t vop_attr_list;
270 vop_link_removed_t vop_link_removed;
271 vop_vnode_change_t vop_vnode_change;
272 vop_ptossvp_t vop_tosspages;
273 vop_pflushinvalvp_t vop_flushinval_pages;
274 vop_pflushvp_t vop_flush_pages;
275 vop_release_t vop_release;
276 vop_iflush_t vop_iflush;
282 #define _VOP_(op, vp) (*((vnodeops_t *)(vp)->v_fops)->op)
284 #define VOP_OPEN(vp, cr, rv) \
285 rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr)
286 #define VOP_CLOSE(vp, f, last, cr, rv) \
287 rv = _VOP_(vop_close, vp)((vp)->v_fbhv, f, last, cr)
288 #define VOP_READ(vp,file,iov,segs,offset,ioflags,cr,rv) \
289 rv = _VOP_(vop_read, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
290 #define VOP_WRITE(vp,file,iov,segs,offset,ioflags,cr,rv) \
291 rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
292 #define VOP_SENDFILE(vp,f,off,ioflags,cnt,act,targ,cr,rv) \
293 rv = _VOP_(vop_sendfile, vp)((vp)->v_fbhv,f,off,ioflags,cnt,act,targ,cr)
294 #define VOP_SPLICE_READ(vp,f,o,pipe,cnt,fl,iofl,cr,rv) \
295 rv = _VOP_(vop_splice_read, vp)((vp)->v_fbhv,f,o,pipe,cnt,fl,iofl,cr)
296 #define VOP_SPLICE_WRITE(vp,f,o,pipe,cnt,fl,iofl,cr,rv) \
297 rv = _VOP_(vop_splice_write, vp)((vp)->v_fbhv,f,o,pipe,cnt,fl,iofl,cr)
298 #define VOP_BMAP(vp,of,sz,rw,b,n,rv) \
299 rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)
300 #define VOP_GETATTR(vp, vap, f, cr, rv) \
301 rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr)
302 #define VOP_SETATTR(vp, vap, f, cr, rv) \
303 rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr)
304 #define VOP_ACCESS(vp, mode, cr, rv) \
305 rv = _VOP_(vop_access, vp)((vp)->v_fbhv, mode, cr)
306 #define VOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv) \
307 rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr)
308 #define VOP_CREATE(dvp,d,vap,vpp,cr,rv) \
309 rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr)
310 #define VOP_REMOVE(dvp,d,cr,rv) \
311 rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr)
312 #define VOP_LINK(tdvp,fvp,d,cr,rv) \
313 rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr)
314 #define VOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv) \
315 rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr)
316 #define VOP_MKDIR(dp,d,vap,vpp,cr,rv) \
317 rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr)
318 #define VOP_RMDIR(dp,d,cr,rv) \
319 rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr)
320 #define VOP_READDIR(vp,uiop,cr,eofp,rv) \
321 rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp)
322 #define VOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv) \
323 rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr)
324 #define VOP_READLINK(vp,uiop,fl,cr,rv) \
325 rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr)
326 #define VOP_FSYNC(vp,f,cr,b,e,rv) \
327 rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e)
328 #define VOP_INACTIVE(vp, cr, rv) \
329 rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr)
330 #define VOP_RELEASE(vp, rv) \
331 rv = _VOP_(vop_release, vp)((vp)->v_fbhv)
332 #define VOP_FID2(vp, fidp, rv) \
333 rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp)
334 #define VOP_RWLOCK(vp,i) \
335 (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
336 #define VOP_RWLOCK_TRY(vp,i) \
337 _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
338 #define VOP_RWUNLOCK(vp,i) \
339 (void)_VOP_(vop_rwunlock, vp)((vp)->v_fbhv, i)
340 #define VOP_FRLOCK(vp,c,fl,flags,offset,fr,rv) \
341 rv = _VOP_(vop_frlock, vp)((vp)->v_fbhv,c,fl,flags,offset,fr)
342 #define VOP_RECLAIM(vp, rv) \
343 rv = _VOP_(vop_reclaim, vp)((vp)->v_fbhv)
344 #define VOP_ATTR_GET(vp, name, val, vallenp, fl, cred, rv) \
345 rv = _VOP_(vop_attr_get, vp)((vp)->v_fbhv,name,val,vallenp,fl,cred)
346 #define VOP_ATTR_SET(vp, name, val, vallen, fl, cred, rv) \
347 rv = _VOP_(vop_attr_set, vp)((vp)->v_fbhv,name,val,vallen,fl,cred)
348 #define VOP_ATTR_REMOVE(vp, name, flags, cred, rv) \
349 rv = _VOP_(vop_attr_remove, vp)((vp)->v_fbhv,name,flags,cred)
350 #define VOP_ATTR_LIST(vp, buf, buflen, fl, cursor, cred, rv) \
351 rv = _VOP_(vop_attr_list, vp)((vp)->v_fbhv,buf,buflen,fl,cursor,cred)
352 #define VOP_LINK_REMOVED(vp, dvp, linkzero) \
353 (void)_VOP_(vop_link_removed, vp)((vp)->v_fbhv, dvp, linkzero)
354 #define VOP_VNODE_CHANGE(vp, cmd, val) \
355 (void)_VOP_(vop_vnode_change, vp)((vp)->v_fbhv,cmd,val)
357 * These are page cache functions that now go thru VOPs.
358 * 'last' parameter is unused and left in for IRIX compatibility
360 #define VOP_TOSS_PAGES(vp, first, last, fiopt) \
361 _VOP_(vop_tosspages, vp)((vp)->v_fbhv,first, last, fiopt)
363 * 'last' parameter is unused and left in for IRIX compatibility
365 #define VOP_FLUSHINVAL_PAGES(vp, first, last, fiopt) \
366 _VOP_(vop_flushinval_pages, vp)((vp)->v_fbhv,first,last,fiopt)
368 * 'last' parameter is unused and left in for IRIX compatibility
370 #define VOP_FLUSH_PAGES(vp, first, last, flags, fiopt, rv) \
371 rv = _VOP_(vop_flush_pages, vp)((vp)->v_fbhv,first,last,flags,fiopt)
372 #define VOP_IOCTL(vp, inode, filp, fl, cmd, arg, rv) \
373 rv = _VOP_(vop_ioctl, vp)((vp)->v_fbhv,inode,filp,fl,cmd,arg)
374 #define VOP_IFLUSH(vp, flags, rv) \
375 rv = _VOP_(vop_iflush, vp)((vp)->v_fbhv, flags)
378 * Flags for read/write calls - same values as IRIX
380 #define IO_ISAIO 0x00001 /* don't wait for completion */
381 #define IO_ISDIRECT 0x00004 /* bypass page cache */
382 #define IO_INVIS 0x00020 /* don't update inode timestamps */
385 * Flags for VOP_IFLUSH call
387 #define FLUSH_SYNC 1 /* wait for flush to complete */
388 #define FLUSH_INODE 2 /* flush the inode itself */
389 #define FLUSH_LOG 4 /* force the last log entry for
390 * this inode out to disk */
393 * Flush/Invalidate options for VOP_TOSS_PAGES, VOP_FLUSHINVAL_PAGES and
396 #define FI_NONE 0 /* none */
397 #define FI_REMAPF 1 /* Do a remapf prior to the operation */
398 #define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation.
399 Prevent VM access to the pages until
400 the operation completes. */
403 * Vnode attributes. va_mask indicates those attributes the caller
404 * wants to set or extract.
406 typedef struct vattr {
407 int va_mask; /* bit-mask of attributes present */
408 mode_t va_mode; /* file access mode and type */
409 xfs_nlink_t va_nlink; /* number of references to file */
410 uid_t va_uid; /* owner user id */
411 gid_t va_gid; /* owner group id */
412 xfs_ino_t va_nodeid; /* file id */
413 xfs_off_t va_size; /* file size in bytes */
414 u_long va_blocksize; /* blocksize preferred for i/o */
415 struct timespec va_atime; /* time of last access */
416 struct timespec va_mtime; /* time of last modification */
417 struct timespec va_ctime; /* time file changed */
418 u_int va_gen; /* generation number of file */
419 xfs_dev_t va_rdev; /* device the special file represents */
420 __int64_t va_nblocks; /* number of blocks allocated */
421 u_long va_xflags; /* random extended file flags */
422 u_long va_extsize; /* file extent size */
423 u_long va_nextents; /* number of extents in file */
424 u_long va_anextents; /* number of attr extents in file */
425 prid_t va_projid; /* project id */
429 * setattr or getattr attributes
431 #define XFS_AT_TYPE 0x00000001
432 #define XFS_AT_MODE 0x00000002
433 #define XFS_AT_UID 0x00000004
434 #define XFS_AT_GID 0x00000008
435 #define XFS_AT_FSID 0x00000010
436 #define XFS_AT_NODEID 0x00000020
437 #define XFS_AT_NLINK 0x00000040
438 #define XFS_AT_SIZE 0x00000080
439 #define XFS_AT_ATIME 0x00000100
440 #define XFS_AT_MTIME 0x00000200
441 #define XFS_AT_CTIME 0x00000400
442 #define XFS_AT_RDEV 0x00000800
443 #define XFS_AT_BLKSIZE 0x00001000
444 #define XFS_AT_NBLOCKS 0x00002000
445 #define XFS_AT_VCODE 0x00004000
446 #define XFS_AT_MAC 0x00008000
447 #define XFS_AT_UPDATIME 0x00010000
448 #define XFS_AT_UPDMTIME 0x00020000
449 #define XFS_AT_UPDCTIME 0x00040000
450 #define XFS_AT_ACL 0x00080000
451 #define XFS_AT_CAP 0x00100000
452 #define XFS_AT_INF 0x00200000
453 #define XFS_AT_XFLAGS 0x00400000
454 #define XFS_AT_EXTSIZE 0x00800000
455 #define XFS_AT_NEXTENTS 0x01000000
456 #define XFS_AT_ANEXTENTS 0x02000000
457 #define XFS_AT_PROJID 0x04000000
458 #define XFS_AT_SIZE_NOPERM 0x08000000
459 #define XFS_AT_GENCOUNT 0x10000000
461 #define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
462 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
463 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
464 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
465 XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
466 XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
468 #define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
469 XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
470 XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
471 XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID)
473 #define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME)
475 #define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME)
477 #define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\
478 XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
479 XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
484 #define VSUID S_ISUID /* set user id on execution */
485 #define VSGID S_ISGID /* set group id on execution */
486 #define VSVTX S_ISVTX /* save swapped text even after use */
487 #define VREAD S_IRUSR /* read, write, execute permissions */
488 #define VWRITE S_IWUSR
489 #define VEXEC S_IXUSR
491 #define MODEMASK S_IALLUGO /* mode bits plus permission bits */
494 * Check whether mandatory file locking is enabled.
496 #define MANDLOCK(vp, mode) \
497 (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
499 extern void vn_init(void);
500 extern vnode_t *vn_initialize(struct inode *);
503 * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
505 typedef struct vnode_map {
507 vnumber_t v_number; /* in-core vnode number */
508 xfs_ino_t v_ino; /* inode # */
511 #define VMAP(vp, vmap) {(vmap).v_vfsp = (vp)->v_vfsp, \
512 (vmap).v_number = (vp)->v_number, \
513 (vmap).v_ino = (vp)->v_inode.i_ino; }
515 extern int vn_revalidate(struct vnode *);
516 extern int __vn_revalidate(struct vnode *, vattr_t *);
517 extern void vn_revalidate_core(struct vnode *, vattr_t *);
519 extern void vn_iowait(struct vnode *vp);
520 extern void vn_iowake(struct vnode *vp);
522 extern void vn_ioerror(struct vnode *vp, int error, char *f, int l);
524 static inline int vn_count(struct vnode *vp)
526 return atomic_read(&vn_to_inode(vp)->i_count);
530 * Vnode reference counting functions (and macros for compatibility).
532 extern vnode_t *vn_hold(struct vnode *);
534 #if defined(XFS_VNODE_TRACE)
535 #define VN_HOLD(vp) \
536 ((void)vn_hold(vp), \
537 vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
538 #define VN_RELE(vp) \
539 (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
540 iput(vn_to_inode(vp)))
542 #define VN_HOLD(vp) ((void)vn_hold(vp))
543 #define VN_RELE(vp) (iput(vn_to_inode(vp)))
546 static inline struct vnode *vn_grab(struct vnode *vp)
548 struct inode *inode = igrab(vn_to_inode(vp));
549 return inode ? vn_from_inode(inode) : NULL;
553 * Vname handling macros.
555 #define VNAME(dentry) ((char *) (dentry)->d_name.name)
556 #define VNAMELEN(dentry) ((dentry)->d_name.len)
557 #define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
560 * Vnode spinlock manipulation.
562 #define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock)
563 #define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s)
565 static __inline__ void vn_flagset(struct vnode *vp, uint flag)
567 spin_lock(&vp->v_lock);
569 spin_unlock(&vp->v_lock);
572 static __inline__ uint vn_flagclr(struct vnode *vp, uint flag)
576 spin_lock(&vp->v_lock);
577 cleared = (vp->v_flag & flag);
579 spin_unlock(&vp->v_lock);
583 #define VMODIFY(vp) vn_flagset(vp, VMODIFIED)
584 #define VUNMODIFY(vp) vn_flagclr(vp, VMODIFIED)
585 #define VTRUNCATE(vp) vn_flagset(vp, VTRUNCATED)
586 #define VUNTRUNCATE(vp) vn_flagclr(vp, VTRUNCATED)
589 * Dealing with bad inodes
591 static inline void vn_mark_bad(struct vnode *vp)
593 make_bad_inode(vn_to_inode(vp));
596 static inline int VN_BAD(struct vnode *vp)
598 return is_bad_inode(vn_to_inode(vp));
602 * Extracting atime values in various formats
604 static inline void vn_atime_to_bstime(struct vnode *vp, xfs_bstime_t *bs_atime)
606 bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec;
607 bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec;
610 static inline void vn_atime_to_timespec(struct vnode *vp, struct timespec *ts)
612 *ts = vp->v_inode.i_atime;
615 static inline void vn_atime_to_time_t(struct vnode *vp, time_t *tt)
617 *tt = vp->v_inode.i_atime.tv_sec;
621 * Some useful predicates.
623 #define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping)
624 #define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages)
625 #define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \
627 #define VN_TRUNC(vp) ((vp)->v_flag & VTRUNCATED)
630 * Flags to VOP_SETATTR/VOP_GETATTR.
632 #define ATTR_UTIME 0x01 /* non-default utime(2) request */
633 #define ATTR_DMI 0x08 /* invocation from a DMI function */
634 #define ATTR_LAZY 0x80 /* set/get attributes lazily */
635 #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
636 #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
637 #define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
640 * Flags to VOP_FSYNC and VOP_RECLAIM.
642 #define FSYNC_NOWAIT 0 /* asynchronous flush */
643 #define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
644 #define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
645 #define FSYNC_DATA 0x4 /* synchronous fsync of data only */
648 * Tracking vnode activity.
650 #if defined(XFS_VNODE_TRACE)
652 #define VNODE_TRACE_SIZE 16 /* number of trace entries */
653 #define VNODE_KTRACE_ENTRY 1
654 #define VNODE_KTRACE_EXIT 2
655 #define VNODE_KTRACE_HOLD 3
656 #define VNODE_KTRACE_REF 4
657 #define VNODE_KTRACE_RELE 5
659 extern void vn_trace_entry(struct vnode *, const char *, inst_t *);
660 extern void vn_trace_exit(struct vnode *, const char *, inst_t *);
661 extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
662 extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
663 extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
665 #define VN_TRACE(vp) \
666 vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
668 #define vn_trace_entry(a,b,c)
669 #define vn_trace_exit(a,b,c)
670 #define vn_trace_hold(a,b,c,d)
671 #define vn_trace_ref(a,b,c,d)
672 #define vn_trace_rele(a,b,c,d)
676 #endif /* __XFS_VNODE_H__ */