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
13 #include "../afs/param.h"
14 #include "../h/types.h"
15 #include "../h/param.h"
17 #ifdef AFS_LINUX20_ENV
18 #ifndef _LINUX_CODA_FS_I
19 #define _LINUX_CODA_FS_I
21 struct coda_inode_info {};
23 #ifndef _LINUX_XFS_FS_I
24 #define _LINUX_XFS_FS_I
25 struct xfs_inode_info {};
32 /* this is just a dummy type decl, we're really using struct sockets here */
38 afs_int32 size; /* file size in bytes */
39 afs_int32 blksize; /* optimal transfer size in bytes */
40 afs_int32 mtime; /* modification date */
41 afs_int32 atime; /* access time */
45 afs_int32 size; /* file size in bytes XXX Must be first field XXX */
46 #ifdef AFS_LINUX22_ENV
47 struct dentry dentry; /* merely to hold the pointer to the inode. */
48 struct file file; /* May need this if we really open the file. */
52 #if defined(AFS_HPUX102_ENV)
57 int (*proc)(); /* proc, which, if not null, is called on writes */
58 char *rock; /* rock passed to proc */
59 ino_t inum; /* guarantee validity of hint */
61 int fd; /* file descriptor for user space files */
62 #endif /* defined(UKERNEL) */
69 struct afs_osi_WaitHandle {
70 caddr_t proc; /* process waiting */
73 #define osi_SetFileProc(x,p) ((x)->proc=(p))
74 #define osi_SetFileRock(x,r) ((x)->rock=(r))
75 #define osi_GetFileProc(x) ((x)->proc)
76 #define osi_GetFileRock(x) ((x)->rock)
79 #define osi_FlushText(vp) if (hcmp((vp)->m.DataVersion, (vp)->flushDV) > 0) \
80 osi_FlushText_really(vp)
82 #define osi_FlushText(vp)
86 #define AFSOP_STOP_RXEVENT 214 /* stop rx event deamon */
87 #define AFSOP_STOP_COMPLETE 215 /* afs has been shutdown */
88 #define AFSOP_STOP_RXK_LISTENER 217 /* stop rx listener daemon */
91 #define osi_NPACKETS 20 /* number of cluster pkts to alloc */
92 extern struct osi_socket *osi_NewSocket();
98 extern void *afs_osi_Alloc(size_t size);
99 extern void afs_osi_Free(void *x, size_t size);
100 #define afs_osi_Alloc_NoSleep afs_osi_Alloc
102 extern void *osi_AllocSmallSpace(size_t size);
103 extern void osi_FreeSmallSpace(void *x);
104 extern void *osi_AllocMediumSpace(size_t size);
105 extern void osi_FreeMediumSpace(void *x);
106 extern void *osi_AllocLargeSpace(size_t size);
107 extern void osi_FreeLargeSpace(void *x);
110 * Vnode related macros
112 extern struct vnodeops *afs_ops;
113 #define vType(vc) (vc)->v.v_type
114 #define vSetType(vc,type) (vc)->v.v_type = (type)
115 #define IsAfsVnode(vc) ((vc)->v_op == afs_ops)
116 #define SetAfsVnode(vc) (vc)->v_op = afs_ops
117 #define vSetVfsp(vc,vfsp) (vc)->v.v_vfsp = (vfsp)
120 #define gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \
121 lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp),\
124 #define gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \
125 lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp))
129 * In IRIX 6.5 we cannot have DEBUG turned on since certain
130 * system-defined structures are a different size with DEBUG on, the
131 * kernel is compiled without DEBUG on, and the resulting differences
132 * would break our ability to interact with the rest of the kernel.
134 * Is DEBUG only for turning the ASSERT() macro? If so, we should
135 * be able to eliminate DEBUG entirely.
137 #if !defined(AFS_SGI65_ENV)
139 #define DEBUG 1 /* Default is to enable debugging/logging */
144 * Time related macros
146 #define osi_GetuTime(x) osi_GetTime(x)
148 /* osi_timeval_t exists because SGI 6.x has two sizes of timeval. */
149 /** In 64 bit Solaris the timeval structure has members that are 64 bit
150 * In the GetTime() interface we expect pointers to afs_int32. So the need to
151 * define osi_timeval_t to have 32 bit members. To make this less ambiguous
152 * we now use 32 bit quantities consistently all over the code.
153 * In 64 bit HP-UX the timeval structure has a 64 bit member.
157 #if defined(AFS_HPUX_ENV) || defined(AFS_SUN57_ENV) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
163 typedef struct timeval osi_timeval_t;
164 #endif /* AFS_SGI61_ENV */
167 * The following three routines provide the fid routines used by the buffer
168 * and directory packages.
170 #define dirp_Zap(afid) (*(afid) = -1)
171 #define dirp_Eq(afid, bfid) (*(afid) == *(bfid))
172 #define dirp_Cpy(dfid,sfid) (*(dfid) = *(sfid))
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 #define osi_ThreadUnique() getpid()
185 #ifdef AFS_GLOBAL_SUNLOCK
186 #define AFS_ASSERT_GLOCK() \
187 (ISAFS_GLOCK() || (osi_Panic("afs global lock not held"), 0))
188 #define AFS_ASSERT_RXGLOCK() \
189 (ISAFS_RXGLOCK() || (osi_Panic("rx global lock not held"), 0))
190 #endif /* AFS_GLOBAL_SUNLOCK */
196 #define AFS_GUNLOCK()
197 #define ISAFS_GLOCK() 1
198 #define AFS_ASSERT_GLOCK()
199 #define AFS_RXGLOCK()
200 #define AFS_RXGUNLOCK()
201 #define ISAFS_RXGLOCK() 1
202 #define AFS_ASSERT_RXGLOCK()
205 /* On an MP that uses multithreading, splnet is not sufficient to provide
206 * mutual exclusion because the other processors will not see it. On some
207 * early multiprocessors (SunOS413 & SGI5.2) splnet actually obtains a global
208 * mutex, which this works in the UP expected way, it means that the whole MP
209 * can only take one interrupt at a time; a serious performance penalty. */
211 #if ((defined(AFS_GLOBAL_SUNLOCK) || defined(RX_ENABLE_LOCKS)) && !defined(AFS_HPUX_ENV)) || !defined(KERNEL)
218 * vnode/vcache ref count manipulation
221 #define AFS_RELE(vp) do { VN_RELE(vp); } while (0)
222 #else /* defined(UKERNEL) */
223 #define AFS_RELE(vp) do { AFS_GUNLOCK(); VN_RELE(vp); AFS_GLOCK(); } while (0)
224 #endif /* defined(UKERNEL) */
226 * For some reason we do bare refcount manipulation in some places, for some
227 * platforms. The assumption is apparently that either we wouldn't call
228 * afs_inactive anyway (because we know the ref count is high), or that it's
229 * OK not to call it (because we don't expect CUnlinked or CDirty).
230 * (Also, of course, the vnode is assumed to be one of ours. Can't use this
231 * macro for V-file vnodes.)
233 #define AFS_FAST_HOLD(vp) VN_HOLD(&(vp)->v)
234 #define AFS_FAST_RELE(vp) AFS_RELE(&(vp)->v)
237 * MP safe versions of routines to copy memory between user space
238 * and kernel space. Call these to avoid taking page faults while
239 * holding the global lock.
241 #ifdef AFS_GLOBAL_SUNLOCK
243 #define AFS_COPYIN(SRC,DST,LEN,CODE) \
245 int haveGlock = ISAFS_GLOCK(); \
248 CODE = copyin((SRC),(DST),(LEN)); \
253 #define AFS_COPYINSTR(SRC,DST,LEN,CNT,CODE) \
255 int haveGlock = ISAFS_GLOCK(); \
258 CODE = copyinstr((SRC),(DST),(LEN),(CNT)); \
263 #define AFS_COPYOUT(SRC,DST,LEN,CODE) \
265 int haveGlock = ISAFS_GLOCK(); \
268 CODE = copyout((SRC),(DST),(LEN)); \
274 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
276 int haveGlock = ISAFS_GLOCK(); \
279 (UIO)->uio_rw = (RW); \
280 CODE = uiomove((SRC),(LEN),(UIO)); \
284 #else /* AFS_OSF_ENV */
285 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
287 int haveGlock = ISAFS_GLOCK(); \
290 CODE = uiomove((SRC),(LEN),(RW),(UIO)); \
294 #endif /* AFS_OSF_ENV */
296 #else /* AFS_GLOBAL_SUNLOCK */
298 #define AFS_COPYIN(SRC,DST,LEN,CODE) \
300 CODE = copyin((SRC),(DST),(LEN)); \
303 #define AFS_COPYINSTR(SRC,DST,LEN,CNT,CODE) \
305 CODE = copyinstr((SRC),(DST),(LEN),(CNT)); \
308 #define AFS_COPYOUT(SRC,DST,LEN,CODE) \
310 CODE = copyout((SRC),(DST),(LEN)); \
314 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
316 (UIO)->uio_rw = (RW); \
317 CODE = uiomove((SRC),(LEN),(UIO)); \
319 #else /* AFS_OSF_ENV */
320 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
322 CODE = uiomove((SRC),(LEN),(RW),(UIO)); \
324 #endif /* AFS_OSF_ENV */
326 #endif /* AFS_GLOBAL_SUNLOCK */
329 * encapsulation of kernel data structure accesses
331 #define setuerror(erval) u.u_error = (erval)
332 #define getuerror() u.u_error
334 /* Macros for vcache/vnode and vfs arguments to vnode and vfs ops.
335 * These are required for IRIX 6.4 and later, which pass behavior pointers.
336 * Note that the _CONVERT routines get the ";" here so that argument lists
337 * can have arguments after the OSI_x_CONVERT macro is called.
339 #define OSI_VN_ARG(V) V
340 #define OSI_VN_DECL(V) struct vnode *V
341 #define OSI_VN_CONVERT(V)
342 #define OSI_VC_ARG(V) V
343 #define OSI_VC_DECL(V) struct vcache *V
344 #define OSI_VC_CONVERT(V)
345 #define OSI_VFS_ARG(V) V
346 #define OSI_VFS_DECL(V) struct vfs *V
347 #define OSI_VFS_CONVERT(V)
351 ** Macro for Solaris 2.6 returns 1 if file is larger than 2GB; else returns 0
353 #define AfsLargeFileUio(uio) 0
354 #define AfsLargeFileSize(pos, off) 0
357 /* VM function prototypes.
359 #if defined(AFS_SUN5_ENV)
360 extern int osi_VM_GetDownD();
361 extern void osi_VM_PreTruncate();
363 #if defined(AFS_SGI_ENV)
364 extern void osi_VM_FSyncInval();
366 extern int osi_VM_FlushVCache();
367 extern void osi_VM_StoreAllSegments();
368 extern void osi_VM_TryToSmush();
369 extern void osi_VM_FlushPages();
370 extern void osi_VM_Truncate();
372 extern void osi_ReleaseVM();
374 /* Now include system specific OSI header file. It will redefine macros
375 * defined here as required by the OS.
377 #include "../afs/osi_machdep.h"
379 /* Declare any structures which use these macros after the OSI implementation
380 * has had the opportunity to redefine them.
382 extern struct AFS_UCRED afs_osi_cred;
384 #endif /* _AFS_OSI_ */