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
17 #include <sys/condvar.h>
20 #ifdef AFS_LINUX20_ENV
21 #ifndef _LINUX_CODA_FS_I
22 #define _LINUX_CODA_FS_I
24 struct coda_inode_info {
27 #ifndef _LINUX_XFS_FS_I
28 #define _LINUX_XFS_FS_I
29 struct xfs_inode_info {
37 /* this is just a dummy type decl, we're really using struct sockets here */
43 afs_int32 size; /* file size in bytes */
44 afs_int32 mtime; /* modification date */
45 afs_int32 atime; /* access time */
49 afs_int32 size; /* file size in bytes XXX Must be first field XXX */
50 #ifdef AFS_LINUX26_ENV
51 struct file *filp; /* May need this if we really open the file. */
53 #ifdef AFS_LINUX22_ENV
54 struct dentry dentry; /* merely to hold the pointer to the inode. */
55 struct file file; /* May need this if we really open the file. */
60 #if defined(AFS_HPUX102_ENV)
63 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
69 int (*proc) (struct osi_file * afile, afs_int32 code); /* proc, which, if not null, is called on writes */
70 char *rock; /* rock passed to proc */
72 int fd; /* file descriptor for user space files */
73 #endif /* defined(UKERNEL) */
77 #if defined(AFS_XBSD_ENV)
79 struct vnode *held_vnode;
80 #elif defined(AFS_AIX42_ENV)
87 struct afs_osi_WaitHandle {
88 caddr_t proc; /* process waiting */
91 #define osi_SetFileProc(x,p) ((x)->proc=(p))
92 #define osi_SetFileRock(x,r) ((x)->rock=(r))
93 #define osi_GetFileProc(x) ((x)->proc)
94 #define osi_GetFileRock(x) ((x)->rock)
97 #define osi_FlushText(vp) if (hcmp((vp)->f.m.DataVersion, (vp)->flushDV) > 0) \
98 osi_FlushText_really(vp)
100 #define osi_FlushText(vp)
104 #define AFSOP_STOP_RXEVENT 214 /* stop rx event deamon */
105 #define AFSOP_STOP_COMPLETE 215 /* afs has been shutdown */
106 #define AFSOP_STOP_RXK_LISTENER 217 /* stop rx listener daemon */
109 #define osi_NPACKETS 20 /* number of cluster pkts to alloc */
112 * Alloc declarations.
114 #if !defined(AFS_OBSD44_ENV)
115 #define afs_osi_Alloc_NoSleep afs_osi_Alloc
119 * Default vnode related macros
121 * Darwin, all of the BSDs, and Linux have their own
123 #if !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_LINUX20_ENV)
124 # define vType(vc) (vc)->v.v_type
125 # define vSetType(vc,type) (vc)->v.v_type = (type)
126 # define vSetVfsp(vc,vfsp) (vc)->v.v_vfsp = (vfsp)
127 extern struct vnodeops *afs_ops;
128 # define IsAfsVnode(v) ((v)->v_op == afs_ops)
129 # define SetAfsVnode(v) (v)->v_op = afs_ops
133 * In IRIX 6.5 we cannot have DEBUG turned on since certain
134 * system-defined structures are a different size with DEBUG on, the
135 * kernel is compiled without DEBUG on, and the resulting differences
136 * would break our ability to interact with the rest of the kernel.
138 * Is DEBUG only for turning the ASSERT() macro? If so, we should
139 * be able to eliminate DEBUG entirely.
141 #if !defined(AFS_SGI65_ENV)
143 #define DEBUG 1 /* Default is to enable debugging/logging */
148 * Time related macros
150 #define osi_GetuTime(x) osi_GetTime(x)
152 /* osi_timeval_t exists because SGI 6.x has two sizes of timeval. */
153 /** In 64 bit Solaris the timeval structure has members that are 64 bit
154 * In the GetTime() interface we expect pointers to afs_int32. So the need to
155 * define osi_timeval_t to have 32 bit members. To make this less ambiguous
156 * we now use 32 bit quantities consistently all over the code.
157 * In 64 bit HP-UX the timeval structure has a 64 bit member.
160 #if defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
165 #elif defined(AFS_SUN57_ENV)
166 typedef struct timeval32 osi_timeval_t;
168 typedef struct timeval osi_timeval_t;
169 #endif /* AFS_SGI61_ENV */
172 #define osi_getpid() getpid()
176 * osi_ThreadUnique() should yield a value that can be found in ps
177 * output in order to draw correspondences between ICL traces and what
178 * is going on in the system. So if ps cannot show thread IDs it is
179 * likely to be the process ID instead.
181 #ifdef AFS_FBSD50_ENV
182 /* should use curthread, but 'ps' can't display it */
183 #define osi_ThreadUnique() (curproc->p_pid)
184 #elif defined(AFS_LINUX_ENV)
185 #define osi_ThreadUnique() (current->pid)
186 #elif defined(UKERNEL)
187 #define osi_ThreadUnique() osi_getpid()
189 #define osi_ThreadUnique() getpid()
194 #ifdef AFS_GLOBAL_SUNLOCK
195 #define AFS_ASSERT_GLOCK() \
196 do { if (!ISAFS_GLOCK()) osi_Panic("afs global lock not held at %s:%d\n", __FILE__, __LINE__); } while (0)
197 #endif /* AFS_GLOBAL_SUNLOCK */
199 #ifdef RX_ENABLE_LOCKS
200 #define RX_AFS_GLOCK() AFS_GLOCK()
201 #define RX_AFS_GUNLOCK() AFS_GUNLOCK()
203 #define RX_AFS_GLOCK()
204 #define RX_AFS_GUNLOCK()
211 #define AFS_GUNLOCK()
212 #define ISAFS_GLOCK() 1
213 #define AFS_ASSERT_GLOCK()
216 /* On an MP that uses multithreading, splnet is not sufficient to provide
217 * mutual exclusion because the other processors will not see it. On some
218 * early multiprocessors (SunOS413 & SGI5.2) splnet actually obtains a global
219 * mutex, which this works in the UP expected way, it means that the whole MP
220 * can only take one interrupt at a time; a serious performance penalty. */
222 #if ((defined(AFS_GLOBAL_SUNLOCK) || defined(RX_ENABLE_LOCKS)) && !defined(AFS_HPUX_ENV)) || !defined(KERNEL)
229 * vnode/vcache ref count manipulation
232 #define AFS_RELE(vp) do { VN_RELE(vp); } while (0)
233 #else /* defined(UKERNEL) */
234 #define AFS_RELE(vp) do { AFS_GUNLOCK(); VN_RELE(vp); AFS_GLOCK(); } while (0)
235 #endif /* defined(UKERNEL) */
238 * For some reason we do bare refcount manipulation in some places, for some
239 * platforms. The assumption is apparently that either we wouldn't call
240 * afs_inactive anyway (because we know the ref count is high), or that it's
241 * OK not to call it (because we don't expect CUnlinked or CDirty).
242 * (Also, of course, the vnode is assumed to be one of ours. Can't use this
243 * macro for V-file vnodes.)
245 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
246 /* Bare refcount manipulation would probably work on this platform, but just
247 calling VREF does not */
248 #define AFS_FAST_HOLD(vp) osi_vnhold((vp),0)
250 #define AFS_FAST_HOLD(vp) VN_HOLD(AFSTOV(vp))
252 #define AFS_FAST_RELE(vp) AFS_RELE(AFSTOV(vp))
255 * MP safe versions of routines to copy memory between user space
256 * and kernel space. Call these to avoid taking page faults while
257 * holding the global lock.
259 #if defined(CAST_USER_ADDR_T) && !defined(UKERNEL) && !defined(AFS_DARWIN100_ENV)
260 #define __U(X) CAST_USER_ADDR_T((X))
264 #ifdef AFS_GLOBAL_SUNLOCK
266 #define AFS_COPYIN(SRC,DST,LEN,CODE) \
268 int haveGlock = ISAFS_GLOCK(); \
271 CODE = copyin(__U((SRC)),(DST),(LEN)); \
276 #define AFS_COPYINSTR(SRC,DST,LEN,CNT,CODE) \
278 int haveGlock = ISAFS_GLOCK(); \
281 CODE = copyinstr(__U((SRC)),(DST),(LEN),(CNT)); \
286 #define AFS_COPYOUT(SRC,DST,LEN,CODE) \
288 int haveGlock = ISAFS_GLOCK(); \
291 CODE = copyout((SRC),__U((DST)),(LEN)); \
296 #if defined(AFS_DARWIN80_ENV)
297 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
299 int haveGlock = ISAFS_GLOCK(); \
302 uio_setrw((UIO),(RW)); \
303 CODE = uiomove((SRC),(LEN),(UIO)); \
308 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
309 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
311 int haveGlock = ISAFS_GLOCK(); \
314 (UIO)->uio_rw = (RW); \
315 CODE = uiomove((SRC),(LEN),(UIO)); \
320 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
322 int haveGlock = ISAFS_GLOCK(); \
325 CODE = uiomove((SRC),(LEN),(RW),(UIO)); \
330 #endif /* AFS_DARWIN80_ENV */
332 #else /* AFS_GLOBAL_SUNLOCK */
334 #define AFS_COPYIN(SRC,DST,LEN,CODE) \
336 CODE = copyin(__U((SRC)),(DST),(LEN)); \
339 #define AFS_COPYINSTR(SRC,DST,LEN,CNT,CODE) \
341 CODE = copyinstr(__U((SRC)),(DST),(LEN),(CNT)); \
344 #define AFS_COPYOUT(SRC,DST,LEN,CODE) \
346 CODE = copyout((SRC),__U((DST)),(LEN)); \
349 #if defined(AFS_DARWIN80_ENV)
350 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
352 uio_setrw((UIO),(RW)); \
353 CODE = uiomove((SRC),(LEN),(UIO)); \
355 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
356 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
358 (UIO)->uio_rw = (RW); \
359 CODE = uiomove((SRC),(LEN),(UIO)); \
362 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
364 CODE = uiomove((SRC),(LEN),(RW),(UIO)); \
368 #endif /* AFS_GLOBAL_SUNLOCK */
370 #ifdef AFS_DARWIN80_ENV
371 #define AFS_UIO_OFFSET(uio) uio_offset(uio)
372 #define AFS_UIO_RESID(uio) (int)uio_resid(uio)
373 #define AFS_UIO_SETOFFSET(uio, off) uio_setoffset(uio, off)
374 #define AFS_UIO_SETRESID(uio, val) uio_setresid(uio, val)
376 #define AFS_UIO_OFFSET(uio) (uio)->uio_offset
377 #define AFS_UIO_RESID(uio) (uio)->uio_resid
378 #define AFS_UIO_SETOFFSET(uio, off) (uio)->uio_offset = off
379 #define AFS_UIO_SETRESID(uio, val) (uio)->uio_resid = val
384 * encapsulation of kernel data structure accesses
387 #define setuerror(erval) u.u_error = (erval)
388 #define getuerror() u.u_error
391 /* Macros for vcache/vnode and vfs arguments to vnode and vfs ops.
392 * These are required for IRIX 6.4 and later, which pass behavior pointers.
393 * Note that the _CONVERT routines get the ";" here so that argument lists
394 * can have arguments after the OSI_x_CONVERT macro is called.
396 #define OSI_VN_ARG(V) V
397 #define OSI_VN_DECL(V) struct vnode *V
398 #define OSI_VN_CONVERT(V)
399 #define OSI_VC_ARG(V) V
400 #define OSI_VC_DECL(V) struct vcache *V
401 #define OSI_VC_CONVERT(V)
402 #define OSI_VFS_ARG(V) V
403 #define OSI_VFS_DECL(V) struct vfs *V
404 #define OSI_VFS_CONVERT(V)
408 ** Macro for Solaris 2.6 returns 1 if file is larger than 2GB; else returns 0
410 #define AfsLargeFileUio(uio) 0
411 #define AfsLargeFileSize(pos, off) 0
413 /* Now include system specific OSI header file. It will redefine macros
414 * defined here as required by the OS.
416 #include "osi_machdep.h"
418 /* Declare any structures which use these macros after the OSI implementation
419 * has had the opportunity to redefine them.
421 extern afs_ucred_t afs_osi_cred, *afs_osi_credp;
424 #define osi_curcred() (u.u_cred)
427 #endif /* _AFS_OSI_ */