OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright 2000, International Business Machines Corporation and others. 00003 * All Rights Reserved. 00004 * 00005 * This software has been released under the terms of the IBM Public 00006 * License. For details, see the LICENSE file in the top-level source 00007 * directory or online at http://www.openafs.org/dl/license10.html 00008 */ 00009 00010 /* 00011 * SGI specific vfs related defines 00012 */ 00013 #ifndef _SGI_VFS_H_ 00014 #define _SGI_VFS_H_ 00015 00016 /* 00017 * UFS -> XFS translations 00018 */ 00019 /* Note: If SGI ever has more than one behavior per vnode, we'll have 00020 * to search for the one we want. 00021 */ 00022 #define XFS_VTOI(V) ((xfs_inode_t*)((V)->v_fbhv->bd_pdata)) 00023 #define vfstom(V) (bhvtom((V)->vfs_fbhv)) 00024 00025 struct xfs_inode; 00026 typedef struct xfs_inode xfs_inode_t; 00027 #define xfs_ino_t uint64_t 00028 #define XFS_ILOCK_SHARED 0x08 00029 struct xfs_trans; 00030 struct xfs_mount; 00031 extern int xfs_iget(struct mount *, struct xfs_trans *, xfs_ino_t, uint, 00032 xfs_inode_t **, daddr_t); 00033 00034 #ifdef AFS_SGI64_ENV 00035 #define XFS_ITOV(ip) BHV_TO_VNODE((struct bhv_desc *)(((char*)(ip)) + 6*sizeof(void*))) 00036 #else 00037 #define XFS_ITOV(ip) (*((vnode_t**)((((char*)(ip)) + 6*sizeof(void*))))) 00038 #endif 00039 00040 /* When we have XFS only clients, then these macros will be defined in 00041 * terms of the XFS inode only. 00042 */ 00043 extern struct vnodeops *afs_xfs_vnodeopsp; 00044 00045 /* These need to be functions to wrap the vnode op calls. */ 00046 extern ino_t VnodeToIno(vnode_t * vp); 00047 extern dev_t VnodeToDev(vnode_t * vp); 00048 extern off_t VnodeToSize(vnode_t * vp); 00049 00050 /* Page routines are vnode ops in Irix 6.5. These macros paper over the 00051 * differences. 00052 */ 00053 #define PTOSSVP(vp, off, len) VOP_TOSS_PAGES((vp), (off), (len), 0) 00054 #define PFLUSHINVALVP(vp, off, len) VOP_FLUSHINVAL_PAGES((vp), (off), (len), 0) 00055 #define PFLUSHVP(vp, len, flags, code) \ 00056 VOP_FLUSH_PAGES((vp), 0, (len), (flags), 0, code) 00057 #define PINVALFREE(vp, off) VOP_INVALFREE_PAGES((vp), (off)) 00058 00059 00060 /* 00061 * VFS translations 00062 */ 00063 #ifdef AFS_SGI_VNODE_GLUE 00064 /* The Octane does not have the mrlock_t in the bvh_head_t. So we should 00065 * not lock it. 00066 */ 00067 extern int afs_is_numa_arch; 00068 #define BHV_IPREVENT(BHP) afs_is_numa_arch ? BHV_INSERT_PREVENT(BHP) : (void)0 00069 #define BHV_IALLOW(BHP) afs_is_numa_arch ? BHV_INSERT_ALLOW(BHP) : (void)0 00070 00071 /* similar definition in /usr/include/sys/vfs.h (sgi_64) */ 00072 #define VFS_STATFS(vfsp,sp,vp)\ 00073 (*((vfsops_t *)(vfsp)->vfs_fops)->vfs_statvfs)((vfsp)->vfs_fbhv,sp,vp) 00074 #define AFS_VOP_ATTR_SET(vp, name, value, valuelen, flags, cred, rv) \ 00075 { \ 00076 BHV_IPREVENT(&(vp)->v_bh); \ 00077 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_attr_set)((vp)->v_fbhv,name,value,valuelen,flags,cred); \ 00078 BHV_IALLOW(&(vp)->v_bh); \ 00079 } 00080 00081 #define AFS_VOP_ATTR_GET(vp, name, value, valuelenp, flags, cred, rv) \ 00082 { \ 00083 BHV_IPREVENT(&(vp)->v_bh); \ 00084 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_attr_get)((vp)->v_fbhv,name,value,valuelenp,flags,cred); \ 00085 BHV_IALLOW(&(vp)->v_bh); \ 00086 } 00087 #define AFS_VOP_SETATTR(vp, vap, f, cr, rv) \ 00088 { \ 00089 BHV_IPREVENT(&(vp)->v_bh); \ 00090 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_setattr)((vp)->v_fbhv, vap, f, cr); \ 00091 BHV_IALLOW(&(vp)->v_bh); \ 00092 } 00093 #define AFS_VOP_GETATTR(vp, vap, f, cr, rv) \ 00094 { \ 00095 BHV_IPREVENT(&(vp)->v_bh); \ 00096 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_getattr)((vp)->v_fbhv, vap, f, cr); \ 00097 BHV_IALLOW(&(vp)->v_bh); \ 00098 } 00099 #define AFS_VOP_REMOVE(dvp,p,cr,rv) \ 00100 { \ 00101 BHV_IPREVENT(&(dvp)->v_bh); \ 00102 rv = (*((vnodeops_t *)(dvp)->v_fops)->vop_remove)((dvp)->v_fbhv,p,cr); \ 00103 BHV_IALLOW(&(dvp)->v_bh); \ 00104 } 00105 #define AFS_VOP_LOOKUP(vp,cp,vpp,pnp,f,rdir,cr,rv) \ 00106 { \ 00107 BHV_IPREVENT(&(vp)->v_bh); \ 00108 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_lookup)((vp)->v_fbhv,cp,vpp,pnp,f,rdir,cr); \ 00109 BHV_IALLOW(&(vp)->v_bh); \ 00110 } 00111 #define AFS_VOP_RMDIR(dp,p,cdir,cr,rv) \ 00112 { \ 00113 BHV_IPREVENT(&(dp)->v_bh); \ 00114 rv = (*((vnodeops_t *)(dp)->v_fops)->vop_rmdir)((dp)->v_fbhv,p,cdir,cr); \ 00115 BHV_IALLOW(&(dp)->v_bh); \ 00116 } 00117 #define AFS_VOP_WRITE(vp,uiop,iof,cr,rv) \ 00118 { \ 00119 BHV_IPREVENT(&(vp)->v_bh); \ 00120 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_write)((vp)->v_fbhv,uiop,iof,cr,&(curprocp->p_flid));\ 00121 BHV_IALLOW(&(vp)->v_bh); \ 00122 } 00123 #define AFS_VOP_READ(vp,uiop,iof,cr,rv) \ 00124 { \ 00125 BHV_IPREVENT(&(vp)->v_bh); \ 00126 rv = (*((vnodeops_t *)(vp)->v_fops)->vop_read)((vp)->v_fbhv,uiop,iof,cr,&(curprocp->p_flid));\ 00127 BHV_IALLOW(&(vp)->v_bh); \ 00128 } 00129 #define AFS_VOP_RWLOCK(vp,i) \ 00130 { \ 00131 BHV_IPREVENT(&(vp)->v_bh); \ 00132 (void)(*((vnodeops_t *)(vp)->v_fops)->vop_rwlock)((vp)->v_fbhv, i); \ 00133 /* "allow" is done by rwunlock */ \ 00134 } 00135 #define AFS_VOP_RWUNLOCK(vp,i) \ 00136 { /* "prevent" was done by rwlock */ \ 00137 (void)(*((vnodeops_t *)(vp)->v_fops)->vop_rwunlock)((vp)->v_fbhv, i);\ 00138 BHV_IALLOW(&(vp)->v_bh); \ 00139 } 00140 00141 /* VOP_RECLAIM remains as is, since it doesn't do the PREVENT/ALLOW */ 00142 00143 #define AFS_VN_OPEN(path, seg, mode, perm, dvp, why) \ 00144 vn_open((path), (seg), (mode), (perm), (dvp), (why), 0) 00145 #else /* AFS_SGI_VNODE_GLUE */ 00146 #define VFS_STATFS VFS_STATVFS 00147 #define AFS_VOP_ATTR_SET VOP_ATTR_SET 00148 #define AFS_VOP_ATTR_GET VOP_ATTR_GET 00149 #define AFS_VOP_SETATTR VOP_SETATTR 00150 #define AFS_VOP_GETATTR VOP_GETATTR 00151 #define AFS_VOP_REMOVE VOP_REMOVE 00152 #define AFS_VOP_LOOKUP VOP_LOOKUP 00153 #define AFS_VOP_RMDIR VOP_RMDIR 00154 #define AFS_VOP_READ(vp, uiop, iof, cr, code) \ 00155 VOP_READ((vp), (uiop), (iof), (cr), &curuthread->ut_flid, code) 00156 #define AFS_VOP_WRITE(vp, uiop, iof, cr, code) \ 00157 VOP_WRITE((vp), (uiop), (iof), (cr), &curuthread->ut_flid, code) 00158 00159 #define AFS_VN_OPEN(path, seg, mode, perm, dvp, why) \ 00160 vn_open((path), (seg), (mode), (perm), (dvp), (why), 0, NULL) 00161 00162 #define AFS_VOP_RWLOCK(vp, flag) VOP_RWLOCK((vp), (flag)) 00163 #define AFS_VOP_RWUNLOCK(vp, flag) VOP_RWUNLOCK((vp), (flag)) 00164 00165 #endif /* AFS_SGI_VNODE_GLUE */ 00166 #define devtovfs vfs_devsearch 00167 #define va_blocksize va_blksize 00168 #define va_blocks va_nblocks 00169 #define MAXNAMLEN 256 00170 00171 /* These macros hide the shape change inthe vnode for sgi_64 w/o NUMA. 00172 * They call routines so that if statements do not contain complex 00173 * expressions. 00174 */ 00175 #ifdef AFS_SGI_VNODE_GLUE 00176 extern int afs_is_numa_arch; 00177 typedef struct bhv_head1 { 00178 struct bhv_desc *bh_first; /* first behavior in chain */ 00179 #ifdef notdef 00180 /* This is not present in the non NUMA machines. */ 00181 mrlock_t bh_mrlock; /* lock for ops-in-progress synch. */ 00182 #endif 00183 } bhv_head1_t; 00184 00185 typedef struct vnode1 { 00186 struct vnlist v_list; /* freelist linkage */ 00187 uint v_flag; /* vnode flags (see below) */ 00188 cnt_t v_count; /* reference count */ 00189 u_short v_namecap; /* name cache capability */ 00190 enum vtype v_type; /* vnode type */ 00191 dev_t v_rdev; /* device (VCHR, VBLK) */ 00192 struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ 00193 struct vfs *v_vfsp; /* ptr to containing VFS */ 00194 struct stdata *v_stream; /* associated stream */ 00195 struct filock *v_filocks; /* ptr to filock list */ 00196 mutex_t *v_filocksem; /* ptr to mutex for list */ 00197 vnumber_t v_number; /* in-core vnode number */ 00198 short v_listid; /* free list id */ 00199 cnt_t v_intpcount; /* interp. refcount for imon */ 00200 bhv_head1_t v_bh; /* behavior head */ 00201 00202 /* 00203 * Used only by global cache. 00204 */ 00205 struct vnode *v_hashp; /* hash list for lookup */ 00206 struct vnode *v_hashn; /* hash list for lookup */ 00207 00208 /* 00209 * Values manipulated only by VM and 00210 * the page/buffer caches. 00211 */ 00212 struct pregion *v_mreg; /* mapped file region pointer */ 00213 int v_dbuf; /* delwri buffer count */ 00214 pgno_t v_pgcnt; /* pages hashed to vnode */ 00215 struct pfdat *v_dpages; /* delwri pages */ 00216 struct buf *v_buf; /* vnode buffer tree head */ 00217 unsigned int v_bufgen; /* buf list generation number */ 00218 mutex_t v_buf_lock; /* mutex for buffer tree */ 00219 00220 vnode_pcache_t v_pc; /* Page cache structure. 00221 * per vnode. Refer to 00222 * vnode_pcache.h 00223 * for details. 00224 */ 00225 #ifdef VNODE_TRACING 00226 struct ktrace *v_trace; /* trace header structure */ 00227 #endif 00228 #ifdef CKPT 00229 ckpt_handle_t v_ckpt; /* ckpt lookup info */ 00230 #endif 00231 } vnode1_t; 00232 00233 extern struct pfdat *vnode_get_dpages(vnode_t *); 00234 extern int vnode_get_dbuf(vnode_t *); 00235 extern pgno_t vnode_get_pgcnt(vnode_t *); 00236 extern struct pregion *vnode_get_mreg(vnode_t *); 00237 #define VN_GET_DPAGES(V) (afs_is_numa_arch ? \ 00238 ((V)->v_dpages) : \ 00239 (((vnode1_t*)(V))->v_dpages)) 00240 #define VN_SET_DPAGES(V, D) (afs_is_numa_arch ? \ 00241 ((V)->v_dpages = (D)) : \ 00242 (((vnode1_t*)(V))->v_dpages = (D))) 00243 #define VN_GET_DBUF(V) (afs_is_numa_arch ? \ 00244 ((V)->v_dbuf) : (((vnode1_t*)(V))->v_dbuf)) 00245 #define VN_GET_PGCNT(V) (afs_is_numa_arch ? \ 00246 ((V)->v_pgcnt) : (((vnode1_t*)(V))->v_pgcnt)) 00247 #define VN_GET_MREG(V) (afs_is_numa_arch ? \ 00248 ((V)->v_mreg) : (((vnode1_t*)(V))->v_mreg)) 00249 #define AFS_VN_MAPPED(V) (VN_GET_MREG(V) != NULL) 00250 #define AFS_VN_DIRTY(V) (VN_GET_DBUF(V) || VN_GET_DPAGES(V)) 00251 #define AFS_VN_INIT_BUF_LOCK(V) \ 00252 (afs_is_numa_arch ? \ 00253 init_mutex(&((V)->v_buf_lock), MUTEX_DEFAULT, "vn_buf_lock", \ 00254 (long)(V) ) : \ 00255 init_mutex(&(((vnode1_t*)(V))->v_buf_lock), MUTEX_DEFAULT, \ 00256 "vn_buf_lock", \ 00257 (long)(V) )) 00258 #define AFS_VN_DESTROY_BUF_LOCK(V) \ 00259 (afs_is_numa_arch ? \ 00260 mutex_destroy(&((V)->v_buf_lock)) : \ 00261 mutex_destroy(&(((vnode1_t*)(V))->v_buf_lock))) 00262 00263 #else 00264 #define VN_GET_DPAGES(V) ((V)->v_dpages) 00265 #define VN_SET_DPAGES(V, D) (V)->v_dpages = (D) 00266 #define VN_GET_DBUF(V) ((V)->v_dbuf) 00267 #define VN_GET_PGCNT(V) ((V)->v_pgcnt) 00268 #define VN_GET_MREG(V) ((V)->v_mreg) 00269 #define AFS_VN_MAPPED VN_MAPPED 00270 #define AFS_VN_DIRTY VN_DIRTY 00271 #define AFS_VN_INIT_BUF_LOCK(V) \ 00272 init_mutex(&((V)->v_buf_lock), MUTEX_DEFAULT, "vn_buf_lock", (long)(V)) 00273 #define AFS_VN_DESTROY_BUF_LOCK(V) \ 00274 mutex_destroy(&((V)->v_buf_lock)) 00275 #endif /* AFS_SGI_VNODE_GLUE */ 00276 00277 /* 00278 * Misc 00279 */ 00280 #define ucred cred 00281 #define uprintf printf 00282 #define d_fileno d_ino 00283 00284 #define CLBYTES NBPC 00285 /* 00286 * Flock(3) call. (from sys/file.h) 00287 */ 00288 #define LOCK_SH 1 /* shared lock */ 00289 #define LOCK_EX 2 /* exclusive lock */ 00290 #define LOCK_NB 4 /* don't block when locking */ 00291 #define LOCK_UN 8 /* unlock */ 00292 00293 #endif 00294 00295 00296 #if defined(AFS_SGI64_ENV) && defined(CKPT) 00297 /* This is a fid for checkpoint restart. Note that the length will be 00298 * greater than 10 and so afs_vget can distinguish this fid. 00299 */ 00300 typedef struct { 00301 u_short af_len; 00302 u_short af_cell; 00303 u_int af_volid; 00304 u_int af_vno; 00305 u_int af_uniq; 00306 } afs_fid2_t; 00307 #endif /* _SGI_VFS_H_ */