SOLARIS: provide cache manager stats via kstat
[openafs.git] / src / afs / afs.h
index 63fb03d..96243ee 100644 (file)
@@ -20,6 +20,9 @@
 #include "afs/afs_consts.h"
 #endif
 
+/* jhash.h is a standalone header and is fine to pull into kernel code. */
+#include <opr/jhash.h>
+
 /*
  * afs_fsfragsize cannot be less than 1023, or some cache-tracking
  * calculations will be incorrect (since we track cache usage in kb).
 /* Upper bound on number of iovecs out uio routines will deal with. */
 #define        AFS_MAXIOVCNT       16
 
+enum afs_shutdown_state {
+    AFS_RUNNING = 0,
+    AFS_FLUSHING_CB = 1,
+    AFS_SHUTDOWN = 2,
+};
+extern enum afs_shutdown_state afs_shuttingdown;
 
-extern int afs_shuttingdown;
+/*
+ * The string that we use for the "device" we mount /afs on. That is, we're not
+ * mounted on a drive like /dev/sda, but instead mounted on "afs".
+ */
+#define AFS_MOUNT_STR "afs"
+#ifndef MOUNT_AFS
+# define MOUNT_AFS AFS_MOUNT_STR
+#endif
 
 /*
  * Macros to uniquely identify the AFS vfs struct
  */
 #define        AFS_VFSMAGIC            0x1234
-#if defined(AFS_SUN5_ENV) || defined(AFS_HPUX90_ENV) || defined(AFS_LINUX20_ENV)
-#define        AFS_VFSFSID             99
-#else
-#if defined(AFS_SGI_ENV)
-#define AFS_VFSFSID            afs_fstype
+
+/*
+ * Define AFS_VFSFSID, an id number corresponding to the AFS filesystem. On
+ * Irix, this is stored in a global var (afs_fstype); everywhere else, we have
+ * a constant. If we have a platform-defined value for this, use it (AFS_FSNO);
+ * otherwise, we just make up an arbitrary value here (99).
+ */
+#ifdef AFS_SGI_ENV
+# define AFS_VFSFSID   afs_fstype
+#elif defined(AFS_FSNO)
+# define AFS_VFSFSID   AFS_FSNO
 #else
-#define        AFS_VFSFSID             AFS_MOUNT_AFS
-#endif
+# define AFS_VFSFSID   99
 #endif
+
 /* use this value for reporting total space, free space, etc.
  * fake a high number to satisfy programs that use the statfs call to make sure
  * that there's enough space in the device partition before storing something
@@ -82,12 +104,14 @@ extern int afs_shuttingdown;
 #define        NSERVERS        16      /* hash table size for server table */
 #define        NVOLS           64      /* hash table size for volume table */
 #define        NFENTRIES       256     /* hash table size for disk volume table */
-#define        VCSIZE         1024     /* stat cache hash table size */
+#define VCSIZEBITS     16      /* log of stat cache hash table size */
+#define        VCSIZE          (opr_jhash_size(VCSIZEBITS))
 #define CBRSIZE                512     /* call back returns hash table size */
 #define        PIGGYSIZE       1350    /* max piggyback size */
 #define        MAXVOLS         128     /* max vols we can store */
 #define        MAXSYSNAME      128     /* max sysname (i.e. @sys) size */
 #define MAXNUMSYSNAMES 32      /* max that current constants allow */
+#define MAXROOTVOLNAMELEN      64      /* max length of root volume name */
 #define        NOTOKTIMEOUT    (2*3600)        /* time after which to timeout conns sans tokens */
 #define        NOPAG           0xffffffff
 
@@ -95,6 +119,8 @@ extern int afs_shuttingdown;
 
 #define AFS_MAXCBRSCALL        32      /* max to return in a given call (must be <= AFSCBMAX) */
 #define        VCACHE_FREE     5
+#define VCACHE_DYNAMIC_STRESSED 10000
+#define VCACHE_STRESS_LOGINTERVAL (60*60*4) /* 4 hours */
 #define        AFS_NRXPACKETS  80
 #define        AFS_RXDEADTIME  50
 #define AFS_HARDDEADTIME       120
