Index: openafs/src/WINNT/afsd/cm_buf.c
diff -c openafs/src/WINNT/afsd/cm_buf.c:1.31.2.36 openafs/src/WINNT/afsd/cm_buf.c:1.31.2.38
*** openafs/src/WINNT/afsd/cm_buf.c:1.31.2.36	Thu Mar  6 20:14:13 2008
--- openafs/src/WINNT/afsd/cm_buf.c	Thu May  8 01:27:14 2008
***************
*** 89,110 ****
  /* set this to 1 when we are terminating to prevent access attempts */
  static int buf_ShutdownFlag = 0;
  
  void buf_HoldLocked(cm_buf_t *bp)
  {
      osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic");
!     InterlockedIncrement(&bp->refCount);
  }
  
  /* hold a reference to an already held buffer */
  void buf_Hold(cm_buf_t *bp)
  {
      lock_ObtainRead(&buf_globalLock);
!     buf_HoldLocked(bp);
      lock_ReleaseRead(&buf_globalLock);
  }
  
  /* code to drop reference count while holding buf_globalLock */
  void buf_ReleaseLocked(cm_buf_t *bp, afs_uint32 writeLocked)
  {
      afs_int32 refCount;
  
--- 89,135 ----
  /* set this to 1 when we are terminating to prevent access attempts */
  static int buf_ShutdownFlag = 0;
  
+ #ifdef DEBUG_REFCOUNT
+ void buf_HoldLockedDbg(cm_buf_t *bp, char *file, long line)
+ #else
  void buf_HoldLocked(cm_buf_t *bp)
+ #endif
  {
+     afs_int32 refCount;
+ 
      osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic");
!     refCount = InterlockedIncrement(&bp->refCount);
! #ifdef DEBUG_REFCOUNT
!     osi_Log2(afsd_logp,"buf_HoldLocked bp 0x%p ref %d",bp, refCount);
!     afsi_log("%s:%d buf_HoldLocked bp 0x%p, ref %d", file, line, bp, refCount);
! #endif
  }
  
  /* hold a reference to an already held buffer */
+ #ifdef DEBUG_REFCOUNT
+ void buf_HoldDbg(cm_buf_t *bp, char *file, long line)
+ #else
  void buf_Hold(cm_buf_t *bp)
+ #endif
  {
+     afs_int32 refCount;
+ 
      lock_ObtainRead(&buf_globalLock);
!     osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic");
!     refCount = InterlockedIncrement(&bp->refCount);
! #ifdef DEBUG_REFCOUNT
!     osi_Log2(afsd_logp,"buf_Hold bp 0x%p ref %d",bp, refCount);
!     afsi_log("%s:%d buf_Hold bp 0x%p, ref %d", file, line, bp, refCount);
! #endif
      lock_ReleaseRead(&buf_globalLock);
  }
  
  /* code to drop reference count while holding buf_globalLock */
+ #ifdef DEBUG_REFCOUNT
+ void buf_ReleaseLockedDbg(cm_buf_t *bp, afs_uint32 writeLocked, char *file, long line)
+ #else
  void buf_ReleaseLocked(cm_buf_t *bp, afs_uint32 writeLocked)
+ #endif
  {
      afs_int32 refCount;
  
***************
*** 117,122 ****
--- 142,151 ----
      osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic");
  
      refCount = InterlockedDecrement(&bp->refCount);
+ #ifdef DEBUG_REFCOUNT
+     osi_Log3(afsd_logp,"buf_ReleaseLocked %s bp 0x%p ref %d",writeLocked?"write":"read", bp, refCount);
+     afsi_log("%s:%d buf_ReleaseLocked %s bp 0x%p, ref %d", file, line, writeLocked?"write":"read", bp, refCount);
+ #endif
  #ifdef DEBUG
      if (refCount < 0)
  	osi_panic("buf refcount 0",__FILE__,__LINE__);;
***************
*** 149,155 ****
--- 178,188 ----
  }       
  
  /* release a buffer.  Buffer must be referenced, but unlocked. */
+ #ifdef DEBUG_REFCOUNT
+ void buf_ReleaseDbg(cm_buf_t *bp, char *file, long line)
+ #else
  void buf_Release(cm_buf_t *bp)
+ #endif
  {
      afs_int32 refCount;
  
***************
*** 157,162 ****
--- 190,199 ----
      osi_assertx(bp->magic == CM_BUF_MAGIC,"incorrect cm_buf_t magic");
  
      refCount = InterlockedDecrement(&bp->refCount);
+ #ifdef DEBUG_REFCOUNT
+     osi_Log2(afsd_logp,"buf_Release bp 0x%p ref %d", bp, refCount);
+     afsi_log("%s:%d buf_ReleaseLocked bp 0x%p, ref %d", file, line, bp, refCount);
+ #endif
  #ifdef DEBUG
      if (refCount < 0)
  	osi_panic("buf refcount 0",__FILE__,__LINE__);;
***************
*** 181,187 ****
  /* incremental sync daemon.  Writes all dirty buffers every 5000 ms */
  void buf_IncrSyncer(long parm)
  {
!     cm_buf_t **bpp, *bp;
      long i;				/* counter */
      long wasDirty = 0;
      cm_req_t req;
--- 218,224 ----
  /* incremental sync daemon.  Writes all dirty buffers every 5000 ms */
  void buf_IncrSyncer(long parm)
  {
!     cm_buf_t **bpp, *bp, *prevbp;
      long i;				/* counter */
      long wasDirty = 0;
      cm_req_t req;
***************
*** 198,209 ****
  
  	wasDirty = 0;
  
!         /* now go through our percentage of the buffers */
!         for (bpp = &cm_data.buf_dirtyListp; bp = *bpp; ) {
  	    /* all dirty buffers are held when they are added to the
  	     * dirty list.  No need for an additional hold.
  	     */
              lock_ObtainMutex(&bp->mx);
  	    if (bp->flags & CM_BUF_DIRTY) {
  		/* start cleaning the buffer; don't touch log pages since
   		 * the log code counts on knowing exactly who is writing
--- 235,249 ----
  
  	wasDirty = 0;
  
!         /* go through all of the dirty buffers */
!         lock_ObtainRead(&buf_globalLock);
!         for (bpp = &cm_data.buf_dirtyListp, prevbp = NULL; bp = *bpp; ) {
!             lock_ReleaseRead(&buf_globalLock);
  	    /* all dirty buffers are held when they are added to the
  	     * dirty list.  No need for an additional hold.
  	     */
              lock_ObtainMutex(&bp->mx);
+ 
  	    if (bp->flags & CM_BUF_DIRTY) {
  		/* start cleaning the buffer; don't touch log pages since
   		 * the log code counts on knowing exactly who is writing
***************
*** 221,238 ****
              if (!(bp->flags & CM_BUF_DIRTY)) {
                  /* remove the buffer from the dirty list */
                  lock_ObtainWrite(&buf_globalLock);
                  *bpp = bp->dirtyp;
                  bp->dirtyp = NULL;
                  if (cm_data.buf_dirtyListp == NULL)
                      cm_data.buf_dirtyListEndp = NULL;
                  buf_ReleaseLocked(bp, TRUE);
!                 lock_ReleaseWrite(&buf_globalLock);
              } else {
                  /* advance the pointer so we don't loop forever */
                  bpp = &bp->dirtyp;
              }
              lock_ReleaseMutex(&bp->mx);
          }	/* for loop over a bunch of buffers */
      }		/* whole daemon's while loop */
  }
  
--- 261,290 ----
              if (!(bp->flags & CM_BUF_DIRTY)) {
                  /* remove the buffer from the dirty list */
                  lock_ObtainWrite(&buf_globalLock);
+ #ifdef DEBUG_REFCOUNT
+                 if (bp->dirtyp == NULL && bp != cm_data.buf_dirtyListEndp) {
+                     osi_Log1(afsd_logp,"buf_IncrSyncer bp 0x%p list corruption",bp);
+                     afsi_log("buf_IncrSyncer bp 0x%p list corruption", bp);
+                 }
+ #endif
                  *bpp = bp->dirtyp;
                  bp->dirtyp = NULL;
+                 bp->flags &= ~CM_BUF_INDL;
                  if (cm_data.buf_dirtyListp == NULL)
                      cm_data.buf_dirtyListEndp = NULL;
+                 else if (cm_data.buf_dirtyListEndp == bp)
+                     cm_data.buf_dirtyListEndp = prevbp;
                  buf_ReleaseLocked(bp, TRUE);
!                 lock_ConvertWToR(&buf_globalLock);
              } else {
                  /* advance the pointer so we don't loop forever */
+                 lock_ObtainRead(&buf_globalLock);
                  bpp = &bp->dirtyp;
+                 prevbp = bp;
              }
              lock_ReleaseMutex(&bp->mx);
          }	/* for loop over a bunch of buffers */
+         lock_ReleaseRead(&buf_globalLock);
      }		/* whole daemon's while loop */
  }
  
***************
*** 812,818 ****
  		 * do not want to allow the buffer to be added
  		 * to the free list.
  		 */
!                 bp->refCount--;
                  lock_ReleaseWrite(&buf_globalLock);
                  lock_ReleaseRead(&scp->bufCreateLock);
                  return CM_BUF_EXISTS;
--- 864,874 ----
  		 * do not want to allow the buffer to be added
  		 * to the free list.
  		 */
!                 afs_int32 refCount = InterlockedDecrement(&bp->refCount);
! #ifdef DEBUG_REFCOUNT
!                 osi_Log2(afsd_logp,"buf_GetNewLocked bp 0x%p ref %d", bp, refCount);
!                 afsi_log("%s:%d buf_GetNewLocked bp 0x%p, ref %d", __FILE__, __LINE__, bp, refCount);
! #endif
                  lock_ReleaseWrite(&buf_globalLock);
                  lock_ReleaseRead(&scp->bufCreateLock);
                  return CM_BUF_EXISTS;
***************
*** 955,961 ****
  
  	    /* prepare to return it.  Give it a refcount */
              bp->refCount = 1;
!                         
              lock_ReleaseWrite(&buf_globalLock);
              lock_ReleaseRead(&scp->bufCreateLock);
              *bufpp = bp;
--- 1011,1020 ----
  
  	    /* prepare to return it.  Give it a refcount */
              bp->refCount = 1;
! #ifdef DEBUG_REFCOUNT
!             osi_Log2(afsd_logp,"buf_GetNewLocked bp 0x%p ref %d", bp, 1);
!             afsi_log("%s:%d buf_GetNewLocked bp 0x%p, ref %d", __FILE__, __LINE__, bp, 1);
! #endif
              lock_ReleaseWrite(&buf_globalLock);
              lock_ReleaseRead(&scp->bufCreateLock);
              *bufpp = bp;
***************
*** 1273,1279 ****
           * already there.
           */
          lock_ObtainWrite(&buf_globalLock);
!         if (bp->dirtyp == NULL && cm_data.buf_dirtyListEndp != bp) {
              buf_HoldLocked(bp);
              if (!cm_data.buf_dirtyListp) {
                  cm_data.buf_dirtyListp = cm_data.buf_dirtyListEndp = bp;
--- 1332,1338 ----
           * already there.
           */
          lock_ObtainWrite(&buf_globalLock);
!         if (!(bp->flags & CM_BUF_INDL)) {
              buf_HoldLocked(bp);
              if (!cm_data.buf_dirtyListp) {
                  cm_data.buf_dirtyListp = cm_data.buf_dirtyListEndp = bp;
***************
*** 1282,1287 ****
--- 1341,1347 ----
                  cm_data.buf_dirtyListEndp = bp;
              }
              bp->dirtyp = NULL;
+             bp->flags |= CM_BUF_INDL;
          }
          lock_ReleaseWrite(&buf_globalLock);
      }
***************
*** 1542,1551 ****
              buf_WaitIO(scp, bp);
              lock_ReleaseMutex(&bp->mx);
  
!             code = (*cm_buf_opsp->Stabilizep)(scp, userp, reqp);
!             if (code && code != CM_ERROR_BADFD) 
!                 goto skip;
! 
              if (code == CM_ERROR_BADFD) {
                  /* if the scp's FID is bad its because we received VNOVNODE 
                   * when attempting to FetchStatus before the write.  This
--- 1602,1617 ----
              buf_WaitIO(scp, bp);
              lock_ReleaseMutex(&bp->mx);
  
!             /* 
!              * if the error for the previous buffer was BADFD
!              * then all buffers for the FID are bad.  Do not
!              * attempt to stabalize.
!              */
!             if (code != CM_ERROR_BADFD) {
!                 code = (*cm_buf_opsp->Stabilizep)(scp, userp, reqp);
!                 if (code && code != CM_ERROR_BADFD) 
!                     goto skip;
!             }
              if (code == CM_ERROR_BADFD) {
                  /* if the scp's FID is bad its because we received VNOVNODE 
                   * when attempting to FetchStatus before the write.  This
***************
*** 1774,1782 ****
      StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_FreeListEndp.\r\n", cookie);
      WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
  
!     StringCbPrintfA(output, sizeof(output), "%s - dumping buf_dirtyListEndp\r\n", cookie);
      WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
!     for(bp = cm_data.buf_dirtyListEndp; bp; bp=(cm_buf_t *) osi_QPrev(&bp->q)) {
  	StringCbPrintfA(output, sizeof(output), 
  			 "%s bp=0x%08X, fid (cell=%d, volume=%d, "
  			 "vnode=%d, unique=%d), offset=%x:%08x, dv=%I64d, "
--- 1840,1848 ----
      StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_FreeListEndp.\r\n", cookie);
      WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
  
!     StringCbPrintfA(output, sizeof(output), "%s - dumping buf_dirtyListp\r\n", cookie);
      WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
!     for(bp = cm_data.buf_dirtyListp; bp; bp=bp->dirtyp) {
  	StringCbPrintfA(output, sizeof(output), 
  			 "%s bp=0x%08X, fid (cell=%d, volume=%d, "
  			 "vnode=%d, unique=%d), offset=%x:%08x, dv=%I64d, "
***************
*** 1787,1793 ****
  			 bp->cmFlags, bp->refCount);
  	WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
      }
!     StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_dirtyListEndp.\r\n", cookie);
      WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
  
      if (lock)
--- 1853,1859 ----
  			 bp->cmFlags, bp->refCount);
  	WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
      }
!     StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_dirtyListp.\r\n", cookie);
      WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
  
      if (lock)
Index: openafs/src/WINNT/afsd/cm_buf.h
diff -c openafs/src/WINNT/afsd/cm_buf.h:1.12.4.13 openafs/src/WINNT/afsd/cm_buf.h:1.12.4.14
*** openafs/src/WINNT/afsd/cm_buf.h:1.12.4.13	Sun Mar  2 16:56:18 2008
--- openafs/src/WINNT/afsd/cm_buf.h	Thu Apr 24 12:22:44 2008
***************
*** 104,110 ****
  #define CM_BUF_INLRU	0x10	/* in lru queue */
  #define CM_BUF_ERROR	0x20	/* something went wrong on delayed write */
  #define CM_BUF_WAITING	0x40	/* someone's waiting for a flag to change */
! 
  #define CM_BUF_EOF	0x100	/* read 0 bytes; used for detecting EOF */
  
  typedef struct cm_buf_ops {
--- 104,110 ----
  #define CM_BUF_INLRU	0x10	/* in lru queue */
  #define CM_BUF_ERROR	0x20	/* something went wrong on delayed write */
  #define CM_BUF_WAITING	0x40	/* someone's waiting for a flag to change */
! #define CM_BUF_INDL     0x80    /* in the dirty list */
  #define CM_BUF_EOF	0x100	/* read 0 bytes; used for detecting EOF */
  
  typedef struct cm_buf_ops {
***************
*** 124,138 ****
  
  extern long buf_CountFreeList(void);
  
  extern void buf_Release(cm_buf_t *);
  
  extern void buf_Hold(cm_buf_t *);
  
- extern void buf_WaitIO(cm_scache_t *, cm_buf_t *);
- 
  extern void buf_ReleaseLocked(cm_buf_t *, afs_uint32);
  
  extern void buf_HoldLocked(cm_buf_t *);
  
  extern cm_buf_t *buf_FindLocked(struct cm_scache *, osi_hyper_t *);
  
--- 124,153 ----
  
  extern long buf_CountFreeList(void);
  
+ #ifdef DEBUG_REFCOUNT
+ extern void buf_ReleaseDbg(cm_buf_t *, char *, long);
+ 
+ extern void buf_HoldDbg(cm_buf_t *, char *, long);
+ 
+ extern void buf_ReleaseLockedDbg(cm_buf_t *, afs_uint32, char *, long);
+ 
+ extern void buf_HoldLockedDbg(cm_buf_t *, char *, long);
+ 
+ #define buf_Release(bufp) buf_ReleaseDbg(bufp, __FILE__, __LINE__)
+ #define buf_Hold(bufp)    buf_HoldDbg(bufp, __FILE__, __LINE__)
+ #define buf_ReleaseLocked(bufp, lock) buf_ReleaseLockedDbg(bufp, lock, __FILE__, __LINE__)
+ #define buf_HoldLocked(bufp) buf_HoldLockedDbg(bufp, __FILE__, __LINE__)
+ #else
  extern void buf_Release(cm_buf_t *);
  
  extern void buf_Hold(cm_buf_t *);
  
  extern void buf_ReleaseLocked(cm_buf_t *, afs_uint32);
  
  extern void buf_HoldLocked(cm_buf_t *);
+ #endif
+ 
+ extern void buf_WaitIO(cm_scache_t *, cm_buf_t *);
  
  extern cm_buf_t *buf_FindLocked(struct cm_scache *, osi_hyper_t *);
  
Index: openafs/src/WINNT/afsd/cm_conn.c
diff -c openafs/src/WINNT/afsd/cm_conn.c:1.49.2.41 openafs/src/WINNT/afsd/cm_conn.c:1.49.2.43
*** openafs/src/WINNT/afsd/cm_conn.c:1.49.2.41	Fri Apr 18 12:46:07 2008
--- openafs/src/WINNT/afsd/cm_conn.c	Fri May  2 15:28:18 2008
***************
*** 28,33 ****
--- 28,34 ----
  DWORD RDRtimeout = CM_CONN_DEFAULTRDRTIMEOUT;
  unsigned short ConnDeadtimeout = CM_CONN_CONNDEADTIME;
  unsigned short HardDeadtimeout = CM_CONN_HARDDEADTIME;
+ unsigned short IdleDeadtimeout = CM_CONN_IDLEDEADTIME;
  
  #define LANMAN_WKS_PARAM_KEY "SYSTEM\\CurrentControlSet\\Services\\lanmanworkstation\\parameters"
  #define LANMAN_WKS_SESSION_TIMEOUT "SessTimeout"
***************
*** 86,92 ****
  	    if (code == ERROR_SUCCESS)
                  HardDeadtimeout = (unsigned short)dwValue;
  	    afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
! 	    RegCloseKey(parmKey);
  	}
  
  	afsi_log("lanmanworkstation : SessTimeout %u", RDRtimeout);
--- 87,101 ----
  	    if (code == ERROR_SUCCESS)
                  HardDeadtimeout = (unsigned short)dwValue;
  	    afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
! 
! 	    dummyLen = sizeof(DWORD);
! 	    code = RegQueryValueEx(parmKey, "IdleDeadTimeout", NULL, NULL,
! 				    (BYTE *) &dwValue, &dummyLen);
! 	    if (code == ERROR_SUCCESS)
!                 IdleDeadtimeout = (unsigned short)dwValue;
! 	    afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
! 
!             RegCloseKey(parmKey);
  	}
  
  	afsi_log("lanmanworkstation : SessTimeout %u", RDRtimeout);
***************
*** 174,180 ****
      int dead_session;
      long timeUsed, timeLeft;
      long code;
!     char addr[16];
      int forcing_new = 0;
  
      osi_Log2(afsd_logp, "cm_Analyze connp 0x%p, code 0x%x",
--- 183,189 ----
      int dead_session;
      long timeUsed, timeLeft;
      long code;
!     char addr[16]="unknown";
      int forcing_new = 0;
  
      osi_Log2(afsd_logp, "cm_Analyze connp 0x%p, code 0x%x",
***************
*** 567,586 ****
           * In addition, we log an event to the event log 
           */
  
!         /* Log server being offline for this volume */
!         sprintf(addr, "%d.%d.%d.%d", 
!                  ((serverp->addr.sin_addr.s_addr & 0xff)),
!                  ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
!                  ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
!                  ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); 
  
  #ifndef DJGPP
! 	LogEvent(EVENTLOG_WARNING_TYPE, MSG_RX_HARD_DEAD_TIME_EXCEEDED, addr);
  #endif /* !DJGPP */
  	  
!         retry = 0;
!         osi_Log1(afsd_logp, "cm_Analyze: hardDeadTime exceeded addr[%s]",
! 		 osi_LogSaveString(afsd_logp,addr));
      }
      else if (errorCode >= -64 && errorCode < 0) {
          /* mark server as down */
--- 576,599 ----
           * In addition, we log an event to the event log 
           */
  
!         if (serverp) {
!             /* Log server being offline for this volume */
!             sprintf(addr, "%d.%d.%d.%d", 
!                      ((serverp->addr.sin_addr.s_addr & 0xff)),
!                      ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
!                      ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
!                      ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); 
  
  #ifndef DJGPP
!             LogEvent(EVENTLOG_WARNING_TYPE, MSG_RX_HARD_DEAD_TIME_EXCEEDED, addr);
  #endif /* !DJGPP */
  	  
!             osi_Log1(afsd_logp, "cm_Analyze: hardDeadTime exceeded addr[%s]",
!                      osi_LogSaveString(afsd_logp,addr));
!             reqp->tokenIdleErrorServp = serverp;
!             reqp->idleError++;
!             retry = 1;
!         }
      }
      else if (errorCode >= -64 && errorCode < 0) {
          /* mark server as down */
***************
*** 614,622 ****
                  retry = 1;
          }
      } else if (errorCode >= ERROR_TABLE_BASE_RXK && errorCode < ERROR_TABLE_BASE_RXK + 256) {
!         reqp->tokenErrorServp = serverp;
!         reqp->tokenError = errorCode;
!         retry = 1;
      } else if (errorCode == VICECONNBAD || errorCode == VICETOKENDEAD) {
  	cm_ForceNewConnections(serverp);
          if ( timeLeft > 2 )
--- 627,637 ----
                  retry = 1;
          }
      } else if (errorCode >= ERROR_TABLE_BASE_RXK && errorCode < ERROR_TABLE_BASE_RXK + 256) {
!         if (serverp) {
!             reqp->tokenIdleErrorServp = serverp;
!             reqp->tokenError = errorCode;
!             retry = 1;
!         }
      } else if (errorCode == VICECONNBAD || errorCode == VICETOKENDEAD) {
  	cm_ForceNewConnections(serverp);
          if ( timeLeft > 2 )
***************
*** 804,818 ****
      lock_ObtainRead(&cm_serverLock);
      for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
          tsp = tsrp->server;
!         if (reqp->tokenErrorServp) {
              /* 
               * search the list until we find the server
               * that failed last time.  When we find it
               * clear the error, skip it and try the one
               * in the list.
               */
!             if (tsp == reqp->tokenErrorServp)
!                 reqp->tokenErrorServp = NULL;
              continue;
          }
          cm_GetServerNoLock(tsp);
--- 819,833 ----
      lock_ObtainRead(&cm_serverLock);
      for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
          tsp = tsrp->server;
!         if (reqp->tokenIdleErrorServp) {
              /* 
               * search the list until we find the server
               * that failed last time.  When we find it
               * clear the error, skip it and try the one
               * in the list.
               */
!             if (tsp == reqp->tokenIdleErrorServp)
!                 reqp->tokenIdleErrorServp = NULL;
              continue;
          }
          cm_GetServerNoLock(tsp);
***************
*** 859,865 ****
  
      if (firstError == 0) {
          if (allDown) 
!             firstError = (reqp->tokenError ? reqp->tokenError : CM_ERROR_ALLDOWN);
          else if (allBusy) 
              firstError = CM_ERROR_ALLBUSY;
  	else if (allOffline || (someBusy && someOffline))
--- 874,881 ----
  
      if (firstError == 0) {
          if (allDown) 
!             firstError = (reqp->tokenError ? reqp->tokenError : 
!                           (reqp->idleError ? RX_CALL_TIMEOUT : CM_ERROR_ALLDOWN));
          else if (allBusy) 
              firstError = CM_ERROR_ALLBUSY;
  	else if (allOffline || (someBusy && someOffline))
***************
*** 943,948 ****
--- 959,965 ----
                                    secIndex);
      rx_SetConnDeadTime(tcp->callp, ConnDeadtimeout);
      rx_SetConnHardDeadTime(tcp->callp, HardDeadtimeout);
+     rx_SetConnIdleDeadTime(tcp->callp, IdleDeadtimeout);
      tcp->ucgen = ucellp->gen;
      if (secObjp)
          rxs_Release(secObjp);   /* Decrement the initial refCount */
Index: openafs/src/WINNT/afsd/cm_conn.h
diff -c openafs/src/WINNT/afsd/cm_conn.h:1.13.4.10 openafs/src/WINNT/afsd/cm_conn.h:1.13.4.11
*** openafs/src/WINNT/afsd/cm_conn.h:1.13.4.10	Fri Mar  7 17:16:06 2008
--- openafs/src/WINNT/afsd/cm_conn.h	Mon Apr 28 11:06:14 2008
***************
*** 13,18 ****
--- 13,19 ----
  #define	CM_CONN_DEFAULTRDRTIMEOUT	45
  #define CM_CONN_CONNDEADTIME		 0
  #define CM_CONN_HARDDEADTIME             0
+ #define CM_CONN_IDLEDEADTIME            30
  
  extern unsigned short ConnDeadtimeout;
  extern unsigned short HardDeadtimeout;
***************
*** 42,49 ****
  	int rpcError;			/* RPC error code */
  	int volumeError;		/* volume error code */
  	int accessError;		/* access error code */
!         struct cm_server * tokenErrorServp;  /* server that reported a token error other than expired */
          int tokenError;
  	afs_uint32 flags;
          char * tidPathp;
          char * relPathp;
--- 43,51 ----
  	int rpcError;			/* RPC error code */
  	int volumeError;		/* volume error code */
  	int accessError;		/* access error code */
!         struct cm_server * tokenIdleErrorServp;  /* server that reported a token/idle error other than expired */
          int tokenError;
+         int idleError;
  	afs_uint32 flags;
          char * tidPathp;
          char * relPathp;
Index: openafs/src/WINNT/install/NSIS/CellServDB
diff -c openafs/src/WINNT/install/NSIS/CellServDB:1.6.4.4 openafs/src/WINNT/install/NSIS/CellServDB:1.6.4.5
*** openafs/src/WINNT/install/NSIS/CellServDB:1.6.4.4	Sat Nov  3 11:59:32 2007
--- openafs/src/WINNT/install/NSIS/CellServDB	Wed Apr 23 23:08:31 2008
***************
*** 1,4 ****
! >grand.central.org      #GCO Public CellServDB 25 Oct 2007
  18.92.0.108                     #grand-opening.mit.edu
  128.2.203.61                    #penn.central.org
  130.237.48.87                   #andrew.e.kth.se
--- 1,4 ----
! >grand.central.org      #GCO Public CellServDB 23 Apr 2008
  18.92.0.108                     #grand-opening.mit.edu
  128.2.203.61                    #penn.central.org
  130.237.48.87                   #andrew.e.kth.se
***************
*** 53,58 ****
--- 53,62 ----
  63.224.10.4                     #troilus.SetFilePointer.com
  >sodre.cx               #Sodre.cx
  128.8.140.165                   #greed.sodre.cx
+ >ruk.cuni.cz            #Charles University Computer Centre, Prague, CR
+ 195.113.0.36                    #asterix.ruk.cuni.cz
+ 195.113.0.37                    #obelix.ruk.cuni.cz
+ 195.113.0.40                    #sal.ruk.cuni.cz
  >desy.de                #Deutsches Elektronen-Synchrotron
  131.169.40.62                   #vayu.desy.de
  131.169.244.60                  #solar00.desy.de
***************
*** 81,86 ****
--- 85,92 ----
  130.183.134.20                  #irafs2.mpe-garching.mpg.de
  >i1.informatik.rwth-aachen.de #Informatik I, RWTH Aachen
  137.226.244.79                  #remus.informatik.rwth-aachen.de
+ >combi.tfh-wildau.de    #Philips Research Lab
+ 194.95.50.106                   #joda13.combi.tfh-wildau.de
  >tu-bs.de               #Technical University of Braunschweig, Germany
  134.169.1.1                     #rzafs1.rz.tu-bs.de
  134.169.1.5                     #rzafs2.rz.tu-bs.de
***************
*** 155,160 ****
--- 161,170 ----
  169.229.60.112                  #envy.eecs.berkeley.edu
  >hep.caltech.edu        #Caltech High Energy Physics
  131.215.116.20                  #afs.hep.caltech.edu
+ >ugcs.caltech.edu       #Caltech UGCS lab
+ 131.215.176.65                  #afs-c.ugcs.caltech.edu
+ 131.215.176.67                  #afs-a.ugcs.caltech.edu
+ 131.215.176.68                  #afs-b.ugcs.caltech.edu
  >clarkson.edu           #Clarkson University, Potsdam, New York USA
  128.153.1.111                   #arthur.clarkson.edu
  128.153.9.111                   #lancelot.clarkson.edu
***************
*** 201,209 ****
  129.170.30.145                  #dbicafs3.dartmouth.edu
  >northstar.dartmouth.edu #Dartmouth College Research Computing
  129.170.16.22                   #halley.dartmouth.edu
! 129.170.16.42                   #oort.dartmouth.edu
  129.170.16.43                   #cygnusx1.dartmouth.edu
! >cs.fhm.edu             #Department Computer Science Munich University Of Applied Science
  129.187.208.2                   #srv1.informatik.fh-muenchen.de
  >eecs.harvard.edu       #Harvard - EECS
  140.247.60.64                   #lefkada.eecs.harvard.edu
--- 211,219 ----
  129.170.30.145                  #dbicafs3.dartmouth.edu
  >northstar.dartmouth.edu #Dartmouth College Research Computing
  129.170.16.22                   #halley.dartmouth.edu
! 129.170.16.26                   #andromeda.dartmouth.edu
  129.170.16.43                   #cygnusx1.dartmouth.edu
! >cs.hm.edu              #Department Computer Science Munich University Of Applied Science
  129.187.208.2                   #srv1.informatik.fh-muenchen.de
  >eecs.harvard.edu       #Harvard - EECS
  140.247.60.64                   #lefkada.eecs.harvard.edu
***************
*** 237,242 ****
--- 247,256 ----
  129.74.223.17                   #john.helios.nd.edu
  129.74.223.33                   #lizardo.helios.nd.edu
  129.74.223.65                   #buckaroo.helios.nd.edu
+ >crc.nd.edu             #University of Notre Dame - Center for Research Computing
+ 129.74.85.34                    #afsdb1.crc.nd.edu
+ 129.74.85.35                    #afsdb2.crc.nd.edu
+ 129.74.85.36                    #afsdb3.crc.nd.edu
  >pitt.edu               #University of Pittsburgh
  136.142.8.15                    #afs09.srv.cis.pitt.edu
  136.142.8.20                    #afs10.srv.cis.pitt.edu
***************
*** 503,508 ****
--- 517,525 ----
  72.13.4.23                      #service-3.tproa.net
  72.13.4.24                      #service-4.tproa.net
  72.13.4.25                      #service-5.tproa.net
+ >interdose.net          #Interdose Ltd. & Co. KG, Germany
+ 80.190.171.42                   #bfd9000.tow5.interdose.net
+ 217.111.69.188                  #bfd9001.z2.interdose.net
  >nikhef.nl              #The Dutch National Institute for High Energy Physics
  192.16.185.26                   #afs1.nikhef.nl
  192.16.185.27                   #afs2.nikhef.nl
***************
*** 527,532 ****
--- 544,552 ----
  128.2.120.138                   #kurma.sys.hackish.org
  >idahofuturetruck.org   #University of Idaho hybrid vehicle development
  12.18.238.210                   #dsle210.fsr.net
+ >mrph.org               #Mrph
+ 66.207.133.1                    #sanber.mrph.org
+ 128.2.99.209                    #hernandarias.mrph.org
  >nimlabs.org            #Nimlabs, Ink. Cell.
  18.238.1.103                    #olfin.nimlabs.org
  18.238.1.105                    #caerbanog.nimlabs.org
***************
*** 536,541 ****
--- 556,563 ----
  >oc7.org                #The OC7 Project
  128.2.122.140                   #knife.oc7.org
  207.22.77.170                   #spoon.oc7.org
+ >riscpkg.org            #The RISC OS Packaging Project
+ 83.104.175.10                   #delenn.riscpkg.org
  >kth.se                 #Royal Institute of Technology, Stockholm, Sweden
  130.237.32.145                  #sonen.e.kth.se
  130.237.48.7                    #anden.e.kth.se
***************
*** 544,552 ****
  130.237.24.11                   #afs1.hallf.kth.se
  130.237.24.104                  #afs2.hallf.kth.se
  >isk.kth.se             #Royal Institute of Technology, ISK
- 130.237.202.3                   #afsdb1.isk.kth.se
  130.237.209.5                   #afsdb2.isk.kth.se
  130.237.209.9                   #afsdb3.isk.kth.se
  >it.kth.se              #Royal Institute of Technology, IT
  130.237.212.15                  #ptah.it.kth.se
  130.237.212.16                  #toth.it.kth.se
--- 566,574 ----
  130.237.24.11                   #afs1.hallf.kth.se
  130.237.24.104                  #afs2.hallf.kth.se
  >isk.kth.se             #Royal Institute of Technology, ISK
  130.237.209.5                   #afsdb2.isk.kth.se
  130.237.209.9                   #afsdb3.isk.kth.se
+ 130.237.216.17                  #afsdb1.isk.kth.se
  >it.kth.se              #Royal Institute of Technology, IT
  130.237.212.15                  #ptah.it.kth.se
  130.237.212.16                  #toth.it.kth.se
Index: openafs/src/WINNT/install/wix/CellServDB
diff -c openafs/src/WINNT/install/wix/CellServDB:1.6.4.4 openafs/src/WINNT/install/wix/CellServDB:1.6.4.5
*** openafs/src/WINNT/install/wix/CellServDB:1.6.4.4	Sat Nov  3 11:59:36 2007
--- openafs/src/WINNT/install/wix/CellServDB	Wed Apr 23 23:08:35 2008
***************
*** 1,4 ****
! >grand.central.org      #GCO Public CellServDB 25 Oct 2007
  18.92.0.108                     #grand-opening.mit.edu
  128.2.203.61                    #penn.central.org
  130.237.48.87                   #andrew.e.kth.se
--- 1,4 ----
! >grand.central.org      #GCO Public CellServDB 23 Apr 2008
  18.92.0.108                     #grand-opening.mit.edu
  128.2.203.61                    #penn.central.org
  130.237.48.87                   #andrew.e.kth.se
***************
*** 53,58 ****
--- 53,62 ----
  63.224.10.4                     #troilus.SetFilePointer.com
  >sodre.cx               #Sodre.cx
  128.8.140.165                   #greed.sodre.cx
+ >ruk.cuni.cz            #Charles University Computer Centre, Prague, CR
+ 195.113.0.36                    #asterix.ruk.cuni.cz
+ 195.113.0.37                    #obelix.ruk.cuni.cz
+ 195.113.0.40                    #sal.ruk.cuni.cz
  >desy.de                #Deutsches Elektronen-Synchrotron
  131.169.40.62                   #vayu.desy.de
  131.169.244.60                  #solar00.desy.de
***************
*** 81,86 ****
--- 85,92 ----
  130.183.134.20                  #irafs2.mpe-garching.mpg.de
  >i1.informatik.rwth-aachen.de #Informatik I, RWTH Aachen
  137.226.244.79                  #remus.informatik.rwth-aachen.de
+ >combi.tfh-wildau.de    #Philips Research Lab
+ 194.95.50.106                   #joda13.combi.tfh-wildau.de
  >tu-bs.de               #Technical University of Braunschweig, Germany
  134.169.1.1                     #rzafs1.rz.tu-bs.de
  134.169.1.5                     #rzafs2.rz.tu-bs.de
***************
*** 155,160 ****
--- 161,170 ----
  169.229.60.112                  #envy.eecs.berkeley.edu
  >hep.caltech.edu        #Caltech High Energy Physics
  131.215.116.20                  #afs.hep.caltech.edu
+ >ugcs.caltech.edu       #Caltech UGCS lab
+ 131.215.176.65                  #afs-c.ugcs.caltech.edu
+ 131.215.176.67                  #afs-a.ugcs.caltech.edu
+ 131.215.176.68                  #afs-b.ugcs.caltech.edu
  >clarkson.edu           #Clarkson University, Potsdam, New York USA
  128.153.1.111                   #arthur.clarkson.edu
  128.153.9.111                   #lancelot.clarkson.edu
***************
*** 201,209 ****
  129.170.30.145                  #dbicafs3.dartmouth.edu
  >northstar.dartmouth.edu #Dartmouth College Research Computing
  129.170.16.22                   #halley.dartmouth.edu
! 129.170.16.42                   #oort.dartmouth.edu
  129.170.16.43                   #cygnusx1.dartmouth.edu
! >cs.fhm.edu             #Department Computer Science Munich University Of Applied Science
  129.187.208.2                   #srv1.informatik.fh-muenchen.de
  >eecs.harvard.edu       #Harvard - EECS
  140.247.60.64                   #lefkada.eecs.harvard.edu
--- 211,219 ----
  129.170.30.145                  #dbicafs3.dartmouth.edu
  >northstar.dartmouth.edu #Dartmouth College Research Computing
  129.170.16.22                   #halley.dartmouth.edu
! 129.170.16.26                   #andromeda.dartmouth.edu
  129.170.16.43                   #cygnusx1.dartmouth.edu
! >cs.hm.edu              #Department Computer Science Munich University Of Applied Science
  129.187.208.2                   #srv1.informatik.fh-muenchen.de
  >eecs.harvard.edu       #Harvard - EECS
  140.247.60.64                   #lefkada.eecs.harvard.edu
***************
*** 237,242 ****
--- 247,256 ----
  129.74.223.17                   #john.helios.nd.edu
  129.74.223.33                   #lizardo.helios.nd.edu
  129.74.223.65                   #buckaroo.helios.nd.edu
+ >crc.nd.edu             #University of Notre Dame - Center for Research Computing
+ 129.74.85.34                    #afsdb1.crc.nd.edu
+ 129.74.85.35                    #afsdb2.crc.nd.edu
+ 129.74.85.36                    #afsdb3.crc.nd.edu
  >pitt.edu               #University of Pittsburgh
  136.142.8.15                    #afs09.srv.cis.pitt.edu
  136.142.8.20                    #afs10.srv.cis.pitt.edu
***************
*** 503,508 ****
--- 517,525 ----
  72.13.4.23                      #service-3.tproa.net
  72.13.4.24                      #service-4.tproa.net
  72.13.4.25                      #service-5.tproa.net
+ >interdose.net          #Interdose Ltd. & Co. KG, Germany
+ 80.190.171.42                   #bfd9000.tow5.interdose.net
+ 217.111.69.188                  #bfd9001.z2.interdose.net
  >nikhef.nl              #The Dutch National Institute for High Energy Physics
  192.16.185.26                   #afs1.nikhef.nl
  192.16.185.27                   #afs2.nikhef.nl
***************
*** 527,532 ****
--- 544,552 ----
  128.2.120.138                   #kurma.sys.hackish.org
  >idahofuturetruck.org   #University of Idaho hybrid vehicle development
  12.18.238.210                   #dsle210.fsr.net
+ >mrph.org               #Mrph
+ 66.207.133.1                    #sanber.mrph.org
+ 128.2.99.209                    #hernandarias.mrph.org
  >nimlabs.org            #Nimlabs, Ink. Cell.
  18.238.1.103                    #olfin.nimlabs.org
  18.238.1.105                    #caerbanog.nimlabs.org
***************
*** 536,541 ****
--- 556,563 ----
  >oc7.org                #The OC7 Project
  128.2.122.140                   #knife.oc7.org
  207.22.77.170                   #spoon.oc7.org
+ >riscpkg.org            #The RISC OS Packaging Project
+ 83.104.175.10                   #delenn.riscpkg.org
  >kth.se                 #Royal Institute of Technology, Stockholm, Sweden
  130.237.32.145                  #sonen.e.kth.se
  130.237.48.7                    #anden.e.kth.se
***************
*** 544,552 ****
  130.237.24.11                   #afs1.hallf.kth.se
  130.237.24.104                  #afs2.hallf.kth.se
  >isk.kth.se             #Royal Institute of Technology, ISK
- 130.237.202.3                   #afsdb1.isk.kth.se
  130.237.209.5                   #afsdb2.isk.kth.se
  130.237.209.9                   #afsdb3.isk.kth.se
  >it.kth.se              #Royal Institute of Technology, IT
  130.237.212.15                  #ptah.it.kth.se
  130.237.212.16                  #toth.it.kth.se
--- 566,574 ----
  130.237.24.11                   #afs1.hallf.kth.se
  130.237.24.104                  #afs2.hallf.kth.se
  >isk.kth.se             #Royal Institute of Technology, ISK
  130.237.209.5                   #afsdb2.isk.kth.se
  130.237.209.9                   #afsdb3.isk.kth.se
+ 130.237.216.17                  #afsdb1.isk.kth.se
  >it.kth.se              #Royal Institute of Technology, IT
  130.237.212.15                  #ptah.it.kth.se
  130.237.212.16                  #toth.it.kth.se
Index: openafs/src/afs/afs.h
diff -c openafs/src/afs/afs.h:1.85.2.7 openafs/src/afs/afs.h:1.85.2.8
*** openafs/src/afs/afs.h:1.85.2.7	Mon Nov 26 16:08:38 2007
--- openafs/src/afs/afs.h	Wed Apr 30 15:08:04 2008
***************
*** 86,96 ****
--- 86,98 ----
  #define	AFS_NRXPACKETS	80
  #define	AFS_RXDEADTIME	50
  #define AFS_HARDDEADTIME	120
+ #define	AFS_IDLEDEADTIME	50
  #define AFS_BLKBITS	12
  #define AFS_BLKSIZE	(1 << AFS_BLKBITS)
  
  extern afs_int32 afs_rx_deadtime;
  extern afs_int32 afs_rx_harddead;
+ extern afs_int32 afs_rx_idledead;
  
  struct sysname_info {
      char *name;
***************
*** 186,191 ****
--- 188,196 ----
      char volumeError;		/* encountered a missing or busy volume */
      char networkError;		/* encountered network problems */
      char permWriteError;	/* fileserver returns permenent error. */
+     char tokenError;            /* a token error other than expired. */
+     char idleError;             /* the server idled too long */
+     char skipserver[MAXHOSTS];
  };
  #define VOLMISSING 1
  #define VOLBUSY 2
Index: openafs/src/afs/afs_analyze.c
diff -c openafs/src/afs/afs_analyze.c:1.22.14.5 openafs/src/afs/afs_analyze.c:1.22.14.6
*** openafs/src/afs/afs_analyze.c:1.22.14.5	Tue Jan  9 10:30:02 2007
--- openafs/src/afs/afs_analyze.c	Wed Apr 30 15:08:04 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_analyze.c,v 1.22.14.5 2007/01/09 15:30:02 jaltman Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_analyze.c,v 1.22.14.6 2008/04/30 19:08:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 211,216 ****
--- 211,276 ----
      return (changed ? DIFFERENT : SAME);
  }				/*VLDB_Same */
  
+ /*------------------------------------------------------------------------
+  * afs_BlackListOnce
+  *
+  * Description:
+  *	Mark a server as invalid for further attempts of this request only.
+  *
+  * Arguments:
+  *	areq  : The request record associated with this operation.
+  *	afid  : The FID of the file involved in the action.  This argument
+  *		may be null if none was involved.
+  *      tsp   : pointer to a server struct for the server we wish to 
+  *              blacklist. 
+  *
+  * Returns:
+  *	Non-zero value if further servers are available to try,
+  *	zero otherwise.
+  *
+  * Environment:
+  *	This routine is typically called in situations where we believe
+  *      one server out of a pool may have an error condition.
+  *
+  * Side Effects:
+  *	As advertised.
+  *
+  * NOTE:
+  *	The afs_Conn* routines use the list of invalidated servers to 
+  *      avoid reusing a server marked as invalid for this request.
+  *------------------------------------------------------------------------*/
+ static afs_int32 
+ afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid, 
+ 		  struct server *tsp)
+ {
+     struct volume *tvp;
+     afs_int32 i;
+     afs_int32 serversleft = 0;
+ 
+     if (afid)
+ 	tvp = afs_FindVolume(afid, READ_LOCK);
+     if (tvp) {
+ 	for (i = 0; i < MAXHOSTS; i++) {
+ 	    if (tvp->serverHost[i] == tsp) {
+ 		areq->skipserver[i] = 1;
+ 	    }
+ 	    if (tvp->serverHost[i] &&
+ 		!(tvp->serverHost[i]->addr->sa_flags & 
+ 		  SRVR_ISDOWN)) {
+ 		areq->skipserver[i] = 1;
+ 	    }
+ 	}
+ 	afs_PutVolume(tvp, READ_LOCK);
+     }
+     for (i = 0; i < MAXHOSTS; i++) {
+ 	if (areq->skipserver[i] == 0) {
+ 	    serversleft = 1;
+ 	    break;
+ 	}
+     }
+     return serversleft;
+ }
+ 
  
  /*------------------------------------------------------------------------
   * EXPORTED afs_Analyze
***************
*** 254,260 ****
--- 314,322 ----
      struct server *tsp;
      struct volume *tvp;
      afs_int32 shouldRetry = 0;
+     afs_int32 serversleft = 1;
      struct afs_stats_RPCErrors *aerrP;
+     afs_int32 markeddown;
  
      AFS_STATCNT(afs_Analyze);
      afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op,
***************
*** 378,387 ****
  	acode = 455;
  #endif /* AFS_64BIT_CLIENT */
      if ((acode < 0) && (acode != VRESTARTING)) {
! 	afs_ServerDown(sa);
! 	ForceNewConnections(sa);	/*multi homed clients lock:afs_xsrvAddr? */
  	if (aerrP)
  	    (aerrP->err_Server)++;
      }
  
      if (acode == VBUSY || acode == VRESTARTING) {
--- 440,472 ----
  	acode = 455;
  #endif /* AFS_64BIT_CLIENT */
      if ((acode < 0) && (acode != VRESTARTING)) {
! 	if (acode == RX_CALL_TIMEOUT) {
! 	    serversleft = afs_BlackListOnce(areq, afid, tsp);
! 	    areq->idleError++;
! 	    if (serversleft) {
! 		shouldRetry = 1;
! 	    } else {
! 		shouldRetry = 0;
! 	    }
! 	    /* By doing this, we avoid ever marking a server down
! 	     * in an idle timeout case. That's because the server is 
! 	     * still responding and may only be letting a single vnode
! 	     * time out. We otherwise risk having the server continually
! 	     * be marked down, then up, then down again... 
! 	     */
! 	    goto out;
! 	} 
! 	markeddown = afs_ServerDown(sa);
! 	ForceNewConnections(sa); /**multi homed clients lock:afs_xsrvAddr? */
  	if (aerrP)
  	    (aerrP->err_Server)++;
+ #if 0
+ 	/* retry *once* when the server is timed out in case of NAT */
+ 	if (markeddown && acode == RX_CALL_DEAD) {
+ 	    aconn->forceConnectFS = 1;
+ 	    shouldRetry = 1;
+ 	}
+ #endif
      }
  
      if (acode == VBUSY || acode == VRESTARTING) {
***************
*** 412,418 ****
  	       || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) {
  	/* any rxkad error is treated as token expiration */
  	struct unixuser *tu;
- 
  	/*
  	 * I'm calling these errors protection errors, since they involve
  	 * faulty authentication.
--- 497,502 ----
***************
*** 431,441 ****
  		    ("afs: Tokens for user of AFS id %d for cell %s have expired\n",
  		     tu->vid, aconn->srvr->server->cell->cellName);
  	    } else {
! 		aconn->forceConnectFS = 0;	/* don't check until new tokens set */
! 		aconn->user->states |= UTokensBad;
! 		afs_warnuser
! 		    ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n",
! 		     tu->vid, aconn->srvr->server->cell->cellName, acode);
  	    }
  	    afs_PutUser(tu, READ_LOCK);
  	} else {
--- 515,536 ----
  		    ("afs: Tokens for user of AFS id %d for cell %s have expired\n",
  		     tu->vid, aconn->srvr->server->cell->cellName);
  	    } else {
! 		serversleft = afs_BlackListOnce(areq, afid, tsp);
! 		areq->tokenError++;
! 
! 		if (serversleft) {
! 		    afs_warnuser
! 			("afs: Tokens for user of AFS id %d for cell %s: rxkad error=%d\n",
! 			 tu->vid, aconn->srvr->server->cell->cellName, acode);
! 		    shouldRetry = 1;
! 		} else {
! 		    areq->tokenError = 0;
! 		    aconn->forceConnectFS = 0;	/* don't check until new tokens set */
! 		    aconn->user->states |= UTokensBad;
! 		    afs_warnuser
! 			("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n",
! 			 tu->vid, aconn->srvr->server->cell->cellName, acode);
! 		}
  	    }
  	    afs_PutUser(tu, READ_LOCK);
  	} else {
***************
*** 531,537 ****
  	VSleep(1);		/* Just a hack for desperate times. */
  	shouldRetry = 1;
      }
! 
      /* now unlock the connection and return */
      afs_PutConn(aconn, locktype);
      return (shouldRetry);
--- 626,632 ----
  	VSleep(1);		/* Just a hack for desperate times. */
  	shouldRetry = 1;
      }
