2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 * Portions Copyright (c) 1989, 1993
33 * The Regents of the University of California. All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. Neither the name of the University nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 #ifndef __XFS_VNODE_H__
60 #define __XFS_VNODE_H__
62 #include <sys/vnode.h>
63 #include <sys/namei.h>
66 typedef xfs_ino_t vnumber_t;
67 typedef struct componentname vname_t;
68 typedef bhv_head_t vn_bhv_head_t;
71 * MP locking protocols:
72 * v_flag, v_vfsp VN_LOCK/VN_UNLOCK
73 * v_type read-only or fs-dependent
75 typedef struct xfs_vnode {
76 __u32 v_flag; /* vnode flags (see below) */
77 enum vtype v_type; /* vnode type */
78 struct xfs_vfs *v_vfsp; /* ptr to containing VFS */
79 vnumber_t v_number; /* in-core vnode number */
80 vn_bhv_head_t v_bh; /* behavior head */
81 struct vnode *v_vnode; /* FreeBSD vnode */
82 struct xfs_inode *v_inode; /* XFS inode */
83 #ifdef XFS_VNODE_TRACE
84 struct ktrace *v_trace; /* trace header structure */
88 #define v_fbhv v_bh.bh_first /* first behavior */
89 #define v_fops v_bh.bh_first->bd_ops /* first behavior ops */
91 #define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
92 #define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */
93 #define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
96 VN_BHV_UNKNOWN, /* not specified */
98 VN_BHV_DM, /* data migration */
99 VN_BHV_QM, /* quota manager */
100 VN_BHV_IO, /* IO path */
101 VN_BHV_END /* housekeeping end-of-range */
104 #define VNODE_POSITION_XFS (VNODE_POSITION_BASE)
105 #define VNODE_POSITION_DM (VNODE_POSITION_BASE+10)
106 #define VNODE_POSITION_QM (VNODE_POSITION_BASE+20)
107 #define VNODE_POSITION_IO (VNODE_POSITION_BASE+30)
109 #define VPTOXFSVP(vp) ((struct xfs_vnode *)(vp)->v_data)
112 * Macros for dealing with the behavior descriptor inside of the vnode.
114 #define BHV_TO_VNODE(bdp) ((xfs_vnode_t *)BHV_VOBJ(bdp))
115 #define BHV_TO_VNODE_NULL(bdp) ((xfs_vnode_t *)BHV_VOBJNULL(bdp))
117 #define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh)))
118 #define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name)
119 #define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp)
120 #define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops)
121 #define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops)
124 * Vnode to Linux inode mapping.
126 #define LINVFS_GET_VP(inode) ((xfs_vnode_t *)NULL)
127 #define LINVFS_GET_IP(vp) ((xfs_inode_t *)NULL)
131 * Convert between vnode types and inode formats (since POSIX.1
132 * defines mode word of stat structure in terms of inode formats).
134 extern enum vtype iftovt_tab[];
135 extern u_short vttoif_tab[];
136 #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
137 #define VTTOIF(indx) (vttoif_tab[(int)(indx)])
138 #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
145 #define VINACT 0x1 /* vnode is being inactivated */
146 #define VRECLM 0x2 /* vnode is being reclaimed */
147 #define VWAIT 0x4 /* waiting for VINACT/VRECLM to end */
148 #define VMODIFIED 0x8 /* XFS inode state possibly differs */
149 /* to the Linux inode state. */
152 * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter.
154 typedef enum vrwlock {
158 VRWLOCK_WRITE_DIRECT,
164 * Return values for VOP_INACTIVE. A return value of
165 * VN_INACTIVE_NOCACHE implies that the file system behavior
166 * has disassociated its state and bhv_desc_t from the vnode.
168 #define VN_INACTIVE_CACHE 0
169 #define VN_INACTIVE_NOCACHE 1
172 * Values for the cmd code given to VOP_VNODE_CHANGE.
174 typedef enum vchange {
175 VCHANGE_FLAGS_FRLOCKS = 0,
176 VCHANGE_FLAGS_ENF_LOCKING = 1,
177 VCHANGE_FLAGS_TRUNCATED = 2,
178 VCHANGE_FLAGS_PAGE_DIRTY = 3,
179 VCHANGE_FLAGS_IOEXCL_COUNT = 4
185 struct attrlist_cursor_kern;
187 typedef int (*xfs_vop_open_t)(bhv_desc_t *, struct cred *);
188 typedef ssize_t (*xfs_vop_read_t)(bhv_desc_t *, uio_t *, int, struct cred *);
189 typedef ssize_t (*xfs_vop_write_t)(bhv_desc_t *, uio_t *, int, struct cred *);
190 typedef int (*xfs_vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *,
191 int, unsigned int, unsigned long);
192 typedef int (*xfs_vop_getattr_t)(bhv_desc_t *, struct xfs_vattr *, int,
194 typedef int (*xfs_vop_setattr_t)(bhv_desc_t *, struct xfs_vattr *, int,
196 typedef int (*xfs_vop_access_t)(bhv_desc_t *, int, struct cred *);
197 typedef int (*xfs_vop_lookup_t)(bhv_desc_t *, vname_t *, xfs_vnode_t **,
198 int, xfs_vnode_t *, struct cred *);
199 typedef int (*xfs_vop_create_t)(bhv_desc_t *, vname_t *, struct xfs_vattr *,
200 xfs_vnode_t **, struct cred *);
201 typedef int (*xfs_vop_remove_t)(bhv_desc_t *, vname_t *, struct cred *);
202 typedef int (*xfs_vop_link_t)(bhv_desc_t *, xfs_vnode_t *, vname_t *,
204 typedef int (*xfs_vop_rename_t)(bhv_desc_t *, vname_t *, xfs_vnode_t *, vname_t *,
206 typedef int (*xfs_vop_mkdir_t)(bhv_desc_t *, vname_t *, struct xfs_vattr *,
207 xfs_vnode_t **, struct cred *);
208 typedef int (*xfs_vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *);
209 typedef int (*xfs_vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *,
211 typedef int (*xfs_vop_symlink_t)(bhv_desc_t *, vname_t *, struct xfs_vattr *,
212 char *, xfs_vnode_t **, struct cred *);
214 typedef int (*xfs_vop_readlink_t)(bhv_desc_t *, struct uio *, int,
216 typedef int (*xfs_vop_fsync_t)(bhv_desc_t *, int, struct cred *,
217 xfs_off_t, xfs_off_t);
218 typedef int (*xfs_vop_inactive_t)(bhv_desc_t *, struct cred *);
219 typedef int (*xfs_vop_fid2_t)(bhv_desc_t *, struct fid *);
220 typedef int (*xfs_vop_release_t)(bhv_desc_t *);
221 typedef int (*xfs_vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
222 typedef void (*xfs_vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
223 typedef int (*xfs_vop_frlock_t)(bhv_desc_t *, int, struct file_lock *,int,
224 xfs_off_t, struct cred *);
225 typedef int (*xfs_vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
226 struct xfs_iomap *, int *);
227 typedef int (*xfs_vop_reclaim_t)(bhv_desc_t *);
228 typedef int (*xfs_vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *, int,
230 typedef int (*xfs_vop_attr_set_t)(bhv_desc_t *, const char *, char *, int, int,
232 typedef int (*xfs_vop_attr_remove_t)(bhv_desc_t *, const char *, int, struct cred *);
233 typedef int (*xfs_vop_attr_list_t)(bhv_desc_t *, char *, int, int,
234 struct attrlist_cursor_kern *, struct cred *);
235 typedef void (*xfs_vop_link_removed_t)(bhv_desc_t *, xfs_vnode_t *, int);
236 typedef void (*xfs_vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t);
237 typedef void (*xfs_vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
238 typedef void (*xfs_vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
239 typedef int (*xfs_vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t,
241 typedef int (*xfs_vop_iflush_t)(bhv_desc_t *, int);
244 typedef struct xfs_vnodeops {
245 bhv_position_t vn_position; /* position within behavior chain */
246 xfs_vop_open_t vop_open;
247 xfs_vop_read_t vop_read;
248 xfs_vop_write_t vop_write;
249 xfs_vop_ioctl_t vop_ioctl;
250 xfs_vop_getattr_t vop_getattr;
251 xfs_vop_setattr_t vop_setattr;
252 xfs_vop_access_t vop_access;
253 xfs_vop_lookup_t vop_lookup;
254 xfs_vop_create_t vop_create;
255 xfs_vop_remove_t vop_remove;
256 xfs_vop_link_t vop_link;
257 xfs_vop_rename_t vop_rename;
258 xfs_vop_mkdir_t vop_mkdir;
259 xfs_vop_rmdir_t vop_rmdir;
260 xfs_vop_readdir_t vop_readdir;
261 xfs_vop_symlink_t vop_symlink;
262 xfs_vop_readlink_t vop_readlink;
263 xfs_vop_fsync_t vop_fsync;
264 xfs_vop_inactive_t vop_inactive;
265 xfs_vop_fid2_t vop_fid2;
266 xfs_vop_rwlock_t vop_rwlock;
267 xfs_vop_rwunlock_t vop_rwunlock;
268 xfs_vop_frlock_t vop_frlock;
269 xfs_vop_bmap_t vop_bmap;
270 xfs_vop_reclaim_t vop_reclaim;
271 xfs_vop_attr_get_t vop_attr_get;
272 xfs_vop_attr_set_t vop_attr_set;
273 xfs_vop_attr_remove_t vop_attr_remove;
274 xfs_vop_attr_list_t vop_attr_list;
275 xfs_vop_link_removed_t vop_link_removed;
276 xfs_vop_vnode_change_t vop_vnode_change;
277 xfs_vop_ptossvp_t vop_tosspages;
278 xfs_vop_pflushinvalvp_t vop_flushinval_pages;
279 xfs_vop_pflushvp_t vop_flush_pages;
280 xfs_vop_release_t vop_release;
281 xfs_vop_iflush_t vop_iflush;
287 #define _VOP_(op, vp) (*((xfs_vnodeops_t *)(vp)->v_fops)->op)
289 #define XVOP_READ(vp,uio,ioflags,cr,rv) \
290 rv = _VOP_(vop_read, vp)((vp)->v_fbhv,uio,ioflags,cr)
291 #define XVOP_WRITE(vp,file,uio,ioflags,cr,rv) \
292 rv = _VOP_(vop_write, vp)((vp)->v_fbhv,uio,ioflags,cr)
293 #define XVOP_BMAP(vp,of,sz,rw,b,n,rv) \
294 rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)
295 #define XVOP_OPEN(vp, cr, rv) \
296 rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr)
297 #define XVOP_GETATTR(vp, vap, f, cr, rv) \
298 rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr)
299 #define XVOP_SETATTR(vp, vap, f, cr, rv) \
300 rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr)
301 #define XVOP_ACCESS(vp, mode, cr, rv) \
302 rv = _VOP_(vop_access, vp)((vp)->v_fbhv, mode, cr)
303 #define XVOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv) \
304 rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr)
305 #define XVOP_CREATE(dvp,d,vap,vpp,cr,rv) \
306 rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr)
307 #define XVOP_REMOVE(dvp,d,cr,rv) \
308 rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr)
309 #define XVOP_LINK(tdvp,fvp,d,cr,rv) \
310 rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr)
311 #define XVOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv) \
312 rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr)
313 #define XVOP_MKDIR(dp,d,vap,vpp,cr,rv) \
314 rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr)
315 #define XVOP_RMDIR(dp,d,cr,rv) \
316 rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr)
317 #define XVOP_READDIR(vp,uiop,cr,eofp,rv) \
318 rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp)
319 #define XVOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv) \
320 rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr)
321 #define XVOP_READLINK(vp,uiop,fl,cr,rv) \
322 rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr)
324 #define XVOP_FSYNC(vp,f,cr,b,e,rv) \
325 rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e)
326 #define XVOP_INACTIVE(vp, cr, rv) \
327 rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr)
328 #define XVOP_RELEASE(vp, rv) \
329 rv = _VOP_(vop_release, vp)((vp)->v_fbhv)
330 #define XVOP_FID2(vp, fidp, rv) \
331 rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp)
332 #define XVOP_RWLOCK(vp,i) \
333 (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
334 #define XVOP_RWLOCK_TRY(vp,i) \
335 _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
336 #define XVOP_RWUNLOCK(vp,i) \
337 (void)_VOP_(vop_rwunlock, vp)((vp)->v_fbhv, i)
338 #define XVOP_FRLOCK(vp,c,fl,flags,offset,fr,rv) \
339 rv = _VOP_(vop_frlock, vp)((vp)->v_fbhv,c,fl,flags,offset,fr)
340 #define XVOP_RECLAIM(vp, rv) \
341 rv = _VOP_(vop_reclaim, vp)((vp)->v_fbhv)
342 #define XVOP_ATTR_GET(vp, name, val, vallenp, fl, cred, rv) \
343 rv = _VOP_(vop_attr_get, vp)((vp)->v_fbhv,name,val,vallenp,fl,cred)
344 #define XVOP_ATTR_SET(vp, name, val, vallen, fl, cred, rv) \
345 rv = _VOP_(vop_attr_set, vp)((vp)->v_fbhv,name,val,vallen,fl,cred)
346 #define XVOP_ATTR_REMOVE(vp, name, flags, cred, rv) \
347 rv = _VOP_(vop_attr_remove, vp)((vp)->v_fbhv,name,flags,cred)
348 #define XVOP_ATTR_LIST(vp, buf, buflen, fl, cursor, cred, rv) \
349 rv = _VOP_(vop_attr_list, vp)((vp)->v_fbhv,buf,buflen,fl,cursor,cred)
350 #define XVOP_LINK_REMOVED(vp, dvp, linkzero) \
351 (void)_VOP_(vop_link_removed, vp)((vp)->v_fbhv, dvp, linkzero)
352 #define XVOP_VNODE_CHANGE(vp, cmd, val) \
353 (void)_VOP_(vop_vnode_change, vp)((vp)->v_fbhv,cmd,val)
355 * These are page cache functions that now go thru VOPs.
356 * 'last' parameter is unused and left in for IRIX compatibility
358 #define XVOP_TOSS_PAGES(vp, first, last, fiopt) \
359 _VOP_(vop_tosspages, vp)((vp)->v_fbhv,first, last, fiopt)
361 * 'last' parameter is unused and left in for IRIX compatibility
363 #define XVOP_FLUSHINVAL_PAGES(vp, first, last, fiopt) \
364 _VOP_(vop_flushinval_pages, vp)((vp)->v_fbhv,first,last,fiopt)
366 * 'last' parameter is unused and left in for IRIX compatibility
368 #define XVOP_FLUSH_PAGES(vp, first, last, flags, fiopt, rv) \
369 rv = _VOP_(vop_flush_pages, vp)((vp)->v_fbhv,first,last,flags,fiopt)
370 #define XVOP_IOCTL(vp, inode, filp, fl, cmd, arg, rv) \
371 rv = _VOP_(vop_ioctl, vp)((vp)->v_fbhv,inode,filp,fl,cmd,arg)
372 #define XVOP_IFLUSH(vp, flags, rv) \
373 rv = _VOP_(vop_iflush, vp)((vp)->v_fbhv, flags)
376 * Flags for read/write calls - select values from FreeBSD IO_ flags
377 * or non-conflicting bits.
379 #define IO_ISDIRECT IO_DIRECT /* bypass page cache */
380 #define IO_INVIS 0x02000 /* don't update inode timestamps */
381 #define IO_ISLOCKED 0x04000 /* don't do inode locking */
384 * Flags for VOP_IFLUSH call
386 #define FLUSH_SYNC 1 /* wait for flush to complete */
387 #define FLUSH_INODE 2 /* flush the inode itself */
388 #define FLUSH_LOG 4 /* force the last log entry for
389 * this inode out to disk */
392 * Flush/Invalidate options for VOP_TOSS_PAGES, VOP_FLUSHINVAL_PAGES and
395 #define FI_NONE 0 /* none */
396 #define FI_REMAPF 1 /* Do a remapf prior to the operation */
397 #define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation.
398 Prevent VM access to the pages until
399 the operation completes. */
402 * Vnode attributes. va_mask indicates those attributes the caller
403 * wants to set or extract.
405 typedef struct xfs_vattr {
406 int va_mask; /* bit-mask of attributes present */
407 enum vtype va_type; /* vnode type (for create) */
408 mode_t va_mode; /* file access mode and type */
409 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 int 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)
485 #define VSUID S_ISUID /* set user id on execution */
486 #define VSGID S_ISGID /* set group id on execution */
487 #define VSVTX S_ISVTX /* save swapped text even after use */
488 #define VREAD S_IRUSR /* read, write, execute permissions */
489 #define VWRITE S_IWUSR
490 #define VEXEC S_IXUSR
491 #endif /* __FreeBSD__ */
493 #define MODEMASK ALLPERMS /* mode bits plus permission bits */
496 * Check whether mandatory file locking is enabled.
498 #define MANDLOCK(vp, mode) \
499 ((vp)->v_type == VREG && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
501 extern void vn_init(void);
502 extern int vn_wait(struct xfs_vnode *);
503 extern xfs_vnode_t *vn_initialize(struct xfs_vnode *);
506 * Acquiring and invalidating vnodes:
508 * if (vn_get(vp, version, 0))
510 * vn_purge(vp, version);
512 * vn_get and vn_purge must be called with vmap_t arguments, sampled
513 * while a lock that the vnode's VOP_RECLAIM function acquires is
514 * held, to ensure that the vnode sampled with the lock held isn't
515 * recycled (VOP_RECLAIMed) or deallocated between the release of the lock
516 * and the subsequent vn_get or vn_purge.
520 * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
522 typedef struct vnode_map {
528 #define VMAP(vp, vmap) {(vmap).v_vfsp = (vp)->v_vfsp; \
529 (vmap).v_vp = (vp)->v_vnode; \
530 (vmap).v_ino = (vp)->v_inode->i_ino;\
531 vhold((vp)->v_vnode); \
534 extern void vn_purge(struct xfs_vnode *, vmap_t *);
535 extern xfs_vnode_t *vn_get(struct xfs_vnode *, vmap_t *);
536 extern int vn_revalidate(struct xfs_vnode *);
537 extern void vn_remove(struct xfs_vnode *);
539 static inline int vn_count(struct xfs_vnode *vp)
541 return vp->v_vnode->v_usecount;
545 * Vnode reference counting functions (and macros for compatibility).
547 extern xfs_vnode_t *vn_hold(struct xfs_vnode *);
548 extern void vn_rele(struct xfs_vnode *);
550 #if defined(XFS_VNODE_TRACE)
551 #define VN_HOLD(vp) \
552 ((void)vref((vp)->v_vnode), \
553 vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
554 #define VN_RELE(vp) \
555 (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
556 vrele((vp)->v_vnode))
558 #define VN_HOLD(vp) vref((vp)->v_vnode)
559 #define VN_RELE(vp) vrele((vp)->v_vnode)
563 * Vname handling macros.
565 #define VNAME(cnp) ((cnp)->cn_nameptr)
566 #define VNAMELEN(cnp) ((cnp)->cn_namelen)
567 #define VNAME_TO_VNODE(dentry) (printf("VNAME_TO_VNODE NI"), (xfs_vnode_t *)0)
570 * Vnode spinlock manipulation.
572 #define VN_LOCK(vp) VI_LOCK(vp->v_vnode)
573 #define VN_UNLOCK(vp, s) VI_UNLOCK(vp->v_vnode)
574 #define VN_FLAGSET(vp,b) vn_flagset(vp,b)
575 #define VN_FLAGCLR(vp,b) vn_flagclr(vp,b)
577 static __inline__ void vn_flagset(struct xfs_vnode *vp, __u32 flag)
584 static __inline__ void vn_flagclr(struct xfs_vnode *vp, __u32 flag)
592 * Update modify/access/change times on the vnode
594 #define VN_MTIMESET(vp, tvp)
595 #define VN_ATIMESET(vp, tvp)
596 #define VN_CTIMESET(vp, tvp)
599 * Some useful predicates.
601 #define VN_MAPPED(vp) 0
602 #define VN_CACHED(vp) 0
603 #define VN_DIRTY(vp) 0
604 #define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED)
605 #define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED)
608 * Flags to VOP_SETATTR/VOP_GETATTR.
610 #define ATTR_UTIME 0x01 /* non-default utime(2) request */
611 #define ATTR_DMI 0x08 /* invocation from a DMI function */
612 #define ATTR_LAZY 0x80 /* set/get attributes lazily */
613 #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
616 * Flags to VOP_FSYNC and VOP_RECLAIM.
618 #define FSYNC_NOWAIT 0 /* asynchronous flush */
619 #define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
620 #define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
621 #define FSYNC_DATA 0x4 /* synchronous fsync of data only */
624 * Tracking vnode activity.
626 #if defined(XFS_VNODE_TRACE)
628 #define VNODE_TRACE_SIZE 16 /* number of trace entries */
629 #define VNODE_KTRACE_ENTRY 1
630 #define VNODE_KTRACE_EXIT 2
631 #define VNODE_KTRACE_HOLD 3
632 #define VNODE_KTRACE_REF 4
633 #define VNODE_KTRACE_RELE 5
635 extern void vn_trace_entry(struct xfs_vnode *, char *, inst_t *);
636 extern void vn_trace_exit(struct xfs_vnode *, char *, inst_t *);
637 extern void vn_trace_hold(struct xfs_vnode *, char *, int, inst_t *);
638 extern void vn_trace_ref(struct xfs_vnode *, char *, int, inst_t *);
639 extern void vn_trace_rele(struct xfs_vnode *, char *, int, inst_t *);
641 #define VN_TRACE(vp) \
642 vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
644 #define vn_trace_entry(a,b,c)
645 #define vn_trace_exit(a,b,c)
646 #define vn_trace_hold(a,b,c,d)
647 #define vn_trace_ref(a,b,c,d)
648 #define vn_trace_rele(a,b,c,d)
652 #endif /* __XFS_VNODE_H__ */