fileserver-cbs-raise-limit-by-killing-goofy-u-short-indexing-20021008
authorDerrick Brashear <shadow@dementia.org>
Wed, 9 Oct 2002 16:54:48 +0000 (16:54 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 9 Oct 2002 16:54:48 +0000 (16:54 +0000)
i probably missed something here.

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

i did miss something. also, change FileEntry padding and axe useless comment

====================

try, try again

====================

once more with feeling

====================

make typing of the indexes into timeout[] match

====================

make struct CallBack a multiple of 32 bit so the weird math works again

src/viced/callback.c
src/viced/host.h
src/viced/viced.c

index 05ca3a8..e5be078 100644 (file)
@@ -134,38 +134,33 @@ int ShowProblems = 1;
 /* max time to break a callback, otherwise client is dead or net is hosed */
 #define MAXCBT 25  
 
-#define u_short        unsigned short
 #define u_byte unsigned char
 
 struct cbcounters cbstuff;
 
 struct cbstruct {
   struct host * hp;
-  u_short thead;
+  afs_uint32 thead;
 } ;
 
 struct FileEntry {
-    afs_uint32     vnode;      /* XXX This was u_short XXX */
+    afs_uint32     vnode;      
     afs_uint32         unique;
     afs_uint32     volid;
-    u_short        fnext;
-    u_short        ncbs;
-    u_short        firstcb;
-    u_short        spare;
-#if defined(AFS_ALPHA_ENV) || defined(AFS_ALPHA_LINUX20_ENV)
-    u_short        spare1;
-    u_short        spare2;
-#endif
+    afs_uint32     fnext;
+    afs_uint32     ncbs;
+    afs_uint32     firstcb;
 } *FE; /* Don't use FE[0] */
 
 struct CallBack {
-    u_short        cnext;              /* Next call back entry */
-    u_short        fhead;              /* Head of this call back chain */
+    afs_uint32     cnext;              /* Next call back entry */
+    afs_uint32     fhead;              /* Head of this call back chain */
     u_byte         thead;              /* Head of timeout chain */
     u_byte         status;             /* Call back status; see definitions, below */
-    u_short        hhead;              /* Head of host table chain */
-    u_short        tprev, tnext;       /* Timeout chain */
-    u_short        hprev, hnext;       /* Chain from host table */
+    afs_uint32     hhead;              /* Head of host table chain */
+    afs_uint32     tprev, tnext;       /* Timeout chain */
+    afs_uint32     hprev, hnext;       /* Chain from host table */
+    unsigned short  spare;              /* make it a multiple of 32 bits. */
 } *CB; /* Don't use CB[0] */
 
 /* status bits for status field of CallBack structure */
@@ -236,7 +231,7 @@ static int MinTimeOut = (7*60);
 #define ServerBias       (3*60)
 
 /* Heads of CB queues; a timeout index is 1+index into this array */
-static u_short timeout[128];
+static afs_uint32 timeout[128];
 
 /* Convert cbtime to timeout queue index */
 #define TIndex(cbtime)  (((cbtime)&127)+1)
@@ -268,7 +263,7 @@ struct object {
 struct VCBParams {
   struct cbstruct cba[MAX_CB_HOSTS];  /* re-entrant storage */
   unsigned int ncbas;
-  unsigned short thead;     /* head of timeout queue for youngest callback */
+  afs_uint32 thead;     /* head of timeout queue for youngest callback */
   struct AFSFid *fid;
 };
 
@@ -281,15 +276,15 @@ static struct CallBack *iGetCB(register int *nused);
 static int iFreeCB(register struct CallBack *cb, register int *nused);
 static struct FileEntry *iGetFE(register int *nused);
 static int iFreeFE(register struct FileEntry *fe, register int *nused);
-static int TAdd(register struct CallBack *cb, register u_short *thead);
+static int TAdd(register struct CallBack *cb, register afs_uint32 *thead);
 static int TDel(register struct CallBack *cb);
 static int HAdd(register struct CallBack *cb, register struct host *host);
 static int HDel(register struct CallBack *cb);
 static int CDel(struct CallBack *cb);
-static int CDelPtr(register struct FileEntry *fe, register u_short *cbp);
-static u_short *FindCBPtr(struct FileEntry *fe, struct host *host);
+static int CDelPtr(register struct FileEntry *fe, register afs_uint32 *cbp);
+static afs_uint32 *FindCBPtr(struct FileEntry *fe, struct host *host);
 static int FDel(register struct FileEntry *fe);
-static int AddCallBack1_r(struct host *host, AFSFid *fid, u_short *thead, int type, int locked);
+static int AddCallBack1_r(struct host *host, AFSFid *fid, afs_uint32 *thead, int type, int locked);
 static void MultiBreakCallBack_r(struct cbstruct cba[], int ncbas, struct AFSCBFids *afidp, struct host *xhost);
 static int MultiBreakVolumeCallBack_r(struct host *host, int isheld, struct VCBParams *parms);
 static int MultiBreakVolumeCallBack(struct host *host, int isheld, struct VCBParams *parms);
@@ -305,7 +300,7 @@ static int GetSomeSpace_r(struct host *hostp, int locked);
 extern void ShutDown();
 
 #define VHASH 512      /* Power of 2 */
-static u_short HashTable[VHASH]; /* File entry hash table */
+static afs_uint32 HashTable[VHASH]; /* File entry hash table */
 #define VHash(volume, unique) (((volume)+(unique))&(VHASH-1))
 
 static struct FileEntry *FindFE (register AFSFid *fid)
@@ -365,7 +360,7 @@ static int iFreeFE(register struct FileEntry *fe, register int *nused)
 }
 
 /* Add cb to end of specified timeout list */
-static int TAdd(register struct CallBack *cb, register u_short *thead)
+static int TAdd(register struct CallBack *cb, register afs_uint32 *thead)
 {
     if (!*thead) {
        (*thead) = cb->tnext = cb->tprev = cbtoi(cb);
@@ -388,7 +383,7 @@ static int TAdd(register struct CallBack *cb, register u_short *thead)
 /* Delete call back entry from timeout list */
 static int TDel(register struct CallBack *cb)
 {
-    register u_short *thead = itot(cb->thead);
+    register afs_uint32 *thead = itot(cb->thead);
 
     if (*thead == cbtoi(cb))
        *thead = (*thead == cb->tnext? 0: cb->tnext);
@@ -419,7 +414,7 @@ static int HAdd(register struct CallBack *cb, register struct host *host)
 /* Delete call back entry from host list */
 static int HDel(register struct CallBack *cb)
 {
-    register u_short *hhead = &h_itoh(cb->hhead)->cblist;
+    register afs_uint32 *hhead = &h_itoh(cb->hhead)->cblist;
 
     if (*hhead == cbtoi(cb))
        *hhead = (*hhead == cb->hnext? 0: cb->hnext);
@@ -436,7 +431,7 @@ static int CDel(struct CallBack *cb)
 {
     int cbi = cbtoi(cb);
     struct FileEntry *fe = itofe(cb->fhead);
-    register u_short *cbp;
+    register afs_uint32 *cbp;
     register int safety;
 
     for (safety = 0, cbp = &fe->firstcb; *cbp && *cbp != cbi; 
@@ -460,7 +455,7 @@ static int CDel(struct CallBack *cb)
 int Ccdelpt=0, CcdelB=0;
 
 static int CDelPtr(register struct FileEntry *fe, 
-       register u_short *cbp)
+       register afs_uint32 *cbp)
 {
     register struct CallBack *cb;
 
@@ -477,11 +472,11 @@ static int CDelPtr(register struct FileEntry *fe,
     return 0;
 }
 
-static u_short *FindCBPtr(struct FileEntry *fe, struct host *host)
+static afs_uint32 *FindCBPtr(struct FileEntry *fe, struct host *host)
 {
     register afs_uint32 hostindex = h_htoi(host);
     register struct CallBack *cb;
-    register u_short *cbp;
+    register afs_uint32 *cbp;
     register int safety;
 
     for (safety = 0, cbp = &fe->firstcb; *cbp; cbp = &cb->cnext, safety++) {
@@ -501,7 +496,7 @@ static u_short *FindCBPtr(struct FileEntry *fe, struct host *host)
 static int FDel(register struct FileEntry *fe)
 {
     register int fei = fetoi(fe);
-    register unsigned short *p = &HashTable[VHash(fe->volid, fe->unique)];
+    register afs_uint32 *p = &HashTable[VHash(fe->volid, fe->unique)];
 
     while (*p && *p != fei)
        p = &itofe(*p)->fnext;
@@ -580,7 +575,7 @@ afs_int32 XCallBackBulk_r(struct host *ahost, struct AFSFid *fids,
  * as well. If so, the host->ResetDone should probably be set to 0,
  * and we probably don't want to return a callback promise to the
  * cache manager, either. */
-int AddCallBack1(struct host *host, AFSFid *fid, u_short *thead, 
+int AddCallBack1(struct host *host, AFSFid *fid, afs_uint32 *thead, 
        int type, int locked)
 {
     int retVal;
@@ -597,14 +592,14 @@ int AddCallBack1(struct host *host, AFSFid *fid, u_short *thead,
     return retVal;
 }
 
-static int AddCallBack1_r(struct host *host, AFSFid *fid, u_short *thead, 
+static int AddCallBack1_r(struct host *host, AFSFid *fid, afs_uint32 *thead, 
        int type, int locked)
 {
     struct FileEntry *fe;
     struct CallBack *cb = 0, *lastcb = 0;
     struct FileEntry *newfe = 0;
     afs_uint32 time_out;
-    u_short *Thead = thead;
+    afs_uint32 *Thead = thead;
     struct CallBack *newcb = 0;
     int safety;
     
@@ -754,7 +749,7 @@ static void MultiBreakCallBack_r(struct cbstruct cba[], int ncbas,
   multi_Rx(conns, j) {
     multi_RXAFSCB_CallBack(afidp, &tc);
     if (multi_error) {
-      unsigned short idx ;
+      afs_uint32 idx ;
       struct host *hp;
       char hoststr[16];
 
@@ -913,7 +908,7 @@ int BreakCallBack(struct host *xhost, AFSFid *fid, int flag)
 int DeleteCallBack(struct host *host, AFSFid *fid)
 {
     register struct FileEntry *fe;
-    register u_short *pcb;
+    register afs_uint32 *pcb;
     char hoststr[16];
 
     cbstuff.DeleteCallBacks++;
@@ -1029,7 +1024,7 @@ extern afsUUID FS_HostUUID;
 int BreakDelayedCallBacks_r(struct host *host)
 {
     struct AFSFid fids[AFSCBMAX];
-    u_short thead[AFSCBMAX];
+    u_byte thead[AFSCBMAX]; /* This should match thead in struct Callback */
     int cbi, first, nfids;
     struct CallBack *cb;
     struct interfaceAddr interf;
@@ -1212,12 +1207,12 @@ int BreakVolumeCallBacks(afs_uint32 volume)
 {
     struct AFSFid fid;
     int hash;
-    u_short *feip;
+    afs_uint32 *feip;
     struct CallBack *cb;
     struct FileEntry *fe;
     struct host *host;
     struct VCBParams henumParms;
-    unsigned short tthead = 0;  /* zero is illegal value */
+    afs_uint32 tthead = 0;  /* zero is illegal value */
 
     H_LOCK
     fid.Volume = volume, fid.Vnode = fid.Unique = 0;
@@ -1285,7 +1280,7 @@ int CleanupTimedOutCallBacks(void)
 int CleanupTimedOutCallBacks_r(void)
 {
     afs_uint32 now = CBtime(FT_ApproxTime());
-    register u_short *thead;
+    register afs_uint32 *thead;
     register struct CallBack *cb;
     register int ntimedout = 0;
     char hoststr[16];
@@ -1631,7 +1626,7 @@ int main(int argc, char **argv)
     }
     if (all || vol) {
        register hash;
-       register u_short *feip;
+       register afs_uint32 *feip;
        register struct CallBack *cb;
        register struct FileEntry *fe;
 
@@ -1651,7 +1646,7 @@ int main(int argc, char **argv)
        }
     }
     if (cbi) {
-       u_short cfirst = cbi;
+       afs_uint32 cfirst = cbi;
        do {
            cb = itocb(cbi);
            PrintCB(cb,now);
index 007f24f..68b2fdf 100644 (file)
@@ -81,13 +81,13 @@ struct host {
     struct client       *FirstClient;  /* first connection from host */
     afs_uint32 cpsCall;        /* time of last cps call from this host */
     struct Interface*  interface;      /* all alternate addr for client */
-    unsigned short      cblist;                /* Call back list for this host */
+    afs_uint32      cblist;            /* Call back list for this host */
     /*
      * These don't get zeroed, keep them at the end. If index doesn't
      * follow an unsigned short then we need to pad to ensure that
-     * the index fields isn't zeroed.
+     * the index fields isn't zeroed. XXX
      */
-    unsigned short      index;          /* Host table index, for vicecb.c */
+    afs_uint32      index;          /* Host table index, for vicecb.c */
     struct Lock         lock;           /* Write lock for synchronization of
                                      VenusDown flag */
 #ifdef AFS_PTHREAD_ENV
@@ -180,9 +180,9 @@ extern int h_Lock_r();
 #define h_Unlock(host)  ReleaseWriteLock(&(host)->lock)
 #define h_Unlock_r(host)  ReleaseWriteLock(&(host)->lock)
 
-#define        AddCallBack(host, fid)  AddCallBack1((host), (fid), (u_short *)0, 1/*CB_NORMAL*/, 0)
-#define        AddVolCallBack(host, fid) AddCallBack1((host), (fid), (u_short *)0, 3/*CB_VOLUME*/, 0)
-#define        AddBulkCallBack(host, fid) AddCallBack1((host), (fid), (u_short *)0, 4/*CB_BULK*/, 0)
+#define        AddCallBack(host, fid)  AddCallBack1((host), (fid), (afs_uint32 *)0, 1/*CB_NORMAL*/, 0)
+#define        AddVolCallBack(host, fid) AddCallBack1((host), (fid), (afs_uint32 *)0, 3/*CB_VOLUME*/, 0)
+#define        AddBulkCallBack(host, fid) AddCallBack1((host), (fid), (afs_uint32 *)0, 4/*CB_BULK*/, 0)
 
 /* operations on the global linked list of hosts */
 #define h_InsertList_r(h)      (h)->next =  hostList;                  \
index 2298da1..30e42b2 100644 (file)
@@ -1145,8 +1145,8 @@ static ParseArgs(argc, argv)
            if (!strcmp(argv[i], "-cb")) {
                Sawcbs = 1;
                numberofcbs = atoi(argv[++i]);
-               if ((numberofcbs < 10000) || (numberofcbs > 65535)) {
-                   printf("number of cbs %d invalid; must be between 10000 and 65535\n",
+               if ((numberofcbs < 10000) || (numberofcbs > 4294967295)) {
+                   printf("number of cbs %d invalid; must be between 10000 and 4294967295\n",
                           numberofcbs);
                    return -1;
                }