! out:
      /* now unlock the connection and return */
      afs_PutConn(aconn, locktype);
      return (shouldRetry);
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.86.4.20 openafs/src/afs/afs_call.c:1.86.4.21
*** openafs/src/afs/afs_call.c:1.86.4.20	Wed Jan 30 16:05:47 2008
--- openafs/src/afs/afs_call.c	Wed Apr 30 15:08:04 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.86.4.20 2008/01/30 21:05:47 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.86.4.21 2008/04/30 19:08:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 72,77 ****
--- 72,78 ----
  
  afs_int32 afs_rx_deadtime = AFS_RXDEADTIME;
  afs_int32 afs_rx_harddead = AFS_HARDDEADTIME;
+ afs_int32 afs_rx_idledead = AFS_IDLEDEADTIME;
  
  static int afscall_set_rxpck_received = 0;
  
Index: openafs/src/afs/afs_conn.c
diff -c openafs/src/afs/afs_conn.c:1.14.8.1 openafs/src/afs/afs_conn.c:1.14.8.2
*** openafs/src/afs/afs_conn.c:1.14.8.1	Mon Feb 26 17:14:58 2007
--- openafs/src/afs/afs_conn.c	Wed Apr 30 15:08:04 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_conn.c,v 1.14.8.1 2007/02/26 22:14:58 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_conn.c,v 1.14.8.2 2008/04/30 19:08:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 83,89 ****
  
      /* First is always lowest rank, if it's up */
      if ((tv->status[0] == not_busy) && tv->serverHost[0]
! 	&& !(tv->serverHost[0]->addr->sa_flags & SRVR_ISDOWN))
  	lowp = tv->serverHost[0]->addr;
  
      /* Otherwise we look at all of them. There are seven levels of
--- 83,91 ----
  
      /* First is always lowest rank, if it's up */
      if ((tv->status[0] == not_busy) && tv->serverHost[0]
! 	&& !(tv->serverHost[0]->addr->sa_flags & SRVR_ISDOWN) &&
! 	!(((areq->idleError > 0) || (areq->tokenError > 0))
! 	  && (areq->skipserver[0] == 1)))
  	lowp = tv->serverHost[0]->addr;
  
      /* Otherwise we look at all of them. There are seven levels of
***************
*** 95,100 ****
--- 97,105 ----
       */
      for (notbusy = not_busy; (!lowp && (notbusy <= end_not_busy)); notbusy++) {
  	for (i = 0; i < MAXHOSTS && tv->serverHost[i]; i++) {
+ 	    if (((areq->tokenError > 0)||(areq->idleError > 0)) 
+ 		&& (areq->skipserver[i] == 1))
+ 		continue;
  	    if (tv->status[i] != notbusy) {
  		if (tv->status[i] == rd_busy || tv->status[i] == rdwr_busy) {
  		    if (!areq->busyCount)
***************
*** 234,239 ****
--- 239,245 ----
  	if (service == 52) {
  	    rx_SetConnHardDeadTime(tc->id, afs_rx_harddead);
  	}
+ 	rx_SetConnIdleDeadTime(tc->id, afs_rx_idledead);
  
  	tc->forceConnectFS = 0;	/* apparently we're appropriately connected now */
  	if (csec)
Index: openafs/src/afs/afs_error.c
diff -c openafs/src/afs/afs_error.c:1.1.2.2 openafs/src/afs/afs_error.c:1.1.2.3
*** openafs/src/afs/afs_error.c:1.1.2.2	Mon Jul 31 17:27:38 2006
--- openafs/src/afs/afs_error.c	Wed Apr 30 15:08:04 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_error.c,v 1.1.2.2 2006/07/31 21:27:38 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_error.c,v 1.1.2.3 2008/04/30 19:08:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 209,218 ****
--- 209,227 ----
  void
  afs_CopyError(register struct vrequest *afrom, register struct vrequest *ato)
  {
+     int i = 0;
      AFS_STATCNT(afs_CopyError);
      if (!afrom->initd)
  	return;
      afs_FinalizeReq(ato);
+     while (i < MAXHOSTS) {
+ 	ato->skipserver[i] = afrom->skipserver[i];
+ 	i++;
+     }
+     if (afrom->tokenError)
+ 	ato->tokenError = afrom->tokenError;
+     if (afrom->idleError)
+ 	ato->idleError = afrom->idleError;
      if (afrom->accessError)
  	ato->accessError = 1;
      if (afrom->volumeError)
***************
*** 227,236 ****
--- 236,252 ----
  void
  afs_FinalizeReq(register struct vrequest *areq)
  {
+     int i = 0;
      AFS_STATCNT(afs_FinalizeReq);
      if (areq->initd)
  	return;
+     while (i < MAXHOSTS) {
+ 	areq->skipserver[i] = 0;
+ 	i++;
+     }
      areq->busyCount = 0;
+     areq->idleError = 0;
+     areq->tokenError = 0;
      areq->accessError = 0;
      areq->volumeError = 0;
      areq->networkError = 0;
Index: openafs/src/afs/afs_prototypes.h
diff -c openafs/src/afs/afs_prototypes.h:1.74.2.13 openafs/src/afs/afs_prototypes.h:1.74.2.14
*** openafs/src/afs/afs_prototypes.h:1.74.2.13	Sun Feb 10 23:00:47 2008
--- openafs/src/afs/afs_prototypes.h	Wed Apr 30 15:08:04 2008
***************
*** 746,752 ****
  				    afs_int32 addr_uniquifier);
  extern void ForceAllNewConnections(void);
  extern void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown);
! extern void afs_ServerDown(struct srvAddr *sa);
  extern void afs_CountServers(void);
  extern void afs_CheckServers(int adown, struct cell *acellp);
  extern unsigned int afs_random(void);
--- 746,752 ----
  				    afs_int32 addr_uniquifier);
  extern void ForceAllNewConnections(void);
  extern void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown);
! extern afs_int32 afs_ServerDown(struct srvAddr *sa);
  extern void afs_CountServers(void);
  extern void afs_CheckServers(int adown, struct cell *acellp);
  extern unsigned int afs_random(void);
Index: openafs/src/afs/afs_server.c
diff -c openafs/src/afs/afs_server.c:1.43.4.5 openafs/src/afs/afs_server.c:1.43.4.6
*** openafs/src/afs/afs_server.c:1.43.4.5	Tue Dec 11 16:30:04 2007
--- openafs/src/afs/afs_server.c	Wed Apr 30 15:08:04 2008
***************
*** 33,39 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.43.4.5 2007/12/11 21:30:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 33,39 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.43.4.6 2008/04/30 19:08:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 239,252 ****
  }				/*MarkServerUpOrDown */
  
  
! void
  afs_ServerDown(struct srvAddr *sa)
  {
      register struct server *aserver = sa->server;
  
      AFS_STATCNT(ServerDown);
!     if (aserver->flags & SRVR_ISDOWN || sa->sa_flags & SRVADDR_ISDOWN)
! 	return;
      afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
      if (sa->sa_portal == aserver->cell->vlport)
  	print_internet_address
--- 239,252 ----
  }				/*MarkServerUpOrDown */
  
  
! afs_int32
  afs_ServerDown(struct srvAddr *sa)
  {
      register struct server *aserver = sa->server;
  
      AFS_STATCNT(ServerDown);
!     if (aserver->flags & SRVR_ISDOWN || sa->sa_flags & SRVADDR_ISDOWN) 
! 	return 0;
      afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
      if (sa->sa_portal == aserver->cell->vlport)
  	print_internet_address
***************
*** 254,260 ****
      else
  	print_internet_address("afs: Lost contact with file server ", sa, "",
  			       1);
! 
  }				/*ServerDown */
  
  
--- 254,260 ----
      else
  	print_internet_address("afs: Lost contact with file server ", sa, "",
  			       1);
!     return 1;
  }				/*ServerDown */
  
  
