hold-afs-xcell-lock-during-setserverprefs-20011113
[openafs.git] / src / afs / afs.h
index 8a957a6..4656f9d 100644 (file)
@@ -63,6 +63,7 @@ extern int afs_shuttingdown;
 #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 16          /* max that current constants allow */
 #define        NOTOKTIMEOUT    (2*3600)    /* time after which to timeout conns sans tokens */
 #define        NOPAG           0xffffffff
 #define AFS_NCBRS      300         /* max # of call back return entries */
@@ -74,6 +75,11 @@ extern int afs_shuttingdown;
 #define        AFS_RXDEADTIME  50
 #define AFS_HARDDEADTIME        120
 
+struct sysname_info {
+  char *name;
+  short offset;
+  char index, allocked;
+};
 
 /* flags to use with AFSOP_CACHEINIT */
 #define AFSCALL_INIT_MEMCACHE        0x1         /* use a memory-based cache */
@@ -110,13 +116,13 @@ extern int afs_shuttingdown;
 struct brequest {
     struct vcache *vnode;          /* vnode to use, with vrefcount bumped */
     struct AFS_UCRED *cred;        /* credentials to use for operation */
-    long parm[BPARMS];             /* random parameters - long's work for
-                                    * both 32 and 64 bit platforms.
-                                    */
-    afs_int32 code;                        /* return code */
+    afs_size_t size_parm[BPARMS];   /* random parameters */
+    void *ptr_parm[BPARMS];        /* pointer parameters */
+    afs_int32 code;                /* return code */
     short refCount;                /* use counter for this structure */
     char opcode;                   /* what to do (store, fetch, etc) */
     char flags;                            /* free, etc */
+    afs_int32 ts;                  /* counter "timestamp" */
 };
 
 struct SecretToken {
@@ -183,6 +189,7 @@ struct afs_cbr {
 #define        CNoSUID             2       /* 1 if no suid progs can run from this cell */
 #define CHasVolRef        16       /* Volumes were referenced in this cell*/
 #define CLinkedCell       32
+#define CAlias            64       /* This cell entry is an alias */
 
 struct cell {
     struct afs_q lruq;                      /* lru q next and prev */
@@ -195,6 +202,7 @@ struct cell {
     short states;                          /* state flags */
     short cellIndex;                       /* relative index number per cell */
     time_t timeout;                        /* data expire time, if non-zero */
+    char *realName;                        /* who this cell is an alias for */
 };
 
 #define        afs_PutCell(cellp, locktype)
@@ -321,6 +329,11 @@ struct srvAddr {
 #define        SRVR_ISDOWN                     0x20
 #define        SRVR_MULTIHOMED                 0x40
 #define        SRVR_ISGONE                     0x80
+#define        SNO_INLINEBULK                  0x100
+#define SNO_64BIT                       0x200 
+
+#define afs_serverSetNo64Bit(s) ((s)->srvr->server->flags |= SNO_64BIT)
+#define afs_serverHasNo64Bit(s) ((s)->srvr->server->flags & SNO_64BIT)
 
 struct server {
     union {
@@ -348,7 +361,7 @@ struct server {
     afs_int32 numDowntimeIncidents;    /* # (completed) downtime incidents */
     afs_int32 sumOfDowntimes;  /* Total downtime experienced, in seconds */
     struct srvAddr *addr;
-    char flags;                        /* Misc flags*/
+    afs_uint32 flags;                  /* Misc flags*/
 };
 
 #define        afs_PutServer(servp, locktype)  
@@ -474,36 +487,36 @@ struct SimpleLocks {
 };
 
 /* vcache state bits */
-#define        CStatd      1           /* has this file ever been stat'd? */
-#define CBackup            2           /* file is on a backup volume */
-#define        CRO         4           /* is it on a read-only volume */
-#define        CMValid     8           /* is the mount point info valid? */
-#define        CCore       0x10        /* storing a core file, needed since we don't get an open */
-#define CDirty      0x20        /* file has been modified since first open (... O_RDWR) */
-#define        CSafeStore  0x40        /* close must wait for store to finish (should be in fd) */
-#define        CMAPPED     0x80        /* Mapped files; primarily used by SunOS 4.0.x */
-#define        CNSHARE     0x100       /* support O_NSHARE semantics */
-#define        CLied       0x200
-#define        CTruth      0x400
+#define CStatd         0x00000001      /* has this file ever been stat'd? */
+#define CBackup                0x00000002      /* file is on a backup volume */
+#define CRO            0x00000004      /* is it on a read-only volume */
+#define CMValid                0x00000008      /* is the mount point info valid? */
+#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 CNSHARE                0x00000100      /* support O_NSHARE semantics */
+#define CLied          0x00000200
+#define CTruth         0x00000400
 #ifdef AFS_OSF_ENV
-#define        CWired      0x800       /* OSF hack only */
+#define CWired         0x00000800      /* OSF hack only */
 #else
-#define        CWRITE_IGN  0x800       /* Next OS hack only */
+#define CWRITE_IGN     0x00000800      /* Next OS hack only */
 #endif
-#define        CUnique     0x1000      /* vc's uniquifier - latest unifiquier for fid */
-#define        CForeign    0x2000      /* this is a non-afs vcache */
-#define CHasPages   0x4000
-#define CUnlinked   0x10000
-#define CBulkStat   0x20000    /* loaded by a bulk stat, and not ref'd since */
-#define CUnlinkedDel  0x40000
-#define CVFlushed   0x80000
-#define        CCore1      0x100000    /* osf1 core file; not same as CCore above */
-#define CWritingUFS 0x200000   /* to detect vm deadlock - used by sgi */
-#define CCreating   0x400000   /* avoid needless store after open truncate */
-#define CPageHog    0x800000   /* AIX - dumping large cores is a page hog. */
-#define CDCLock            0x200000    /* Vnode lock held over call to GetDownD */
-#define CBulkFetching 0x4000000 /* stats are being fetched by bulk stat */
-#define CExtendedFile 0x8000000 /* extended file via ftruncate call. */
+#define CUnique                0x00001000      /* vc's uniquifier - latest unifiquier for fid */
+#define CForeign       0x00002000      /* this is a non-afs vcache */
+#define CHasPages      0x00004000
+#define CUnlinked      0x00010000
+#define CBulkStat      0x00020000      /* loaded by a bulk stat, and not ref'd since */
+#define CUnlinkedDel   0x00040000
+#define CVFlushed      0x00080000
+#define CCore1         0x00100000      /* osf1 core file; not same as CCore above */
+#define CWritingUFS    0x00200000      /* to detect vm deadlock - used by sgi */
+#define CCreating      0x00400000      /* avoid needless store after open truncate */
+#define CPageHog       0x00800000      /* AIX - dumping large cores is a page hog. */
+#define CDCLock                0x02000000      /* Vnode lock held over call to GetDownD */
+#define CBulkFetching  0x04000000      /* stats are being fetched by bulk stat */
+#define CExtendedFile  0x08000000      /* extended file via ftruncate call. */
 
 /* vcache vstate bits */
 #define VRevokeWait   0x1
@@ -516,8 +529,24 @@ struct SimpleLocks {
 #define vrefCount   v.v_usecount
 #endif /* AFS_FBSD_ENV */
 
+#ifdef AFS_LINUX24_ENV
+#define VREFCOUNT(v)           atomic_read(&((vnode_t *) v)->v_count)
+#define VREFCOUNT_SET(v, c)    atomic_set(&((vnode_t *) v)->v_count, c)
+#define VREFCOUNT_DEC(v)       atomic_dec(&((vnode_t *) v)->v_count)
+#define VREFCOUNT_INC(v)       atomic_inc(&((vnode_t *) v)->v_count)
+#else
+#define VREFCOUNT(v)           ((v)->vrefCount)
+#define VREFCOUNT_SET(v, c)    (v)->vrefCount = c;
+#define VREFCOUNT_DEC(v)       (v)->vrefCount--;
+#define VREFCOUNT_INC(v)       (v)->vrefCount++;
+#endif
+
 #define        AFS_MAXDV   0x7fffffff      /* largest dataversion number */
+#ifdef AFS_64BIT_CLIENT
+#define AFS_NOTRUNC 0x7fffffffffffffffLL  /* largest positive int64 number */
+#else /* AFS_64BIT_CLIENT */
 #define        AFS_NOTRUNC 0x7fffffff      /* largest dataversion number */
+#endif /* AFS_64BIT_CLIENT */
 
 extern afs_int32 vmPageHog; /* counter for # of vnodes which are page hogs. */
 
@@ -529,8 +558,8 @@ struct      vtodc
        struct dcache * dc;
        afs_uint32              stamp;
        struct osi_file * f;
-       afs_uint32              minLoc; /* smallest offset into dc. */
-       afs_uint32              len;    /* largest offset into dc. */
+       afs_offs_t              minLoc; /* smallest offset into dc. */
+       afs_offs_t              len;    /* largest offset into dc. */
        };
 
 extern afs_uint32 afs_stampValue;              /* stamp for pair's usage */
@@ -547,7 +576,7 @@ struct vcache {
     struct vcache *hnext;              /* Hash next */
     struct VenusFid fid;
     struct mstat {
-        afs_uint32 Length;
+        afs_size_t Length;
         afs_hyper_t DataVersion;
         afs_uint32 Date;
         afs_uint32 Owner;
@@ -587,7 +616,7 @@ struct vcache {
     char *linkData;                    /* Link data if a symlink. */
     afs_hyper_t flushDV;                       /* data version last flushed from text */
     afs_hyper_t mapDV;                 /* data version last flushed from map */
-    afs_uint32 truncPos;                       /* truncate file to this position at next store */
+    afs_size_t truncPos;                       /* truncate file to this position at next store */
     struct server *callback;           /* The callback host, if any */
     afs_uint32 cbExpires;                      /* time the callback expires */
     struct afs_q callsort;              /* queue in expiry order, sort of */
@@ -838,10 +867,10 @@ struct fcache {
 struct dcache {
     struct afs_q lruq;         /* Free queue for in-memory images */
     afs_rwlock_t lock;         /* XXX */
-    short refCount;            /* Associated reference count. */
+    afs_size_t validPos;       /* number of valid bytes during fetch */
     afs_int32 index;                   /* The index in the CacheInfo file*/
+    short refCount;            /* Associated reference count. */
     short flags;               /* more flags bits */
-    afs_int32 validPos;                /* number of valid bytes during fetch */
     struct fcache f;           /* disk image */
     afs_int32 stamp;           /* used with vtodc struct for hints */
 };
@@ -939,7 +968,10 @@ extern struct brequest afs_brs[NBRS];              /* request structures */
 #define        FVHash(acell,avol)  (((avol)+(acell)) & (NFENTRIES-1))
 
 extern struct cell         *afs_GetCell();
+extern struct cell         *afs_GetCellNoLock();
 extern struct cell         *afs_GetCellByName();
+extern struct cell         *afs_GetCellByName2();
+extern struct cell         *afs_GetCellByIndex();
 extern struct unixuser     *afs_GetUser();
 extern struct volume       *afs_GetVolume();
 extern struct volume       *afs_GetVolumeByName();
@@ -972,6 +1004,19 @@ extern void afs_shutdown();
 /* afs_osifile.c */
 extern void shutdown_osifile();
 
+/* afs_dynroot.c */
+extern int afs_IsDynrootFid();
+extern void afs_GetDynrootFid();
+extern int afs_IsDynroot();
+extern void afs_RefreshDynroot();
+extern void afs_GetDynroot();
+extern void afs_PutDynroot();
+extern int afs_DynrootNewVnode();
+extern int afs_SetDynrootEnable();
+extern int afs_GetDynrootEnable();
+extern int afs_DynrootVOPSymlink();
+extern int afs_DynrootVOPRemove();
+
 
 /* Performance hack - we could replace VerifyVCache2 with the appropriate
  * GetVCache incantation, and could eliminate even this code from afs_UFSRead 
@@ -1030,6 +1075,7 @@ extern int afs_CacheTooFull;
  * afs_GetDownD wakes those processes once the cache is 95% full
  * (CM_CACHESIZEDRAINEDPCT).
  */
+extern void afs_MaybeWakeupTruncateDaemon();
 extern void afs_CacheTruncateDaemon();
 extern int afs_WaitForCacheDrain;
 #define CM_MAXDISCARDEDCHUNKS  16      /* # of chunks */
@@ -1045,19 +1091,6 @@ extern int afs_WaitForCacheDrain;
      afs_freeDCCount - afs_discardDCCount < \
        ((100-CM_DCACHECOUNTFREEPCT)*afs_cacheFiles)/100)
 
-#define        afs_MaybeWakeupTruncateDaemon() \
-    do { \
-       if (!afs_CacheTooFull && afs_CacheIsTooFull()) { \
-           afs_CacheTooFull = 1; \
-            if (!afs_TruncateDaemonRunning) { \
-               afs_osi_Wakeup((char *)afs_CacheTruncateDaemon); \
-           } \
-       } else if (!afs_TruncateDaemonRunning && \
-                  afs_blocksDiscarded > CM_MAXDISCARDEDCHUNKS) { \
-           afs_osi_Wakeup((char *)afs_CacheTruncateDaemon); \
-       } \
-    } while (0)
-
 /* Handy max length of a numeric string. */
 #define        CVBS    12  /* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */