Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2000, International Business Machines Corporation and others. | |
3 | * All Rights Reserved. | |
4 | * | |
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 | |
8 | */ | |
9 | ||
10 | /* | |
11 | * SGI specific vfs related defines | |
12 | */ | |
13 | #ifndef _SGI_VFS_H_ | |
14 | #define _SGI_VFS_H_ | |
15 | ||
16 | /* | |
17 | * UFS -> XFS translations | |
18 | */ | |
19 | /* Note: If SGI ever has more than one behavior per vnode, we'll have | |
20 | * to search for the one we want. | |
21 | */ | |
22 | #define XFS_VTOI(V) ((xfs_inode_t*)((V)->v_fbhv->bd_pdata)) | |
23 | #define vfstom(V) (bhvtom((V)->vfs_fbhv)) | |
24 | ||
25 | struct xfs_inode; | |
26 | typedef struct xfs_inode xfs_inode_t; | |
27 | #define xfs_ino_t uint64_t | |
28 | #define XFS_ILOCK_SHARED 0x08 | |
29 | struct xfs_trans; | |
30 | struct xfs_mount; | |
31 | extern int xfs_iget(struct mount *, struct xfs_trans *, xfs_ino_t, uint, | |
32 | xfs_inode_t **, daddr_t); | |
33 | ||
34 | #ifdef AFS_SGI64_ENV | |
35 | #define XFS_ITOV(ip) BHV_TO_VNODE((struct bhv_desc *)(((char*)(ip)) + 6*sizeof(void*))) | |
36 | #else | |
37 | #define XFS_ITOV(ip) (*((vnode_t**)((((char*)(ip)) + 6*sizeof(void*))))) | |
38 | #endif | |
39 | ||
40 | /* When we have XFS only clients, then these macros will be defined in | |
41 | * terms of the XFS inode only. | |
42 | */ | |
43 | extern struct vnodeops *afs_xfs_vnodeopsp; | |
44 | ||
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); | |
49 | ||
50 | /* Page routines are vnode ops in Irix 6.5. These macros paper over the | |
51 | * differences. | |
52 | */ | |
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)) | |
58 | ||
59 | ||
60 | /* | |
61 | * VFS translations | |
62 | */ | |
63 | #ifdef AFS_SGI_VNODE_GLUE | |
64 | /* The Octane does not have the mrlock_t in the bvh_head_t. So we should | |
65 | * not lock it. | |
66 | */ | |
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 | |
70 | ||
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) \ | |
75 | { \ | |
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); \ | |
79 | } | |
80 | ||
81 | #define AFS_VOP_ATTR_GET(vp, name, value, valuelenp, flags, cred, rv) \ | |
82 | { \ | |
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); \ | |
86 | } | |
87 | #define AFS_VOP_SETATTR(vp, vap, f, cr, rv) \ | |
88 | { \ | |
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); \ | |
92 | } | |
93 | #define AFS_VOP_GETATTR(vp, vap, f, cr, rv) \ | |
94 | { \ | |
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); \ | |
98 | } | |
99 | #define AFS_VOP_REMOVE(dvp,p,cr,rv) \ | |
100 | { \ | |
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); \ | |
104 | } | |
105 | #define AFS_VOP_LOOKUP(vp,cp,vpp,pnp,f,rdir,cr,rv) \ | |
106 | { \ | |
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); \ | |
110 | } | |
111 | #define AFS_VOP_RMDIR(dp,p,cdir,cr,rv) \ | |
112 | { \ | |
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); \ | |
116 | } | |
117 | #define AFS_VOP_WRITE(vp,uiop,iof,cr,rv) \ | |
118 | { \ | |
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); \ | |
122 | } | |
123 | #define AFS_VOP_READ(vp,uiop,iof,cr,rv) \ | |
124 | { \ | |
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); \ | |
128 | } | |
129 | #define AFS_VOP_RWLOCK(vp,i) \ | |
130 | { \ | |
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 */ \ | |
134 | } | |
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); \ | |
139 | } | |
140 | ||
141 | /* VOP_RECLAIM remains as is, since it doesn't do the PREVENT/ALLOW */ | |
142 | ||
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) | |
158 | ||
159 | #define AFS_VN_OPEN(path, seg, mode, perm, dvp, why) \ | |
160 | vn_open((path), (seg), (mode), (perm), (dvp), (why), 0, NULL) | |
161 | ||
162 | #define AFS_VOP_RWLOCK(vp, flag) VOP_RWLOCK((vp), (flag)) | |
163 | #define AFS_VOP_RWUNLOCK(vp, flag) VOP_RWUNLOCK((vp), (flag)) | |
164 | ||
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 | |
170 | ||
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 | |
173 | * expressions. | |
174 | */ | |
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 */ | |
179 | #ifdef notdef | |
180 | /* This is not present in the non NUMA machines. */ | |
181 | mrlock_t bh_mrlock; /* lock for ops-in-progress synch. */ | |
182 | #endif | |
183 | } bhv_head1_t; | |
184 | ||
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 */ | |
201 | ||
202 | /* | |
203 | * Used only by global cache. | |
204 | */ | |
205 | struct vnode *v_hashp; /* hash list for lookup */ | |
206 | struct vnode *v_hashn; /* hash list for lookup */ | |
207 | ||
208 | /* | |
209 | * Values manipulated only by VM and | |
210 | * the page/buffer caches. | |
211 | */ | |
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 */ | |
219 | ||
220 | vnode_pcache_t v_pc; /* Page cache structure. | |
221 | * per vnode. Refer to | |
222 | * vnode_pcache.h | |
223 | * for details. | |
224 | */ | |
225 | #ifdef VNODE_TRACING | |
226 | struct ktrace *v_trace; /* trace header structure */ | |
227 | #endif | |
228 | #ifdef CKPT | |
229 | ckpt_handle_t v_ckpt; /* ckpt lookup info */ | |
230 | #endif | |
231 | } vnode1_t; | |
232 | ||
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 ? \ | |
238 | ((V)->v_dpages) : \ | |
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", \ | |
254 | (long)(V) ) : \ | |
255 | init_mutex(&(((vnode1_t*)(V))->v_buf_lock), MUTEX_DEFAULT, \ | |
256 | "vn_buf_lock", \ | |
257 | (long)(V) )) | |
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))) | |
262 | ||
263 | #else | |
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 */ | |
276 | ||
277 | /* | |
278 | * Misc | |
279 | */ | |
280 | #define ucred cred | |
281 | #define uprintf printf | |
282 | #define d_fileno d_ino | |
283 | ||
284 | #define CLBYTES NBPC | |
285 | /* | |
286 | * Flock(3) call. (from sys/file.h) | |
287 | */ | |
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 */ | |
292 | ||
293 | #endif | |
294 | ||
295 | ||
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. | |
299 | */ | |
300 | typedef struct { | |
301 | u_short af_len; | |
302 | u_short af_cell; | |
303 | u_int af_volid; | |
304 | u_int af_vno; | |
305 | u_int af_uniq; | |
306 | } afs_fid2_t; | |
307 | #endif /* _SGI_VFS_H_ */ |