Index: openafs/src/afs/VNOPS/afs_vnop_read.c
diff -c openafs/src/afs/VNOPS/afs_vnop_read.c:1.34.2.1 openafs/src/afs/VNOPS/afs_vnop_read.c:1.34.2.2
*** openafs/src/afs/VNOPS/afs_vnop_read.c:1.34.2.1	Thu Nov 29 13:34:32 2007
--- openafs/src/afs/VNOPS/afs_vnop_read.c	Sat Apr 26 23:54:14 2008
***************
*** 19,25 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v 1.34.2.1 2007/11/29 18:34:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 19,25 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v 1.34.2.2 2008/04/27 03:54:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 120,125 ****
--- 120,126 ----
      if (filePos >= avc->m.Length) {
  	if (len > AFS_ZEROS)
  	    len = sizeof(afs_zeros);	/* and in 0 buffer */
+ 	len = 0;
  #ifdef AFS_DARWIN80_ENV
  	trimlen = len;
  	tuiop = afsio_darwin_partialcopy(auio, trimlen);
Index: openafs/src/butc/dump.c
diff -c openafs/src/butc/dump.c:1.18.6.2 openafs/src/butc/dump.c:1.18.6.3
*** openafs/src/butc/dump.c:1.18.6.2	Mon Mar 10 18:32:33 2008
--- openafs/src/butc/dump.c	Thu May  1 20:59:38 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/dump.c,v 1.18.6.2 2008/03/10 22:32:33 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/dump.c,v 1.18.6.3 2008/05/02 00:59:38 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 2215,2220 ****
  	code = BUTX_DELETENOVOL;
  	setStatus(taskId, TASK_ERROR);
      }