@@ -139,6 +165,7 @@ struct sysname_info {
 #define        BOP_MOVE        5        /* ptr1 afs_uspc_param ptr2 sname ptr3 dname */
 #endif
 #define BOP_PARTIAL_STORE 6     /* parm1 is chunk to store */
+#define BOP_INVALIDATE_SEGMENTS 7 /* no parms: just uses the 'bp->vc' vcache */
 
 #define        B_DONTWAIT      1       /* On failure return; don't wait */
 
@@ -181,7 +208,7 @@ struct VenusFid {
     struct AFSFid Fid;
 };
 
-/* Temporary struct to be passed between afs_fid and afs_vget; in SunOS4.x we can only pass a maximum of 10 bytes for a handle (we ideally need 16!) */
+/* Temporary struct to be passed between afs_fid and afs_vget */
 struct SmallFid {
     afs_int32 Volume;
     afs_int32 CellAndUnique;
@@ -594,7 +621,7 @@ struct volume {
     afs_int32 roVol;
     afs_int32 backVol;
     afs_int32 rwVol;           /* For r/o vols, original read/write volume. */
-    afs_int32 accessTime;      /* last time we used it */
+    afs_int32 setupTime;       /* time volume was setup from vldb info */
     afs_int32 vtix;            /* volume table index */
     afs_int32 copyDate;                /* copyDate field, for tracking vol releases */
     afs_int32 expireTime;      /* for per-volume callbacks... */
@@ -632,7 +659,7 @@ struct SimpleLocks {
 #define CCore          0x00000010      /* storing a core file, needed since we don't get an open */
 #define CDirty         0x00000020      /* file has been modified since first open (... O_RDWR) */
 #define CSafeStore     0x00000040      /* close must wait for store to finish (should be in fd) */
-#define CMAPPED                0x00000080      /* Mapped files; primarily used by SunOS 4.0.x */
+#define CMAPPED                0x00000080      /* Mapped files */
 #define CNSHARE                0x00000100      /* support O_NSHARE semantics */
 #define CLied          0x00000200
 #define CTruth         0x00000400
@@ -707,6 +734,8 @@ struct SimpleLocks {
 #define        CPSIZE      2
 #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV)
 #define vrefCount   v->v_usecount
+#elif defined(AFS_SUN511_ENV)
+# define vrefCount v->v_count
 #else
 #define vrefCount   v.v_count
 #endif /* AFS_XBSD_ENV */
@@ -754,7 +783,7 @@ struct nbvdata {
 };
 #define VTOAFS(v) ((((struct nbvdata *)((v)->v_data)))->afsvc)
 #define AFSTOV(vc) ((vc)->v)
-#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
+#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_SUN511_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
 #define VTOAFS(v) ((struct vcache *)(v)->v_data)
 #define AFSTOV(vc) ((vc)->v)
 #else
@@ -828,7 +857,7 @@ struct multiPage_range {
  * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree)
  */
 struct vcache {
-#if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
+#if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_SUN511_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
     struct vnode *v;
 #else
     struct vnode v;            /* Has reference count in v.v_count */
@@ -1318,7 +1347,7 @@ struct afs_FetchOutput {
        avc->f.states |= CCore; /* causes close to be called later */ \
                                                                       \
        /* The cred and vnode holds will be released in afs_FlushActiveVcaches */  \
-       AFS_FAST_HOLD(avc);     /* So it won't disappear */           \
+       osi_Assert(osi_vnhold(avc) == 0);       /* So it won't disappear */        \
        CRKEEP(avc, acred); /* Should use a better place for the creds */ \
     }                                                                         \
     else {                                                                    \
@@ -1330,26 +1359,10 @@ struct afs_FetchOutput {
 
 #define        AFS_ZEROS   64          /* zero buffer */
 
-/*#define afs_DirtyPages(avc)  (((avc)->f.states & CDirty) || osi_VMDirty_p((avc)))*/
 #define        afs_DirtyPages(avc)     ((avc)->f.states & CDirty)
 
 #define afs_InReadDir(avc) (((avc)->f.states & CReadDir) && (avc)->readdir_pid == MyPidxx2Pid(MyPidxx))
 
-/* The PFlush algorithm makes use of the fact that Fid.Unique is not used in
-  below hash algorithms.  Change it if need be so that flushing algorithm
-  doesn't move things from one hash chain to another
-*/
-/* extern int afs_dhashsize; */
-#define        DCHash(v, c)    ((((v)->Fid.Vnode + (v)->Fid.Volume + (c))) & (afs_dhashsize-1))
-       /*Vnode, Chunk -> Hash table index */
-#define        DVHash(v)       ((((v)->Fid.Vnode + (v)->Fid.Volume )) & (afs_dhashsize-1))
-       /*Vnode -> Other hash table index */
-/* don't hash on the cell, our callback-breaking code sometimes fails to compute
-    the cell correctly, and only scans one hash bucket */
-#define        VCHash(fid)     (((fid)->Fid.Volume + (fid)->Fid.Vnode) & (VCSIZE-1))
-/* Hash only on volume to speed up volume callbacks. */
-#define VCHashV(fid) ((fid)->Fid.Volume & (VCSIZE-1))
-
 extern struct dcache **afs_indexTable; /*Pointers to in-memory dcache entries */
 extern afs_int32 *afs_indexUnique;     /*dcache entry Fid.Unique */
 extern afs_int32 *afs_dvnextTbl;       /*Dcache hash table links */
@@ -1357,6 +1370,9 @@ extern afs_int32 *afs_dcnextTbl;  /*Dcache hash table links */
 extern afs_int32 afs_cacheFiles;       /*Size of afs_indexTable */
 extern afs_int32 afs_cacheBlocks;      /*1K blocks in cache */
 extern afs_int32 afs_cacheStats;       /*Stat entries in cache */
+extern afs_int32 afs_freeDCCount;      /*Count of elts in freeDCList */
+extern afs_uint32 afs_CacheTooFullCount;
+extern afs_uint32 afs_WaitForCacheDrainCount;
 extern struct vcache *afs_vhashT[VCSIZE];      /*Stat cache hash table */
 extern struct afs_q afs_vhashTV[VCSIZE]; /* cache hash table on volume */
 extern afs_int32 afs_initState;        /*Initialization state */
@@ -1596,7 +1612,7 @@ extern int Afs_syscall(struct afssysa *uap, rval_t *rvp);
 
 /*
  * Various definitions for osi_sleep and its event hash table
- * DFBSD and SUNOS have no osi_sleep, and HPUX has its own hack for this stuff
+ * DFBSD has no osi_sleep, and HPUX has its own hack for this stuff
  */
 #define AFS_EVHASHSIZE 128     /* size of afs_evhasht, must be power of 2 */