2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * SGI specific vfs related defines
17 * UFS -> XFS translations
19 /* Note: If SGI ever has more than one behavior per vnode, we'll have
20 * to search for the one we want.
22 #define XFS_VTOI(V) ((xfs_inode_t*)((V)->v_fbhv->bd_pdata))
23 #define vfstom(V) (bhvtom((V)->vfs_fbhv))
26 typedef struct xfs_inode xfs_inode_t;
27 #define xfs_ino_t uint64_t
28 #define XFS_ILOCK_SHARED 0x08
31 extern int xfs_iget(struct mount *, struct xfs_trans *, xfs_ino_t, uint,
32 xfs_inode_t **, daddr_t);
35 #define XFS_ITOV(ip) BHV_TO_VNODE((struct bhv_desc *)(((char*)(ip)) + 6*sizeof(void*)))
37 #define XFS_ITOV(ip) (*((vnode_t**)((((char*)(ip)) + 6*sizeof(void*)))))
40 /* When we have XFS only clients, then these macros will be defined in
41 * terms of the XFS inode only.
43 extern struct vnodeops *afs_xfs_vnodeopsp;
45 /* These need to be functions to wrap the vnode op calls. */
46 extern ino_t VnodeToIno(vnode_t * vp);
47 extern dev_t VnodeToDev(vnode_t * vp);
48 extern off_t VnodeToSize(vnode_t * vp);
50 /* Page routines are vnode ops in Irix 6.5. These macros paper over the
53 #define PTOSSVP(vp, off, len) VOP_TOSS_PAGES((vp), (off), (len), 0)
54 #define PFLUSHINVALVP(vp, off, len) VOP_FLUSHINVAL_PAGES((vp), (off), (len), 0)
55 #define PFLUSHVP(vp, len, flags, code) \
56 VOP_FLUSH_PAGES((vp), 0, (len), (flags), 0, code)
57 #define PINVALFREE(vp, off) VOP_INVALFREE_PAGES((vp), (off))
63 #ifdef AFS_SGI_VNODE_GLUE
64 /* The Octane does not have the mrlock_t in the bvh_head_t. So we should
67 extern int afs_is_numa_arch;
68 #define BHV_IPREVENT(BHP) afs_is_numa_arch ? BHV_INSERT_PREVENT(BHP) : (void)0
69 #define BHV_IALLOW(BHP) afs_is_numa_arch ? BHV_INSERT_ALLOW(BHP) : (void)0
71 /* similar definition in /usr/include/sys/vfs.h (sgi_64) */
72 #define VFS_STATFS(vfsp,sp,vp)\
73 (*((vfsops_t *)(vfsp)->vfs_fops)->vfs_statvfs)((vfsp)->vfs_fbhv,sp,vp)
74 #define AFS_VOP_ATTR_SET(vp, name, value, valuelen, flags, cred, rv) \
76 BHV_IPREVENT(&(vp)->v_bh); \
77 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_attr_set)((vp)->v_fbhv,name,value,valuelen,flags,cred); \
78 BHV_IALLOW(&(vp)->v_bh); \
81 #define AFS_VOP_ATTR_GET(vp, name, value, valuelenp, flags, cred, rv) \
83 BHV_IPREVENT(&(vp)->v_bh); \
84 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_attr_get)((vp)->v_fbhv,name,value,valuelenp,flags,cred); \
85 BHV_IALLOW(&(vp)->v_bh); \
87 #define AFS_VOP_SETATTR(vp, vap, f, cr, rv) \
89 BHV_IPREVENT(&(vp)->v_bh); \
90 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_setattr)((vp)->v_fbhv, vap, f, cr); \
91 BHV_IALLOW(&(vp)->v_bh); \
93 #define AFS_VOP_GETATTR(vp, vap, f, cr, rv) \
95 BHV_IPREVENT(&(vp)->v_bh); \
96 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_getattr)((vp)->v_fbhv, vap, f, cr); \
97 BHV_IALLOW(&(vp)->v_bh); \
99 #define AFS_VOP_REMOVE(dvp,p,cr,rv) \
101 BHV_IPREVENT(&(dvp)->v_bh); \
102 rv = (*((vnodeops_t *)(dvp)->v_fops)->vop_remove)((dvp)->v_fbhv,p,cr); \
103 BHV_IALLOW(&(dvp)->v_bh); \
105 #define AFS_VOP_LOOKUP(vp,cp,vpp,pnp,f,rdir,cr,rv) \
107 BHV_IPREVENT(&(vp)->v_bh); \
108 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_lookup)((vp)->v_fbhv,cp,vpp,pnp,f,rdir,cr); \
109 BHV_IALLOW(&(vp)->v_bh); \
111 #define AFS_VOP_RMDIR(dp,p,cdir,cr,rv) \
113 BHV_IPREVENT(&(dp)->v_bh); \
114 rv = (*((vnodeops_t *)(dp)->v_fops)->vop_rmdir)((dp)->v_fbhv,p,cdir,cr); \
115 BHV_IALLOW(&(dp)->v_bh); \
117 #define AFS_VOP_WRITE(vp,uiop,iof,cr,rv) \
119 BHV_IPREVENT(&(vp)->v_bh); \
120 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_write)((vp)->v_fbhv,uiop,iof,cr,&(curprocp->p_flid));\
121 BHV_IALLOW(&(vp)->v_bh); \
123 #define AFS_VOP_READ(vp,uiop,iof,cr,rv) \
125 BHV_IPREVENT(&(vp)->v_bh); \
126 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_read)((vp)->v_fbhv,uiop,iof,cr,&(curprocp->p_flid));\
127 BHV_IALLOW(&(vp)->v_bh); \
129 #define AFS_VOP_RWLOCK(vp,i) \
131 BHV_IPREVENT(&(vp)->v_bh); \
132 (void)(*((vnodeops_t *)(vp)->v_fops)->vop_rwlock)((vp)->v_fbhv, i); \
133 /* "allow" is done by rwunlock */ \
135 #define AFS_VOP_RWUNLOCK(vp,i) \
136 { /* "prevent" was done by rwlock */ \
137 (void)(*((vnodeops_t *)(vp)->v_fops)->vop_rwunlock)((vp)->v_fbhv, i);\
138 BHV_IALLOW(&(vp)->v_bh); \
141 /* VOP_RECLAIM remains as is, since it doesn't do the PREVENT/ALLOW */
143 #define AFS_VN_OPEN(path, seg, mode, perm, dvp, why) \
144 vn_open((path), (seg), (mode), (perm), (dvp), (why), 0)
145 #else /* AFS_SGI_VNODE_GLUE */
146 #define VFS_STATFS VFS_STATVFS
147 #define AFS_VOP_ATTR_SET VOP_ATTR_SET
148 #define AFS_VOP_ATTR_GET VOP_ATTR_GET
149 #define AFS_VOP_SETATTR VOP_SETATTR
150 #define AFS_VOP_GETATTR VOP_GETATTR
151 #define AFS_VOP_REMOVE VOP_REMOVE
152 #define AFS_VOP_LOOKUP VOP_LOOKUP
153 #define AFS_VOP_RMDIR VOP_RMDIR
154 #define AFS_VOP_READ(vp, uiop, iof, cr, code) \
155 VOP_READ((vp), (uiop), (iof), (cr), &curuthread->ut_flid, code)
156 #define AFS_VOP_WRITE(vp, uiop, iof, cr, code) \
157 VOP_WRITE((vp), (uiop), (iof), (cr), &curuthread->ut_flid, code)
159 #define AFS_VN_OPEN(path, seg, mode, perm, dvp, why) \
160 vn_open((path), (seg), (mode), (perm), (dvp), (why), 0, NULL)
162 #define AFS_VOP_RWLOCK(vp, flag) VOP_RWLOCK((vp), (flag))
163 #define AFS_VOP_RWUNLOCK(vp, flag) VOP_RWUNLOCK((vp), (flag))
165 #endif /* AFS_SGI_VNODE_GLUE */
166 #define devtovfs vfs_devsearch
167 #define va_blocksize va_blksize
168 #define va_blocks va_nblocks
169 #define MAXNAMLEN 256
171 /* These macros hide the shape change inthe vnode for sgi_64 w/o NUMA.
172 * They call routines so that if statements do not contain complex
175 #ifdef AFS_SGI_VNODE_GLUE
176 extern int afs_is_numa_arch;
177 typedef struct bhv_head1 {
178 struct bhv_desc *bh_first; /* first behavior in chain */
180 /* This is not present in the non NUMA machines. */
181 mrlock_t bh_mrlock; /* lock for ops-in-progress synch. */
185 typedef struct vnode1 {
186 struct vnlist v_list; /* freelist linkage */
187 uint v_flag; /* vnode flags (see below) */
188 cnt_t v_count; /* reference count */
189 u_short v_namecap; /* name cache capability */
190 enum vtype v_type; /* vnode type */
191 dev_t v_rdev; /* device (VCHR, VBLK) */
192 struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */
193 struct vfs *v_vfsp; /* ptr to containing VFS */
194 struct stdata *v_stream; /* associated stream */
195 struct filock *v_filocks; /* ptr to filock list */
196 mutex_t *v_filocksem; /* ptr to mutex for list */
197 vnumber_t v_number; /* in-core vnode number */
198 short v_listid; /* free list id */
199 cnt_t v_intpcount; /* interp. refcount for imon */
200 bhv_head1_t v_bh; /* behavior head */
203 * Used only by global cache.
205 struct vnode *v_hashp; /* hash list for lookup */
206 struct vnode *v_hashn; /* hash list for lookup */
209 * Values manipulated only by VM and
210 * the page/buffer caches.
212 struct pregion *v_mreg; /* mapped file region pointer */
213 int v_dbuf; /* delwri buffer count */
214 pgno_t v_pgcnt; /* pages hashed to vnode */
215 struct pfdat *v_dpages; /* delwri pages */
216 struct buf *v_buf; /* vnode buffer tree head */
217 unsigned int v_bufgen; /* buf list generation number */
218 mutex_t v_buf_lock; /* mutex for buffer tree */
220 vnode_pcache_t v_pc; /* Page cache structure.
221 * per vnode. Refer to
226 struct ktrace *v_trace; /* trace header structure */
229 ckpt_handle_t v_ckpt; /* ckpt lookup info */
233 extern struct pfdat *vnode_get_dpages(vnode_t *);
234 extern int vnode_get_dbuf(vnode_t *);
235 extern pgno_t vnode_get_pgcnt(vnode_t *);
236 extern struct pregion *vnode_get_mreg(vnode_t *);
237 #define VN_GET_DPAGES(V) (afs_is_numa_arch ? \
239 (((vnode1_t*)(V))->v_dpages))
240 #define VN_SET_DPAGES(V, D) (afs_is_numa_arch ? \
241 ((V)->v_dpages = (D)) : \
242 (((vnode1_t*)(V))->v_dpages = (D)))
243 #define VN_GET_DBUF(V) (afs_is_numa_arch ? \
244 ((V)->v_dbuf) : (((vnode1_t*)(V))->v_dbuf))
245 #define VN_GET_PGCNT(V) (afs_is_numa_arch ? \
246 ((V)->v_pgcnt) : (((vnode1_t*)(V))->v_pgcnt))
247 #define VN_GET_MREG(V) (afs_is_numa_arch ? \
248 ((V)->v_mreg) : (((vnode1_t*)(V))->v_mreg))
249 #define AFS_VN_MAPPED(V) (VN_GET_MREG(V) != NULL)
250 #define AFS_VN_DIRTY(V) (VN_GET_DBUF(V) || VN_GET_DPAGES(V))
251 #define AFS_VN_INIT_BUF_LOCK(V) \
252 (afs_is_numa_arch ? \
253 init_mutex(&((V)->v_buf_lock), MUTEX_DEFAULT, "vn_buf_lock", \
255 init_mutex(&(((vnode1_t*)(V))->v_buf_lock), MUTEX_DEFAULT, \
258 #define AFS_VN_DESTROY_BUF_LOCK(V) \
259 (afs_is_numa_arch ? \
260 mutex_destroy(&((V)->v_buf_lock)) : \
261 mutex_destroy(&(((vnode1_t*)(V))->v_buf_lock)))
264 #define VN_GET_DPAGES(V) ((V)->v_dpages)
265 #define VN_SET_DPAGES(V, D) (V)->v_dpages = (D)
266 #define VN_GET_DBUF(V) ((V)->v_dbuf)
267 #define VN_GET_PGCNT(V) ((V)->v_pgcnt)
268 #define VN_GET_MREG(V) ((V)->v_mreg)
269 #define AFS_VN_MAPPED VN_MAPPED
270 #define AFS_VN_DIRTY VN_DIRTY
271 #define AFS_VN_INIT_BUF_LOCK(V) \
272 init_mutex(&((V)->v_buf_lock), MUTEX_DEFAULT, "vn_buf_lock", (long)(V))
273 #define AFS_VN_DESTROY_BUF_LOCK(V) \
274 mutex_destroy(&((V)->v_buf_lock))
275 #endif /* AFS_SGI_VNODE_GLUE */
281 #define uprintf printf
282 #define d_fileno d_ino
286 * Flock(3) call. (from sys/file.h)
288 #define LOCK_SH 1 /* shared lock */
289 #define LOCK_EX 2 /* exclusive lock */
290 #define LOCK_NB 4 /* don't block when locking */
291 #define LOCK_UN 8 /* unlock */
296 #if defined(AFS_SGI64_ENV) && defined(CKPT)
297 /* This is a fid for checkpoint restart. Note that the length will be
298 * greater than 10 and so afs_vget can distinguish this fid.
307 #endif /* _SGI_VFS_H_ */