!     return (code);
  }
  #endif
--- 2215,2220 ----
  	code = BUTX_DELETENOVOL;
  	setStatus(taskId, TASK_ERROR);
      }
!     return (void *)(code);
  }
  #endif
Index: openafs/src/packaging/RedHat/mockbuild.pl
diff -c openafs/src/packaging/RedHat/mockbuild.pl:1.1.4.3 openafs/src/packaging/RedHat/mockbuild.pl:1.1.4.4
*** openafs/src/packaging/RedHat/mockbuild.pl:1.1.4.3	Tue Apr  8 14:36:13 2008
--- openafs/src/packaging/RedHat/mockbuild.pl	Tue Apr 22 08:50:38 2008
***************
*** 20,25 ****
--- 20,69 ----
  my $ignorerelease = 1;
  my @newrpms;
  
+ # Words cannot describe how gross this is. Yum no longer provides usable
+ # output, so we need to call the python interface. At some point this
+ # probably means this script should be entirely rewritten in python,
+ # but this is not that point.
+ 
+ sub findKernelModules {
+   my ($root, $uname, @modules) = @_;
+ 
+   my $modlist = join(",",map { "'".$_."'" } @modules);
+   my $python = <<EOS;
+ import yum;
+ import sys;
+ base = yum.YumBase();
+ base.doConfigSetup('$root/etc/yum.conf', '$root');
+ base.doRepoSetup();
+ base.doSackSetup();
+ EOS
+ 
+   if ($uname) {
+     $python.= <<EOS;
+ 
+ for pkg, values in base.searchPackageProvides(['kernel-devel-uname-r']).items():
+   if values[0].find('kernel-devel-uname-r = ') != -1:
+     print '%s.%s %s' % (pkg.name, pkg.arch, values[0].replace('kernel-devel-uname-r = ',''));
+ 
+ EOS
+   } else {
+     $python.= <<EOS;
+ 
+ print '\\n'.join(['%s.%s %s' % (x.name, x.arch, x.printVer()) for x in base.searchPackageProvides([$modlist]).keys()]);
+ 
+ EOS
+   }
+ 
+ #  my $output = `$suser -c "python -c \\\"$python\\\"" `;
+   my $output = `python -c "$python"`;
+ 
+   die "Python script to figure out available kernels failed : $output" 
+     if $?;
+ 
+   return $output;
+ }
+ 
+ 
  my %platconf = ( "fedora-5-i386" => { osver => "fc5",
  				      kmod => '1',
  				      basearch => 'i386',
***************
*** 80,100 ****
  				   	basearch => 'x86_64',
  				        updaterepo => 'update',
  					results => "el5/x86_64" },
! #		 "fedora-development-i386" => { osver => "fcd",
! #					  kmod => '1',
! #					  basearch => 'i386',
! #					  results => 'fedora-devel/i386'},
! #		 "fedora-development-x86_64" => { osver => "fcd",
! #					    kmod => '1',
! #					    basearch => 'x86_64',
! #					    results => 'fedora-devel/x86_64'} 
  );
  
  # The following are kernels that we can't successfully build modules against
  # due to issues in the packaged kernel-devel RPM.
  
  my %badkernels = (
! 	"2.6.21-2950.fc8" => { "xen" => 1} # Missing build ID
  );
  
  my $help;
