LINUX: defer afs_remunlink when current->fs==NULL
[openafs.git] / src / afs / afs_osi.h
index 30f497d..f8a6316 100644 (file)
@@ -11,7 +11,9 @@
 #define _AFS_OSI_
 
 #include "h/types.h"
+#if !defined(AFS_LINUX_ENV)
 #include "h/param.h"
+#endif
 
 #ifdef AFS_FBSD_ENV
 #include <sys/condvar.h>
@@ -21,7 +23,7 @@
 #include <sys/lock.h>
 #endif
 
-#ifdef AFS_LINUX20_ENV
+#ifdef AFS_LINUX_ENV
 #ifndef _LINUX_CODA_FS_I
 #define _LINUX_CODA_FS_I
 #define _CODA_HEADER_
@@ -58,10 +60,10 @@ struct osi_stat {
 
 struct osi_file {
     afs_int32 size;            /* file size in bytes XXX Must be first field XXX */
-#ifdef AFS_LINUX26_ENV
+#ifdef AFS_LINUX_ENV
     struct file *filp;         /* May need this if we really open the file. */
 #else
-#ifdef AFS_LINUX22_ENV
+#ifdef AFS_LINUX_ENV
     struct dentry dentry;      /* merely to hold the pointer to the inode. */
     struct file file;          /* May need this if we really open the file. */
 #else
@@ -131,10 +133,10 @@ struct afs_osi_WaitHandle {
  *
  * Darwin, all of the BSDs, and Linux have their own
  */
-#if !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_LINUX20_ENV)
-# define       vType(vc)           (vc)->v.v_type
-# define       vSetType(vc,type)   (vc)->v.v_type = (type)
-# define       vSetVfsp(vc,vfsp)   (vc)->v.v_vfsp = (vfsp)
+#if !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_LINUX_ENV)
+# define       vType(vc)           AFSTOV(vc)->v_type
+# define       vSetType(vc,type)   AFSTOV(vc)->v_type = (type)
+# define       vSetVfsp(vc,vfsp)   AFSTOV(vc)->v_vfsp = (vfsp)
 extern struct vnodeops *afs_ops;
 # define       IsAfsVnode(v)       ((v)->v_op == afs_ops)
 # define       SetAfsVnode(v)      (v)->v_op = afs_ops
@@ -147,6 +149,15 @@ extern void osi_PrePopulateVCache(struct vcache *);
 extern void osi_PostPopulateVCache(struct vcache *);
 extern void osi_AttachVnode(struct vcache *, int seq);
 
+/**
+ * Increment the refcount on the given vcache.
+ *
+ * @retval 0 Success
+ * @retval nonzero Error obtaining reference; the vcache is no longer valid and
+ *                the caller should act as if it doesn't exist.
+ */
+extern int osi_vnhold(struct vcache *);
+
 /*
  * In IRIX 6.5 and NetBSD we cannot have DEBUG turned on since certain
  * system-defined structures are a different size with DEBUG on, the
@@ -163,34 +174,14 @@ extern void osi_AttachVnode(struct vcache *, int seq);
 #endif
 
 /*
- * Time related macros
+ * We use osi_timeval32_t because the native timeval varies in size on
+ * different platforms.  We require a fixed size timeval, at least for the
+ * xstats.
  */
-#define osi_GetuTime(x) osi_GetTime(x)
-
-/* osi_timeval_t exists because SGI 6.x has two sizes of timeval. */
-/** In 64 bit Solaris the timeval structure has members that are 64 bit
-  * In the GetTime() interface we expect pointers to afs_int32. So the need to
-  * define osi_timeval_t to have 32 bit members. To make this less ambiguous
-  * we now use 32 bit quantities consistently all over the code.
-  * In 64 bit HP-UX the timeval structure has a 64 bit member.
-  */
-
-#if defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
-typedef struct {
-    afs_int32 tv_sec;
-    afs_int32 tv_usec;
-} osi_timeval_t;
 typedef struct {
     afs_int32 tv_sec;
     afs_int32 tv_usec;
 } osi_timeval32_t;
-#elif defined(AFS_SUN5_ENV)
-typedef struct timeval32 osi_timeval_t;
-typedef struct timeval32 osi_timeval32_t;
-#else
-typedef struct timeval osi_timeval_t;
-typedef struct timeval osi_timeval32_t;
-#endif /* AFS_SGI61_ENV */
 
 #ifndef UKERNEL
 #define osi_getpid()           getpid()
@@ -237,7 +228,7 @@ typedef struct timeval osi_timeval32_t;
 
 /* On an MP that uses multithreading, splnet is not sufficient to provide
  * mutual exclusion because the other processors will not see it.  On some
- * early multiprocessors (SunOS413 & SGI5.2) splnet actually obtains a global
+ * early multiprocessors (SGI5.2) splnet actually obtains a global
  * mutex, which this works in the UP expected way, it means that the whole MP
  * can only take one interrupt at a time; a serious performance penalty. */
 
@@ -264,9 +255,6 @@ typedef struct timeval osi_timeval32_t;
  * (Also, of course, the vnode is assumed to be one of ours.  Can't use this
  * macro for V-file vnodes.)
  */
-/* osi_vnhold is defined in PLATFORM/osi_machdep.h */
-#define AFS_FAST_HOLD(vp) osi_vnhold((vp), 0)
-
 #ifdef AFS_AIX_ENV
 #define AFS_FAST_RELE(vp) VREFCOUNT_DEC(vp)
 #else
@@ -446,4 +434,16 @@ extern afs_ucred_t afs_osi_cred, *afs_osi_credp;
 #define osi_curcred() (u.u_cred)
 #endif
 
+#ifdef AFS_PAG_ONEGROUP_ENV
+#define AFS_NUMPAGGROUPS 1
+#else
+#define AFS_NUMPAGGROUPS 2
+#endif
+
+#ifdef AFS_LINUX_ENV
+extern int osi_ShouldDeferRemunlink(struct vcache *avc);
+#else
+# define osi_ShouldDeferRemunlink(avc) 0
+#endif
+
 #endif /* _AFS_OSI_ */