--- 124,144 ----
  				   	basearch => 'x86_64',
  				        updaterepo => 'update',
  					results => "el5/x86_64" },
! 		 "fedora-development-i386" => { osver => "fcd",
! 					  kmod => '1',
! 					  basearch => 'i386',
! 					  results => 'fedora-devel/i386'},
! 		 "fedora-development-x86_64" => { osver => "fcd",
! 					    kmod => '1',
! 					    basearch => 'x86_64',
! 					    results => 'fedora-devel/x86_64'} 
  );
  
  # The following are kernels that we can't successfully build modules against
  # due to issues in the packaged kernel-devel RPM.
  
  my %badkernels = (
! 	"2.6.21-2950.fc8" => { "xen" => 1}, # Missing build ID
  );
  
  my $help;
***************
*** 155,175 ****
    print "Finding available kernel modules\n";
  
    my $arbitraryversion = "";
!   my $modules=`$suser -c 'yum --installroot $root provides kernel-devel'`;
!   if ($modules eq "") {
!       $modules=`$suser -c 'yum -d 2 --installroot $root provides kernel-devel'`;
!       my $modulen;
!       my %modulel;
!       foreach $modulen (split(/\n/, $modules)) {
! 	  my ($pk, $colon, $comment)=split(/\s+/, $modulen);
! 	  if ($pk =~ /^kernel/) {
! 	      $modulel{$pk} = "$pk";
! 	  } 
!       }
!       $modulen=join(" ", keys(%modulel));
!       $modules=`$suser -c 'yum --installroot $root list $modulen'`;
    }
    foreach my $module (split(/\n/, $modules)) {
        my ($package, $version, $repo)=split(/\s+/, $module);
        my ($arch) = ($package=~/\.(.*)$/);
        my ($variant) = ($package=~/kernel-(.*)-devel/);
--- 199,217 ----
    print "Finding available kernel modules\n";
  
    my $arbitraryversion = "";
! 
!   my $modules;
!   if ($platform=~/fedora-development/) {
!     $modules = findKernelModules($root, 0, "kernel-devel");
!   } elsif ($platform=~/centos-4/) {
!     $modules = findKernelModules($root, 0, "kernel-devel", "kernel-smp-devel", 
! 				 "kernel-hugemem-devel", "kernel-xenU-devel");
!   } else {
!     $modules = findKernelModules($root, 0, 'kernel-devel');
    }
+ 
    foreach my $module (split(/\n/, $modules)) {
+       chomp $module;
        my ($package, $version, $repo)=split(/\s+/, $module);
        my ($arch) = ($package=~/\.(.*)$/);
        my ($variant) = ($package=~/kernel-(.*)-devel/);
***************
*** 182,188 ****
  	  next if ($variant eq "xen0"); # Fedora 5 has some bad xen0 kernel-devels
  	  next if ($variant eq "smp");
        }
!       if ($platform=~/fedora-8/) {
  	  next if ($variant =~/debug$/); # Fedora 8 debug kernels are bad
        }
        print "$arch : $variant : $version\n";
--- 224,230 ----
  	  next if ($variant eq "xen0"); # Fedora 5 has some bad xen0 kernel-devels
  	  next if ($variant eq "smp");
        }
!       if ($platform=~/fedora-8/ || $platform=~/fedora-9/ || $platform=~/fedora-development/) {
  	  next if ($variant =~/debug$/); # Fedora 8 debug kernels are bad
        }
        print "$arch : $variant : $version\n";
Index: openafs/src/packaging/RedHat/openafs-kmodtool
diff -c openafs/src/packaging/RedHat/openafs-kmodtool:1.1.2.2 openafs/src/packaging/RedHat/openafs-kmodtool:1.1.2.3
*** openafs/src/packaging/RedHat/openafs-kmodtool:1.1.2.2	Wed Feb 13 00:28:58 2008
--- openafs/src/packaging/RedHat/openafs-kmodtool	Tue Apr 22 08:50:38 2008
***************
*** 70,80 ****
          *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
          *)     kdep="kernel-%{_target_cpu} = ${verrel}${variant}"     ;;
      esac
      cat <<EOF
  %package       -n kmod-${kmod_name}${dashvariant}
  Summary:          ${kmod_name} kernel module(s)
  Group:            System Environment/Kernel
! Provides:         kernel-modules = ${verrel}${variant}
  Provides:         ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
  Provides:         openafs-kernel = %{PACKAGE_VERSION}
  Requires:         ${kdep}
--- 70,85 ----
          *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
          *)     kdep="kernel-%{_target_cpu} = ${verrel}${variant}"     ;;
      esac
+     case "$verrel" in
+         *.fc9*) kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
+         *)      kname="${verrel}${variant}"                             ;;
+     esac
+ 
      cat <<EOF
  %package       -n kmod-${kmod_name}${dashvariant}
  Summary:          ${kmod_name} kernel module(s)
  Group:            System Environment/Kernel
! Provides:         kernel-modules = ${kname}
  Provides:         ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
  Provides:         openafs-kernel = %{PACKAGE_VERSION}
  Requires:         ${kdep}
***************
*** 85,98 ****
  BuildRequires:    kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}
  %description   -n kmod-${kmod_name}${dashvariant}
  This package provides the ${kmod_name} kernel modules built for the Linux
! kernel ${verrel}${variant} for the %{_target_cpu} family of processors.
  %post          -n kmod-${kmod_name}${dashvariant}
! /sbin/depmod -aeF /boot/System.map-${verrel}${variant} ${verrel}${variant} > /dev/null || :
  %postun        -n kmod-${kmod_name}${dashvariant}
! /sbin/depmod -aF /boot/System.map-${verrel}${variant} ${verrel}${variant} &> /dev/null || :
  %files         -n kmod-${kmod_name}${dashvariant}
  %defattr(644,root,root,755)
! /lib/modules/${verrel}${variant}/extra/${kmod_name}/
  
  EOF
  }
--- 90,103 ----
  BuildRequires:    kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}
  %description   -n kmod-${kmod_name}${dashvariant}
  This package provides the ${kmod_name} kernel modules built for the Linux
! kernel ${kname} for the %{_target_cpu} family of processors.
  %post          -n kmod-${kmod_name}${dashvariant}
! /sbin/depmod -aeF /boot/System.map-${kname} ${kname} > /dev/null || :
  %postun        -n kmod-${kmod_name}${dashvariant}
! /sbin/depmod -aF /boot/System.map-${kname} ${kname} &> /dev/null || :
  %files         -n kmod-${kmod_name}${dashvariant}
  %defattr(644,root,root,755)
! /lib/modules/${kname}/extra/${kmod_name}/
  
  EOF
  }
Index: openafs/src/packaging/RedHat/openafs.spec.in
diff -c openafs/src/packaging/RedHat/openafs.spec.in:1.2.2.20 openafs/src/packaging/RedHat/openafs.spec.in:1.2.2.22
*** openafs/src/packaging/RedHat/openafs.spec.in:1.2.2.20	Tue Apr  8 14:36:13 2008
--- openafs/src/packaging/RedHat/openafs.spec.in	Sun Apr 27 00:00:22 2008
***************
*** 1,4 ****
! # Openafs Spec $Revision: 1.2.2.20 $
  
  %define afsvers @VERSION@
  %define pkgvers @LINUX_PKGVER@
--- 1,4 ----
! # Openafs Spec $Revision: 1.2.2.22 $
  
  %define afsvers @VERSION@
  %define pkgvers @LINUX_PKGVER@
***************
*** 37,43 ****
  %define upvar ""
  %{!?kvariants: %define kvariants %{?upvar}}
  
! %{!?ksrcdir: %define ksrcdir %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}}
  
  %else # Legacy kernel build stuff 
  
--- 37,49 ----
  %define upvar ""
  %{!?kvariants: %define kvariants %{?upvar}}
  
! %if %{?ksrcdir:1}%{!?ksrcdir:0}
!   if ( -d %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}) ; then
!     %define ksrcdir %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}}
!   else
!     %define ksrcdir %{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}}
!   fi
! %endif
  
  %else # Legacy kernel build stuff 
  
***************
*** 242,248 ****
  Source10: http://www.openafs.org/dl/openafs/%{afsvers}/RELNOTES-%{afsvers}
  Source11: http://www.openafs.org/dl/openafs/%{afsvers}/ChangeLog
  
! Source20: http://dl.central.org/dl/cellservdb/CellServDB.2007-10-25 
  
  Source30: openafs-kernel-version.sh
  Source996: openafs-kvers-is.sh
--- 248,254 ----
  Source10: http://www.openafs.org/dl/openafs/%{afsvers}/RELNOTES-%{afsvers}
  Source11: http://www.openafs.org/dl/openafs/%{afsvers}/ChangeLog
  
! Source20: http://dl.central.org/dl/cellservdb/CellServDB.2008-04-23
  
  Source30: openafs-kernel-version.sh
  Source996: openafs-kvers-is.sh
***************
*** 821,827 ****
  %if %{fedorakmod} 
    for kvariant in %{kvariants} ; do
      if [ -z "${kvariant}" -o -z "$ksrc" ] ; then
!       ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
      fi
    done
  %endif
--- 827,837 ----
  %if %{fedorakmod} 
    for kvariant in %{kvariants} ; do
      if [ -z "${kvariant}" -o -z "$ksrc" ] ; then
!       if [ -d %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} ] ; then
!         ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
!       else
!         ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}
!       fi
      fi
    done
  %endif
***************
*** 854,859 ****
--- 864,875 ----
  %if %{fedorakmod} && %{build_modules}
  for kvariant in %{kvariants} ; do
    if [ -n "${kvariant}" ] ; then
+     if [ -d %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} ] ; then
+       ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
+     else
+       ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}
+     fi
+ 
      cp -R libafs_tree _kmod_build_${kvariant}
      pushd _kmod_build_${kvariant}
      ./configure --with-afs-sysname=${sysname} \
***************
*** 861,867 ****
  	--libdir=%{_libdir} \
  	--bindir=%{_bindir} \
  	--sbindir=%{_sbindir} \
! 	--with-linux-kernel-headers=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} \
  %if %{krb5support}
  	--with-krb5-conf=/usr/kerberos/bin/krb5-config \
  %endif
--- 877,883 ----
  	--libdir=%{_libdir} \
  	--bindir=%{_bindir} \
  	--sbindir=%{_sbindir} \
! 	--with-linux-kernel-headers=${ksrc} \
  %if %{krb5support}
  	--with-krb5-conf=/usr/kerberos/bin/krb5-config \
  %endif
***************
*** 1196,1209 ****
  for kvariant in %{kvariants}
  do
    if [ -n "$kvariant" ] ; then
!     srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP
    else
      srcdir=${sysname}/dest/root.client%{_prefix}/vice/etc/modload
    fi
  
!   dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
    mkdir -p ${dstdir}
!   install -m 755 ${srcdir}/libafs-%{kverrel}${kvariant}.ko $dstdir/openafs.ko
  done
  %else
  # Install the kernel modules
--- 1212,1236 ----
  for kvariant in %{kvariants}
  do
    if [ -n "$kvariant" ] ; then
!     if [ -d _kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP ] ; then
!       srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP
!     else
!       srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}.%{_target_cpu}.${kvariant}-SP
!     fi
    else
      srcdir=${sysname}/dest/root.client%{_prefix}/vice/etc/modload
    fi
  
!   if [ -f ${srcdir}/libafs-%{kverrel}${kvariant}.ko ] ; then
!     srcmod=${srcdir}/libafs-%{kverrel}${kvariant}.ko
!     dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
!   else
!     srcmod=${srcdir}/libafs-%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}.ko
!     dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}/extra/openafs
!   fi
! 
    mkdir -p ${dstdir}
!   install -m 755 ${srcmod} ${dstdir}/openafs.ko
  done
  %else
  # Install the kernel modules
Index: openafs/src/rx/rx.c
diff -c openafs/src/rx/rx.c:1.97.2.19 openafs/src/rx/rx.c:1.97.2.20
*** openafs/src/rx/rx.c:1.97.2.19	Mon Mar 17 13:57:18 2008
--- openafs/src/rx/rx.c	Thu May  8 17:25:58 2008
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.97.2.19 2008/03/17 17:57:18 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.97.2.20 2008/05/08 21:25:58 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
***************
*** 741,747 ****
  		 register struct rx_securityClass *securityObject,
  		 int serviceSecurityIndex)
  {
!     int hashindex;
      afs_int32 cid;
      register struct rx_connection *conn;
  
--- 741,747 ----
  		 register struct rx_securityClass *securityObject,
  		 int serviceSecurityIndex)
  {
!     int hashindex, i;
      afs_int32 cid;
      register struct rx_connection *conn;
  
***************
*** 777,782 ****
--- 777,786 ----
      conn->delayedAbortEvent = NULL;
      conn->abortCount = 0;
      conn->error = 0;
+     for (i = 0; i < RX_MAXCALLS; i++) {
+ 	conn->twind[i] = rx_initSendWindow;
+ 	conn->rwind[i] = rx_initReceiveWindow;
+     }
  
      RXS_NewConnection(securityObject, conn);
      hashindex =
***************
*** 2153,2158 ****
--- 2157,2164 ----
      }
      call->channel = channel;
      call->callNumber = &conn->callNumber[channel];
+     call->rwind = conn->rwind[channel];
+     call->twind = conn->twind[channel];
      /* Note that the next expected call number is retained (in
       * conn->callNumber[i]), even if we reallocate the call structure
       */
***************
*** 2313,2319 ****
  		   register u_short port, u_short serviceId, afs_uint32 cid,
  		   afs_uint32 epoch, int type, u_int securityIndex)
  {
!     int hashindex, flag;
      register struct rx_connection *conn;
      hashindex = CONN_HASH(host, port, cid, epoch, type);
      MUTEX_ENTER(&rx_connHashTable_lock);
--- 2319,2325 ----
  		   register u_short port, u_short serviceId, afs_uint32 cid,
  		   afs_uint32 epoch, int type, u_int securityIndex)
  {
!     int hashindex, flag, i;
      register struct rx_connection *conn;
      hashindex = CONN_HASH(host, port, cid, epoch, type);
      MUTEX_ENTER(&rx_connHashTable_lock);
***************
*** 2383,2388 ****
--- 2389,2398 ----
  	conn->specific = NULL;
  	rx_SetConnDeadTime(conn, service->connDeadTime);
  	rx_SetConnIdleDeadTime(conn, service->idleDeadTime);
+ 	for (i = 0; i < RX_MAXCALLS; i++) {
+ 	    conn->twind[i] = rx_initSendWindow;
+ 	    conn->rwind[i] = rx_initReceiveWindow;
+ 	}
  	/* Notify security object of the new connection */
  	RXS_NewConnection(conn->securityObject, conn);
  	/* XXXX Connection timeout? */
***************
*** 3759,3764 ****
--- 3769,3775 ----
  	    if (tSize < call->twind) {	/* smaller than our send */
  		call->twind = tSize;	/* window, we must send less... */
  		call->ssthresh = MIN(call->twind, call->ssthresh);
+ 		call->conn->twind[call->channel] = call->twind;
  	    }
  
  	    /* Only send jumbograms to 3.4a fileservers. 3.3a RX gets the
***************
*** 3782,3790 ****
--- 3793,3803 ----
  	     */
  	    if (tSize < call->twind) {
  		call->twind = tSize;
+ 		call->conn->twind[call->channel] = call->twind;
  		call->ssthresh = MIN(call->twind, call->ssthresh);
  	    } else if (tSize > call->twind) {
  		call->twind = tSize;
+ 		call->conn->twind[call->channel] = call->twind;
  	    }
  
  	    /*
***************
*** 4499,4506 ****
      }
      queue_Init(&call->rq);
      call->error = 0;
!     call->rwind = rx_initReceiveWindow;
!     call->twind = rx_initSendWindow;
      call->nSoftAcked = 0;
      call->nextCwind = 0;
      call->nAcks = 0;
--- 4512,4519 ----
      }
      queue_Init(&call->rq);
      call->error = 0;
!     call->twind = call->conn->twind[call->channel];
!     call->rwind = call->conn->rwind[call->channel];
      call->nSoftAcked = 0;
      call->nextCwind = 0;
      call->nAcks = 0;
***************
*** 4611,4617 ****
       * Open the receive window once a thread starts reading packets
       */
      if (call->rnext > 1) {
! 	call->rwind = rx_maxReceiveWindow;
      }
  
      call->nHardAcks = 0;
--- 4624,4630 ----
       * Open the receive window once a thread starts reading packets
       */
      if (call->rnext > 1) {
! 	call->conn->rwind[call->channel] = call->rwind = rx_maxReceiveWindow;
      }
  
      call->nHardAcks = 0;
Index: openafs/src/rx/rx.h
diff -c openafs/src/rx/rx.h:1.28.4.7 openafs/src/rx/rx.h:1.28.4.8
*** openafs/src/rx/rx.h:1.28.4.7	Wed Mar 12 01:13:59 2008
--- openafs/src/rx/rx.h	Thu May  8 17:25:58 2008
***************
*** 233,238 ****
--- 233,240 ----
      struct rx_call *call[RX_MAXCALLS];
  #endif
      afs_uint32 callNumber[RX_MAXCALLS];	/* Current call numbers */
+     afs_uint32 rwind[RX_MAXCALLS];
+     u_short twind[RX_MAXCALLS];
      afs_uint32 serial;		/* Next outgoing packet serial number */
      afs_uint32 lastSerial;	/* # of last packet received, for computing skew */
      afs_int32 maxSerial;	/* largest serial number seen on incoming packets */
Index: openafs/src/rx/rx_globals.h
diff -c openafs/src/rx/rx_globals.h:1.21.2.7 openafs/src/rx/rx_globals.h:1.21.2.8
*** openafs/src/rx/rx_globals.h:1.21.2.7	Tue Mar 11 14:27:39 2008
--- openafs/src/rx/rx_globals.h	Thu May  8 17:25:58 2008
***************
*** 119,127 ****
  
  EXT int rx_minWindow GLOBALSINIT(1);
  EXT int rx_initReceiveWindow GLOBALSINIT(16);	/* how much to accept */
! EXT int rx_maxReceiveWindow GLOBALSINIT(32);	/* how much to accept */
! EXT int rx_initSendWindow GLOBALSINIT(8);
! EXT int rx_maxSendWindow GLOBALSINIT(32);
  EXT int rx_nackThreshold GLOBALSINIT(3);	/* Number NACKS to trigger congestion recovery */
  EXT int rx_nDgramThreshold GLOBALSINIT(4);	/* Number of packets before increasing
  					 * packets per datagram */
--- 119,127 ----
  
  EXT int rx_minWindow GLOBALSINIT(1);
  EXT int rx_initReceiveWindow GLOBALSINIT(16);	/* how much to accept */
! EXT int rx_maxReceiveWindow GLOBALSINIT(64);	/* how much to accept */
! EXT int rx_initSendWindow GLOBALSINIT(16);
! EXT int rx_maxSendWindow GLOBALSINIT(64);
  EXT int rx_nackThreshold GLOBALSINIT(3);	/* Number NACKS to trigger congestion recovery */
  EXT int rx_nDgramThreshold GLOBALSINIT(4);	/* Number of packets before increasing
  					 * packets per datagram */
Index: openafs/src/rx/rx_rdwr.c
diff -c openafs/src/rx/rx_rdwr.c:1.29.2.3 openafs/src/rx/rx_rdwr.c:1.29.2.4
*** openafs/src/rx/rx_rdwr.c:1.29.2.3	Mon Mar 17 11:38:28 2008
--- openafs/src/rx/rx_rdwr.c	Thu May  8 17:25:58 2008
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.29.2.3 2008/03/17 15:38:28 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.29.2.4 2008/05/08 21:25:58 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 700,706 ****
  	    }
  	    /* Wait for transmit window to open up */
  	    while (!call->error
! 		   && call->tnext + 1 > call->tfirst + call->twind) {
  		clock_NewTime();
  		call->startWait = clock_Sec();
  
--- 700,706 ----
  	    }
  	    /* Wait for transmit window to open up */
  	    while (!call->error
! 		   && call->tnext + 1 > call->tfirst + (2 * call->twind)) {
  		clock_NewTime();
  		call->startWait = clock_Sec();
  
***************
*** 1138,1144 ****
      }
  
      /* Wait for the length of the transmit queue to fall below call->twind */
!     while (!call->error && call->tnext + 1 > call->tfirst + call->twind) {
  	clock_NewTime();
  	call->startWait = clock_Sec();
  #ifdef	RX_ENABLE_LOCKS
--- 1138,1144 ----
      }
  
      /* Wait for the length of the transmit queue to fall below call->twind */
!     while (!call->error && call->tnext + 1 > call->tfirst + (2 * call->twind)) {
  	clock_NewTime();
  	call->startWait = clock_Sec();
  #ifdef	RX_ENABLE_LOCKS
Index: openafs/src/rx/test/generator.c
diff -c openafs/src/rx/test/generator.c:1.8.14.2 openafs/src/rx/test/generator.c:1.8.14.3
*** openafs/src/rx/test/generator.c:1.8.14.2	Wed Oct 31 00:09:33 2007
--- openafs/src/rx/test/generator.c	Thu May  8 17:26:00 2008
***************
*** 53,66 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/test/generator.c,v 1.8.14.2 2007/10/31 04:09:33 shadow Exp $");
  
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
  #include <limits.h>
  #include <float.h>
- #include <malloc.h>
  #include <assert.h>
  #include "generator.h"
  
--- 53,65 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/test/generator.c,v 1.8.14.3 2008/05/08 21:26:00 shadow Exp $");
  
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
  #include <limits.h>
  #include <float.h>
  #include <assert.h>
  #include "generator.h"
  
Index: openafs/src/tbutc/Makefile.in
diff -c openafs/src/tbutc/Makefile.in:1.15 openafs/src/tbutc/Makefile.in:1.15.4.1
*** openafs/src/tbutc/Makefile.in:1.15	Mon Oct 24 15:05:15 2005
--- openafs/src/tbutc/Makefile.in	Mon Apr 28 12:15:06 2008
***************
*** 24,30 ****
  BUCOORDOBJS=ubik_db_if.o ../bucoord/volstub.o ../bucoord/dlq.o \
  	    status.o ../bucoord/bucoord_errs.o
  
! VOLSEROBJS=vsprocs.o vsutils.o
  VOLSERLIBS=${TOP_LIBDIR}/libvosadmin.a ${TOP_LIBDIR}/libafsadminutil.a
  
  LWPOBJS     =lock.o
--- 24,30 ----
  BUCOORDOBJS=ubik_db_if.o ../bucoord/volstub.o ../bucoord/dlq.o \
  	    status.o ../bucoord/bucoord_errs.o
  
! VOLSEROBJS=vsprocs.o vsutils.o lockprocs.o
  VOLSERLIBS=${TOP_LIBDIR}/libvosadmin.a ${TOP_LIBDIR}/libafsadminutil.a
  
  LWPOBJS     =lock.o
***************
*** 115,120 ****
--- 115,123 ----
  vsprocs.o: ${VOLSER}/vsprocs.c
  	${CC} ${CFLAGS} -c ${VOLSER}/vsprocs.c
  
+ lockprocs.o: ${VOLSER}/lockprocs.c
+ 	${CC} ${CFLAGS} -c ${VOLSER}/lockprocs.c
+ 
  lock.o: ${LWP}/lock.c
  	${CC} ${CFLAGS} -c ${LWP}/lock.c
  
Index: openafs/src/ubik/phys.c
diff -c openafs/src/ubik/phys.c:1.9.2.3 openafs/src/ubik/phys.c:1.9.2.4
*** openafs/src/ubik/phys.c:1.9.2.3	Wed Apr  2 15:51:56 2008
--- openafs/src/ubik/phys.c	Mon Apr 28 17:48:11 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/phys.c,v 1.9.2.3 2008/04/02 19:51:56 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/phys.c,v 1.9.2.4 2008/04/28 21:48:11 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 137,143 ****
  	return EBADF;
      tfd = fdcache;
      for (i = 0; i < MAXFDCACHE; i++, tfd++) {
! 	if (tfd->fd == afd) {
  	    tfd->refCount--;
  	    return 0;
  	}
--- 137,143 ----
  	return EBADF;
      tfd = fdcache;
      for (i = 0; i < MAXFDCACHE; i++, tfd++) {
! 	if (tfd->fd == afd && tfd->fileID != -10000) {
  	    tfd->refCount--;
  	    return 0;
  	}
***************
*** 289,291 ****
--- 289,308 ----
      uphys_close(fd);
      return code;
  }
+ 
+ void
+ uphys_invalidate(register struct ubik_dbase *adbase, afs_int32 afid)
+ {
+     register int i;
+     register struct fdcache *tfd;
+ 
+     /* scan file descr cache */
+     for (tfd = fdcache, i = 0; i < MAXFDCACHE; i++, tfd++) {
+ 	if (afid == tfd->fileID) {
+ 	    tfd->fileID = -10000;
+ 	    if (tfd->fd >= 0 && tfd->refCount == 0)
+ 		close(tfd->fd);
+ 	    return;
+ 	}
+     }
+ }
Index: openafs/src/ubik/recovery.c
diff -c openafs/src/ubik/recovery.c:1.14.4.6 openafs/src/ubik/recovery.c:1.14.4.7
*** openafs/src/ubik/recovery.c:1.14.4.6	Wed Apr  9 12:40:01 2008
--- openafs/src/ubik/recovery.c	Mon Apr 28 17:48:11 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/recovery.c,v 1.14.4.6 2008/04/09 16:40:01 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/recovery.c,v 1.14.4.7 2008/04/28 21:48:11 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 662,667 ****
--- 662,669 ----
  #endif
  		if (!code) 
  		    code = rename(pbuffer, tbuffer);
+ 		if (!code) 
+ 		    code = (*ubik_dbase->open) (ubik_dbase, 0);
  		if (!code)
  #endif
  		/* after data is good, sync disk with correct label */
Index: openafs/src/ubik/remote.c
diff -c openafs/src/ubik/remote.c:1.15.4.5 openafs/src/ubik/remote.c:1.15.4.6
*** openafs/src/ubik/remote.c:1.15.4.5	Wed Apr  2 15:51:56 2008
--- openafs/src/ubik/remote.c	Mon Apr 28 17:48:11 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/remote.c,v 1.15.4.5 2008/04/02 19:51:56 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/remote.c,v 1.15.4.6 2008/04/28 21:48:11 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 615,620 ****
--- 615,622 ----
  #endif
      if (!code) 
  	code = rename(pbuffer, tbuffer);
+     if (!code) 
+ 	code = (*ubik_dbase->open) (ubik_dbase, 0);
      if (!code)
  #endif
      code = (*ubik_dbase->setlabel) (dbase, file, avers);
Index: openafs/src/ubik/ubik.c
diff -c openafs/src/ubik/ubik.c:1.15.14.4 openafs/src/ubik/ubik.c:1.15.14.5
*** openafs/src/ubik/ubik.c:1.15.14.4	Wed Apr  2 15:51:56 2008
--- openafs/src/ubik/ubik.c	Mon Apr 28 17:48:11 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/ubik.c,v 1.15.14.4 2008/04/02 19:51:56 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/ubik.c,v 1.15.14.5 2008/04/28 21:48:11 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 220,226 ****
      tdb->read = uphys_read;
      tdb->write = uphys_write;
      tdb->truncate = uphys_truncate;
!     tdb->open = 0;		/* this function isn't used any more */
      tdb->sync = uphys_sync;
      tdb->stat = uphys_stat;
      tdb->getlabel = uphys_getlabel;
--- 220,226 ----
      tdb->read = uphys_read;
      tdb->write = uphys_write;
      tdb->truncate = uphys_truncate;
!     tdb->open = uphys_invalidate;	/* this function isn't used any more */
      tdb->sync = uphys_sync;
      tdb->stat = uphys_stat;
      tdb->getlabel = uphys_getlabel;
Index: openafs/src/ubik/ubik.p.h
diff -c openafs/src/ubik/ubik.p.h:1.18.8.3 openafs/src/ubik/ubik.p.h:1.18.8.4
*** openafs/src/ubik/ubik.p.h:1.18.8.3	Wed Apr  2 15:51:56 2008
--- openafs/src/ubik/ubik.p.h	Mon Apr 28 17:48:11 2008
***************
*** 311,317 ****
  extern int uphys_setlabel(register struct ubik_dbase *adbase, afs_int32 afile,
  			  struct ubik_version *aversion);
  extern int uphys_sync(register struct ubik_dbase *adbase, afs_int32 afile);
! 
  
  /* recovery.c */
  extern int urecovery_ResetState(void);
--- 311,318 ----
  extern int uphys_setlabel(register struct ubik_dbase *adbase, afs_int32 afile,
  			  struct ubik_version *aversion);
  extern int uphys_sync(register struct ubik_dbase *adbase, afs_int32 afile);
! extern void uphys_invalidate(register struct ubik_dbase *adbase, 
! 			     afs_int32 afid);
  
  /* recovery.c */
  extern int urecovery_ResetState(void);
Index: openafs/src/ubik/udebug.c
diff -c openafs/src/ubik/udebug.c:1.18.4.2 openafs/src/ubik/udebug.c:1.18.4.3
*** openafs/src/ubik/udebug.c:1.18.4.2	Wed Oct 31 00:09:38 2007
--- openafs/src/ubik/udebug.c	Mon Apr 28 11:20:41 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/udebug.c,v 1.18.4.2 2007/10/31 04:09:38 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdlib.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/udebug.c,v 1.18.4.3 2008/04/28 15:20:41 jaltman Exp $");
  
  #include <sys/types.h>
  #include <stdlib.h>
***************
*** 172,179 ****
      times = ctime(&now);
      times[24] = 0;
      diff = now - udebug.now;
!     printf("Local time is %s (time differential %d secs)\n", times, diff);
!     if (abs(diff) >= MAXSKEW)
  	printf("****clock may be bad\n");
  
      /* UBIK skips the voting if 1 server - so we fudge it here */
--- 172,179 ----
      times = ctime(&now);
      times[24] = 0;
      diff = now - udebug.now;
!     printf("Local time is %s (time differential %d secs)\n", times, (int)diff);
!     if (abs((int)diff) >= MAXSKEW)
  	printf("****clock may be bad\n");
  
      /* UBIK skips the voting if 1 server - so we fudge it here */
***************
*** 192,205 ****
      } else {
  	diff = udebug.now - udebug.lastYesTime;
  	printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
! 	       afs_inet_ntoa(htonl(udebug.lastYesHost)), diff,
  	       ((udebug.lastYesState) ? "" : "not "));
  
  	diff = udebug.now - udebug.lastYesClaim;
  	newtime = now - diff;
  	times = ctime(&newtime);
  	times[24] = 0;
! 	printf("Last vote started %d secs ago (at %s)\n", diff, times);
      }
  
      printf("Local db version is %d.%d\n", udebug.localVersion.epoch,
--- 192,205 ----
      } else {
  	diff = udebug.now - udebug.lastYesTime;
  	printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
! 	       afs_inet_ntoa(htonl(udebug.lastYesHost)), (int)diff,
  	       ((udebug.lastYesState) ? "" : "not "));
  
  	diff = udebug.now - udebug.lastYesClaim;
  	newtime = now - diff;
  	times = ctime(&newtime);
  	times[24] = 0;
! 	printf("Last vote started %d secs ago (at %s)\n", (int)diff, times);
      }
  
      printf("Local db version is %d.%d\n", udebug.localVersion.epoch,
***************
*** 216,222 ****
  	    times[24] = 0;
  	    printf
  		("I am sync site until %d secs from now (at %s) (%d server%s)\n",
! 		 diff, times, udebug.nServers,
  		 ((udebug.nServers > 1) ? "s" : ""));
  	}
  	printf("Recovery state %x\n", udebug.recoveryState);
--- 216,222 ----
  	    times[24] = 0;
  	    printf
  		("I am sync site until %d secs from now (at %s) (%d server%s)\n",
! 		 (int)diff, times, udebug.nServers,
  		 ((udebug.nServers > 1) ? "s" : ""));
  	}
  	printf("Recovery state %x\n", udebug.recoveryState);
***************
*** 232,243 ****
  	diff = udebug.now - udebug.lowestTime;
  	printf("Lowest host %s was set %d secs ago\n",
  	       afs_inet_ntoa(htonl(udebug.lowestHost)),
! 	       diff);
  
  	diff = udebug.now - udebug.syncTime;
  	printf("Sync host %s was set %d secs ago\n",
  	       afs_inet_ntoa(htonl(udebug.syncHost)),
! 	       diff);
      }
  
      printf("Sync site's db version is %d.%d\n", udebug.syncVersion.epoch,
--- 232,243 ----
  	diff = udebug.now - udebug.lowestTime;
  	printf("Lowest host %s was set %d secs ago\n",
  	       afs_inet_ntoa(htonl(udebug.lowestHost)),
! 	       (int)diff);
  
  	diff = udebug.now - udebug.syncTime;
  	printf("Sync host %s was set %d secs ago\n",
  	       afs_inet_ntoa(htonl(udebug.syncHost)),
! 	       (int)diff);
      }
  
      printf("Sync site's db version is %d.%d\n", udebug.syncVersion.epoch,
***************
*** 265,271 ****
  	times[24] = 0;
  	printf
  	    ("Last time a new db version was labelled was:\n\t %d secs ago (at %s)\n",
! 	     diff, times);
      }
  
      if (int32p || udebug.amSyncSite) {
--- 265,271 ----
  	times[24] = 0;
  	printf
  	    ("Last time a new db version was labelled was:\n\t %d secs ago (at %s)\n",
! 	     (int)diff, times);
      }
  
      if (int32p || udebug.amSyncSite) {
***************
*** 305,311 ****
  		newtime = now - diff;
  		times = ctime(&newtime);
  		times[24] = 0;
! 		printf("    last vote rcvd %d secs ago (at %s),\n", diff,
  		       times);
  	    }
  
--- 305,311 ----
  		newtime = now - diff;
  		times = ctime(&newtime);
  		times[24] = 0;
! 		printf("    last vote rcvd %d secs ago (at %s),\n", (int)diff,
  		       times);
  	    }
  
***************
*** 318,324 ****
  		times[24] = 0;
  		printf
  		    ("    last beacon sent %d secs ago (at %s), last vote was %s\n",
! 		     diff, times, ((usdebug.lastVote) ? "yes" : "no"));
  	    }
  
  	    printf("    dbcurrent=%d, up=%d beaconSince=%d\n",
--- 318,324 ----
  		times[24] = 0;
  		printf
  		    ("    last beacon sent %d secs ago (at %s), last vote was %s\n",
! 		     (int)diff, times, ((usdebug.lastVote) ? "yes" : "no"));
  	    }
  
  	    printf("    dbcurrent=%d, up=%d beaconSince=%d\n",
Index: openafs/src/venus/Makefile.in
diff -c openafs/src/venus/Makefile.in:1.34.2.1 openafs/src/venus/Makefile.in:1.34.2.2
*** openafs/src/venus/Makefile.in:1.34.2.1	Mon Nov 12 13:28:36 2007
--- openafs/src/venus/Makefile.in	Sun Apr 27 23:45:15 2008
***************
*** 290,302 ****
  		${INSTALL} -f ${srcdir}/kdump ${DEST}/etc/kdump32;; \
  	*alpha_linux* ) \
  		${INSTALLex} -f ${srcdir}/kdump.sh.linux ${DEST}/etc/kdump; \
! 		${INSTALL} kdump-alpha_linux-${LINUX_VERSION} $@ ;; \
  	*linux* ) \
  		${INSTALLex} -f ${srcdir}/kdump.sh.linux ${DEST}/etc/kdump; \
  		${INSTALL} kdump-linux-${LINUX_VERSION} $@-${LINUX_VERSION} ;; \
  	hp_ux11* ) \
  		${INSTALLex} -f ${srcdir}/kdump.sh.hp_ux11 ${DEST}/etc/kdump; \
! 		${INSTALL} -f $? $@;; \
  	*nbsd*) \
  		;; \
  	*) \
--- 290,302 ----
  		${INSTALL} -f ${srcdir}/kdump ${DEST}/etc/kdump32;; \
  	*alpha_linux* ) \
  		${INSTALLex} -f ${srcdir}/kdump.sh.linux ${DEST}/etc/kdump; \
! 		${INSTALL} kdump-alpha_linux-${LINUX_VERSION} $@-${LINUX_VERSION} ;; \
  	*linux* ) \
  		${INSTALLex} -f ${srcdir}/kdump.sh.linux ${DEST}/etc/kdump; \
  		${INSTALL} kdump-linux-${LINUX_VERSION} $@-${LINUX_VERSION} ;; \
  	hp_ux11* ) \
  		${INSTALLex} -f ${srcdir}/kdump.sh.hp_ux11 ${DEST}/etc/kdump; \
! 		${INSTALL} -f $? ${DEST}/etc/kdump32;; \
  	*nbsd*) \
  		;; \
  	*) \
***************
*** 367,382 ****
  			do ${INSTALL} $$f ${DESTDIR}${sbindir}/$$f || exit $$? ; \
  		done ;; \
  	sun*_5[789] | sun*_510 ) \
! 		${INSTALLex} -f kdump.sh.solaris7 ${DESTDIR}${sbindir}/kdump32; \
! 		${INSTALL} -f $? $@;; \
  	*linux* ) \
  		${INSTALLex} -f kdump.sh.linux ${DESTDIR}${sbindir}/kdump; \
! 		${INSTALL} $? $@ ;; \
  	hp_ux11* ) \
  		${INSTALLex} -f kdump.sh.hp_ux11 ${DESTDIR}${sbindir}/kdump; \
! 		${INSTALL} -f $? $@;; \
  	*) \
! 		${INSTALL} $? $@ ;; \
  	esac
  
  ${DESTDIR}${sbindir}/kdump64: kdump-build
--- 367,385 ----
  			do ${INSTALL} $$f ${DESTDIR}${sbindir}/$$f || exit $$? ; \
  		done ;; \
  	sun*_5[789] | sun*_510 ) \
! 		${INSTALLex} -f kdump.sh.solaris7 ${DESTDIR}${sbindir}/kdump; \
! 		${INSTALL} -f kdump ${DESTDIR}${sbindir}/kdump32;; \
! 	*alpha_linux* ) \
! 		${INSTALLex} -f kdump.sh.linux ${DESTDIR}${sbindir}/kdump; \
! 		${INSTALL} kdump-alpha_linux-${LINUX_VERSION} $@-${LINUX_VERSION} ;; \
  	*linux* ) \
  		${INSTALLex} -f kdump.sh.linux ${DESTDIR}${sbindir}/kdump; \
! 		${INSTALL} kdump-linux-${LINUX_VERSION} $@-${LINUX_VERSION} ;; \
  	hp_ux11* ) \
  		${INSTALLex} -f kdump.sh.hp_ux11 ${DESTDIR}${sbindir}/kdump; \
! 		${INSTALL} -f kdump ${DESTDIR}${sbindir}/kdump32;; \
  	*) \
! 		${INSTALL} kdump $@ ;; \
  	esac
  
  ${DESTDIR}${sbindir}/kdump64: kdump-build
Index: openafs/src/viced/host.c
diff -c openafs/src/viced/host.c:1.93.2.32 openafs/src/viced/host.c:1.93.2.34
*** openafs/src/viced/host.c:1.93.2.32	Mon Feb 25 23:14:17 2008
--- openafs/src/viced/host.c	Thu May  8 17:18:56 2008
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.93.2.32 2008/02/26 04:14:17 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.93.2.34 2008/05/08 21:18:56 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 1156,1162 ****
  
      /* don't add the same entry multiple times */
      for (chain = hostUuidHashTable[index]; chain; chain = chain->next) {
! 	if (host->interface && afs_uuid_equal(&host->interface->uuid, uuid))
  	    return;
      }
  
--- 1156,1163 ----
  
      /* don't add the same entry multiple times */
      for (chain = hostUuidHashTable[index]; chain; chain = chain->next) {
! 	if (chain->hostPtr->interface && 
! 	    afs_uuid_equal(&chain->hostPtr->interface->uuid, uuid))
  	    return;
      }
  
***************
*** 1564,1569 ****
--- 1565,1571 ----
                   */
                  removeAddress_r(host, haddr, hport);
                  host->hostFlags &= ~HWHO_INPROGRESS;
+                 host->hostFlags |= ALTADDR;
                  h_Unlock_r(host);
  		if (!held)
                      h_Release_r(host);
***************
*** 1599,1604 ****
--- 1601,1607 ----
  		    removeAddress_r(host, host->host, host->port);
  		}
  		host->hostFlags &= ~HWHO_INPROGRESS;
+                 host->hostFlags |= ALTADDR;
  		h_Unlock_r(host);
  		if (!held)
  		    h_Release_r(host);
***************
*** 1668,1673 ****
--- 1671,1677 ----
  			 afs_inet_ntoa_r(haddr, hoststr), ntohs(hport), code));
                  removeAddress_r(host, haddr, hport);
                  host->hostFlags &= ~HWHO_INPROGRESS;
+                 host->hostFlags |= ALTADDR;
                  h_Unlock_r(host);
                  if (!held)
                      h_Release_r(host);
Index: openafs/src/viced/viced.c
diff -c openafs/src/viced/viced.c:1.75.2.21 openafs/src/viced/viced.c:1.75.2.22
*** openafs/src/viced/viced.c:1.75.2.21	Mon Mar 10 18:32:35 2008
--- openafs/src/viced/viced.c	Tue May  6 11:03:07 2008
***************
*** 22,28 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.75.2.21 2008/03/10 22:32:35 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 22,28 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.75.2.22 2008/05/06 15:03:07 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 1420,1426 ****
  	if (!Sawcbs)
  	    numberofcbs = 64000;
  	if (!Sawlwps)
! 	    lwps = 12;
  	if (!Sawbufs)
  	    buffs = 120;
  	if (!SawVC)
--- 1420,1426 ----
  	if (!Sawcbs)
  	    numberofcbs = 64000;
  	if (!Sawlwps)
! 	    lwps = 128;
  	if (!Sawbufs)
  	    buffs = 120;
  	if (!SawVC)
Index: openafs/src/viced/viced.h
diff -c openafs/src/viced/viced.h:1.8.2.2 openafs/src/viced/viced.h:1.8.2.3
*** openafs/src/viced/viced.h:1.8.2.2	Thu Jul 12 04:29:34 2007
--- openafs/src/viced/viced.h	Wed Apr 23 14:57:16 2008
***************
*** 190,196 ****
  #define DONTPANIC 0
  #define PANIC 1
  
! #define MAX_FILESERVER_THREAD	128	/* max number of threads in fileserver, subject to system limits */
  
  #define FILESERVER_HELPER_THREADS 7	/* Listner, IOMGR, FiveMinute, 
  					 * HostCheck, Signal, min 2 for RXSTATS */
--- 190,196 ----
  #define DONTPANIC 0
  #define PANIC 1
  
! #define MAX_FILESERVER_THREAD	128	/* max number of threads in fileserver, subject to system limits. match to FD_HANDLE_SETASIDE */
  
  #define FILESERVER_HELPER_THREADS 7	/* Listner, IOMGR, FiveMinute, 
  					 * HostCheck, Signal, min 2 for RXSTATS */
Index: openafs/src/vol/ihandle.h
diff -c openafs/src/vol/ihandle.h:1.10.2.2 openafs/src/vol/ihandle.h:1.10.2.3
*** openafs/src/vol/ihandle.h:1.10.2.2	Fri Sep  7 00:03:49 2007
--- openafs/src/vol/ihandle.h	Wed Apr 23 14:57:13 2008
***************
*** 193,199 ****
  #define STREAM_HANDLE_MALLOCSIZE 1
  
  /* Number of file descriptors needed for non-cached I/O */
! #define FD_HANDLE_SETASIDE	64
  
  /* Don't try to have more than 256 files open at once if you are planning
   * to use fopen or fdopen. The FILE structure has an eight bit field for
--- 193,199 ----
  #define STREAM_HANDLE_MALLOCSIZE 1
  
  /* Number of file descriptors needed for non-cached I/O */
! #define FD_HANDLE_SETASIDE	128 /* Match to MAX_FILESERVER_THREAD */
  
  /* Don't try to have more than 256 files open at once if you are planning
   * to use fopen or fdopen. The FILE structure has an eight bit field for
Index: openafs/src/volser/vsprocs.c
diff -c openafs/src/volser/vsprocs.c:1.38.2.17 openafs/src/volser/vsprocs.c:1.38.2.18
*** openafs/src/volser/vsprocs.c:1.38.2.17	Mon Apr 14 16:25:52 2008
--- openafs/src/volser/vsprocs.c	Thu Apr 24 18:45:47 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.38.2.17 2008/04/14 20:25:52 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.38.2.18 2008/04/24 22:45:47 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 1790,1795 ****
--- 1790,1796 ----
  	ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
  		  (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
  	VDONE;
+ 	islocked = 0;
      }
  
      if (clonetid) {
***************
*** 1995,2006 ****
      }
  
      /* unlock VLDB entry */
!     VPRINT1("Recovery: Releasing lock on VLDB entry for volume %u ...",
! 	    afromvol);
!     ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
! 	      (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
!     VDONE;
! 
    done:			/* routine cleanup */
      if (volName)
  	free(volName);
--- 1996,2009 ----
      }
  
      /* unlock VLDB entry */
!     if (islocked) {
! 	VPRINT1("Recovery: Releasing lock on VLDB entry for volume %u ...",
! 		afromvol);
! 	ubik_VL_ReleaseLock(cstruct, 0, afromvol, -1,
! 			    (LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP));
! 	VDONE;
! 	islocked = 0;
!     }
    done:			/* routine cleanup */
      if (volName)
  	free(volName);
