abstract-reset-vcache-20090119
[openafs.git] / src / afs / afs_vcache.c
index 1d2e08d..e298083 100644 (file)
@@ -19,6 +19,7 @@
  * afs_FlushActiveVcaches
  * afs_VerifyVCache2
  * afs_WriteVCache
+ * afs_WriteVCacheDiscon
  * afs_SimpleVStat
  * afs_ProcessFS
  * TellALittleWhiteLie
@@ -26,6 +27,7 @@
  * afs_GetVCache
  * afs_LookupVCache
  * afs_GetRootVCache
+ * afs_UpdateStatus
  * afs_FetchStatus
  * afs_StuffVcache
  * afs_PutVCache
@@ -62,9 +64,11 @@ char *makesname();
 
 /* Exported variables */
 afs_rwlock_t afs_xvcache;      /*Lock: alloc new stat cache entries */
+afs_rwlock_t afs_xvreclaim;    /*Lock: entries reclaimed, not on free list */
 afs_lock_t afs_xvcb;           /*Lock: fids on which there are callbacks */
 #if !defined(AFS_LINUX22_ENV)
 static struct vcache *freeVCList;      /*Free list for stat cache entries */
+struct vcache *ReclaimedVCList;        /*Reclaimed list for stat entries */
 static struct vcache *Initial_freeVCList;      /*Initial list for above */
 #endif
 struct afs_q VLRU;             /*vcache LRU */
@@ -79,10 +83,10 @@ int afs_norefpanic = 0;
 /* Forward declarations */
 static afs_int32 afs_QueueVCB(struct vcache *avc);
 
-/*
- * afs_HashCBRFid
- *
+/*!
  * Generate an index into the hash table for a given Fid.
+ * \param fid 
+ * \return The hash value.
  */
 static int
 afs_HashCBRFid(struct AFSFid *fid)
@@ -90,11 +94,11 @@ afs_HashCBRFid(struct AFSFid *fid)
     return (fid->Volume + fid->Vnode + fid->Unique) % CBRSIZE;
 }
 
-/*
- * afs_InsertHashCBR
- *
+/*!
  * Insert a CBR entry into the hash table.
  * Must be called with afs_xvcb held.
+ * \param cbr
+ * \return
  */
 static void
 afs_InsertHashCBR(struct afs_cbr *cbr)
@@ -109,15 +113,9 @@ afs_InsertHashCBR(struct afs_cbr *cbr)
     afs_cbrHashT[slot] = cbr;
 }
 
-/*
- * afs_FlushVCache
- *
- * Description:
- *     Flush the given vcache entry.
+/*!
  *
- * Parameters:
- *     avc : Pointer to vcache entry to flush.
- *     slept : Pointer to int to set 1 if we sleep/drop locks, 0 if we don't.
+ * Flush the given vcache entry.
  *
  * Environment:
  *     afs_xvcache lock must be held for writing upon entry to
@@ -126,8 +124,11 @@ afs_InsertHashCBR(struct afs_cbr *cbr)
  * LOCK: afs_FlushVCache afs_xvcache W
  * REFCNT: vcache ref count must be zero on entry except for osf1
  * RACE: lock is dropped and reobtained, permitting race in caller
+ *
+ * \param avc Pointer to vcache entry to flush.
+ * \param slept Pointer to int to set 1 if we sleep/drop locks, 0 if we don't.
+ *
  */
-
 int
 afs_FlushVCache(struct vcache *avc, int *slept)
 {                              /*afs_FlushVCache */
@@ -161,7 +162,6 @@ afs_FlushVCache(struct vcache *avc, int *slept)
     avc->states |= CVFlushed;
     /* pull the entry out of the lruq and put it on the free list */
     QRemove(&avc->vlruq);
-    avc->vlruq.prev = avc->vlruq.next = (struct afs_q *)0;
 
     /* keep track of # of files that we bulk stat'd, but never used
      * before they got recycled.
@@ -203,6 +203,10 @@ afs_FlushVCache(struct vcache *avc, int *slept)
        AFSTOV(avc) = NULL;             /* also drop the ptr to vnode */
     }
 #endif
+#ifdef AFS_SUN510_ENV
+    /* As we use private vnodes, cleanup is up to us */
+    vn_reinit(AFSTOV(avc));
+#endif
     afs_FreeAllAxs(&(avc->Access));
 
     /* we can't really give back callbacks on RO files, since the
@@ -272,10 +276,11 @@ afs_FlushVCache(struct vcache *avc, int *slept)
 }                              /*afs_FlushVCache */
 
 #ifndef AFS_SGI_ENV
-/*
- * afs_InactiveVCache
+/*!
+ *  The core of the inactive vnode op for all but IRIX.
  *
- * The core of the inactive vnode op for all but IRIX.
+ * \param avc 
+ * \param acred
  */
 void
 afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred)
@@ -298,14 +303,14 @@ afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred)
 }
 #endif
 
-/*
- * afs_AllocCBR
- *
- * Description: allocate a callback return structure from the
+/*!
+ *   Allocate a callback return structure from the
  * free list and return it.
  *
- * Env: The alloc and free routines are both called with the afs_xvcb lock
+ * Environment: The alloc and free routines are both called with the afs_xvcb lock
  * held, so we don't have to worry about blocking in osi_Alloc.
+ *
+ * \return The allocated afs_cbr.
  */
 static struct afs_cbr *afs_cbrSpace = 0;
 struct afs_cbr *
@@ -337,15 +342,14 @@ afs_AllocCBR(void)
     return tsp;
 }
 
-/*
- * afs_FreeCBR
+/*!
+ * Free a callback return structure, removing it from all lists.
  *
- * Description: free a callback return structure, removing it from all lists.
+ * Environment: the xvcb lock is held over these calls.
  *
- * Parameters:
- *     asp -- the address of the structure to free.
+ * \param asp The address of the structure to free.
  *
- * Environment: the xvcb lock is held over these calls.
+ * \rerurn 0
  */
 int
 afs_FreeCBR(register struct afs_cbr *asp)
@@ -363,15 +367,13 @@ afs_FreeCBR(register struct afs_cbr *asp)
     return 0;
 }
 
-/*
- * afs_FlushVCBs
- *
- * Description: flush all queued callbacks to all servers.
- *
- * Parameters: none.
+/*!
+ *   Flush all queued callbacks to all servers.
  *
  * Environment: holds xvcb lock over RPC to guard against race conditions
  *     when a new callback is granted for the same file later on.
+ *
+ * \return 0 for success.
  */
 afs_int32
 afs_FlushVCBs(afs_int32 lockit)
@@ -485,18 +487,15 @@ afs_FlushVCBs(afs_int32 lockit)
     return 0;
 }
 
-/*
- * afs_QueueVCB
- *
- * Description:
- *     Queue a callback on the given fid.
- *
- * Parameters:
- *     avc: vcache entry
+/*!
+ *  Queue a callback on the given fid.
  *
  * Environment:
  *     Locks the xvcb lock.
  *     Called when the xvcache lock is already held.
+ *
+ * \param avc vcache entry
+ * \return 0 for success < 0 otherwise.
  */
 
 static afs_int32
@@ -531,19 +530,16 @@ afs_QueueVCB(struct vcache *avc)
 }
 
 
-/*
- * afs_RemoveVCB
- *
- * Description:
- *     Remove a queued callback for a given Fid.
- *
- * Parameters:
- *     afid: The fid we want cleansed of queued callbacks.
+/*!
+ *   Remove a queued callback for a given Fid.
  *
  * Environment:
  *     Locks xvcb and xserver locks.
  *     Typically called with xdcache, xvcache and/or individual vcache
  *     entries locked.
+ *
+ * \param afid The fid we want cleansed of queued callbacks.
+ *
  */
 
 void
@@ -572,21 +568,63 @@ afs_RemoveVCB(struct VenusFid *afid)
     MReleaseWriteLock(&afs_xvcb);
 }
 
-/*
- * afs_NewVCache
+void 
+afs_FlushReclaimedVcaches(void)
+{
+#if !defined(AFS_LINUX22_ENV)
+    struct vcache *tvc;
+    int code, fv_slept;
+    struct vcache *tmpReclaimedVCList = NULL;  
+
+    ObtainWriteLock(&afs_xvreclaim, 76);
+    while (ReclaimedVCList) {
+       tvc = ReclaimedVCList;  /* take from free list */
+       ReclaimedVCList = tvc->nextfree;
+       tvc->nextfree = NULL;
+       code = afs_FlushVCache(tvc, &fv_slept);
+       if (code) {
+           /* Ok, so, if we got code != 0, uh, wtf do we do? */
+           /* Probably, build a temporary list and then put all back when we
+              get to the end of the list */
+           /* This is actually really crappy, but we need to not leak these.
+              We probably need a way to be smarter about this. */
+           tvc->nextfree = tmpReclaimedVCList;
+           tmpReclaimedVCList = tvc;
+           printf("Reclaim list flush %lx failed: %d\n", (unsigned long) tvc, code);
+       }
+        if (tvc->states & (CVInit
+#ifdef AFS_DARWIN80_ENV
+                         | CDeadVnode
+#endif
+           )) {
+          tvc->states &= ~(CVInit
+#ifdef AFS_DARWIN80_ENV
+                           | CDeadVnode
+#endif
+          );
+          afs_osi_Wakeup(&tvc->states);
+       }
+    }
+    if (tmpReclaimedVCList) 
+       ReclaimedVCList = tmpReclaimedVCList;
+
+    ReleaseWriteLock(&afs_xvreclaim);
+#endif
+}
+
+/*!
+ *   This routine is responsible for allocating a new cache entry
+ * from the free list.  It formats the cache entry and inserts it
+ * into the appropriate hash tables.  It must be called with
+ * afs_xvcache write-locked so as to prevent several processes from
+ * trying to create a new cache entry simultaneously.
  *
- * Description:
- *     This routine is responsible for allocating a new cache entry
- *     from the free list.  It formats the cache entry and inserts it
- *     into the appropriate hash tables.  It must be called with
- *     afs_xvcache write-locked so as to prevent several processes from
- *     trying to create a new cache entry simultaneously.
+ * LOCK: afs_NewVCache  afs_xvcache W
  *
- * Parameters:
- *     afid  : The file id of the file whose cache entry is being
- *             created.
+ * \param afid The file id of the file whose cache entry is being created.
+ *
+ * \return The new vcache struct.
  */
-/* LOCK: afs_NewVCache  afs_xvcache W */
 struct vcache *
 afs_NewVCache(struct VenusFid *afid, struct server *serverp)
 {
@@ -603,6 +641,9 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp)
     int code, fv_slept;
 
     AFS_STATCNT(afs_NewVCache);
+
+    afs_FlushReclaimedVcaches();
+
 #if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
 #if defined(AFS_OSF30_ENV) || defined(AFS_LINUX22_ENV)
     if (afs_vcount >= afs_maxvcount)
@@ -638,7 +679,6 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp)
            if (tvc != afs_globalVp && VREFCOUNT(tvc) > 1 && tvc->opens == 0) {
                 struct dentry *dentry;
                 struct list_head *cur, *head;
-                AFS_FAST_HOLD(tvc);
                 AFS_GUNLOCK();
 #if defined(AFS_LINUX24_ENV)
                 spin_lock(&dcache_lock);
@@ -674,7 +714,6 @@ restart:
 #endif
            inuse:
                AFS_GLOCK();
-               AFS_FAST_RELE(tvc);
            }
 #endif
 
@@ -702,8 +741,9 @@ restart:
                return NULL;
            }
        }
-    }
+    } /* finished freeing up space */
 
+/* Alloc new vnode. */
 #if defined(AFS_LINUX22_ENV)
 {
     struct inode *ip;
@@ -736,6 +776,7 @@ restart:
 #else /* AFS_OSF_ENV */
     /* pull out a free cache entry */
     if (!freeVCList) {
+        int loop = 0;
        i = 0;
        for (tq = VLRU.prev; (anumber > 0) && (tq != &VLRU); tq = uq) {
            tvc = QTOV(tq);
@@ -763,6 +804,7 @@ restart:
                /* VREFCOUNT_GT only sees usecounts, not iocounts */
                /* so this may fail to actually recycle the vnode now */
                /* must call vnode_get to avoid races. */
+                fv_slept = 0;
                if (vnode_get(tvp) == 0) {
                    fv_slept=1;
                    /* must release lock, since vnode_put will immediately
@@ -777,9 +819,13 @@ restart:
                /* we can't use the vnode_recycle return value to figure
                 * this out, since the iocount we have to hold makes it
                 * always "fail" */
-               if (AFSTOV(tvc) == tvp)
+               if (AFSTOV(tvc) == tvp) {
+                    if (anumber > 0 && fv_slept) {
+                       QRemove(&tvc->vlruq);
+                       QAdd(&VLRU, &tvc->vlruq);
+                    }
                    code = EBUSY;
-               else
+               } else
                    code = 0;
 #else
                 /*
@@ -802,6 +848,8 @@ restart:
                    anumber--;
                }
                if (fv_slept) {
+                    if (loop++ > 100)
+                       break;
                    uq = VLRU.prev;
                    i = 0;
                    continue;   /* start over - may have raced. */
@@ -810,7 +858,8 @@ restart:
            if (tq == uq)
                break;
        }
-    }
+    } /* end of if (!freeVCList) */
+
     if (!freeVCList) {
        /* none free, making one is better than a panic */
        afs_stats_cmperf.vcacheXAllocs++;       /* count in case we have a leak */
@@ -843,7 +892,8 @@ restart:
        tvc = freeVCList;       /* take from free list */
        freeVCList = tvc->nextfree;
        tvc->nextfree = NULL;
-    }
+    } /* end of if (!freeVCList) */
+
 #endif /* AFS_OSF_ENV */
 
 #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV)
@@ -857,9 +907,9 @@ restart:
     tvc->uncred = 0;
 #endif
 
-    RWLOCK_INIT(&tvc->lock, "vcache lock");
+    AFS_RWLOCK_INIT(&tvc->lock, "vcache lock");
 #if    defined(AFS_SUN5_ENV)
-    RWLOCK_INIT(&tvc->vlock, "vcache vlock");
+    AFS_RWLOCK_INIT(&tvc->vlock, "vcache vlock");
 #endif /* defined(AFS_SUN5_ENV) */
 
     tvc->parentVnode = 0;
@@ -884,6 +934,10 @@ restart:
     tvc->Access = NULL;
     tvc->callback = serverp;    /* to minimize chance that clear
                                 * request is lost */
+#if defined(AFS_DISCON_ENV)
+    tvc->ddirty_next = NULL;
+    tvc->ddirty_flags = 0;
+#endif
 
     i = VCHash(afid);
     j = VCHashV(afid);
@@ -975,6 +1029,12 @@ restart:
     tvc->vmh = tvc->segid = NULL;
     tvc->credp = NULL;
 #endif
+
+#if defined(AFS_CACHE_BYPASS)
+    tvc->cachingStates = 0;
+    tvc->cachingTransitions = 0;
+#endif
+
 #ifdef AFS_BOZONLOCK_ENV
 #if    defined(AFS_SUN5_ENV)
     rw_init(&tvc->rwlock, "vcache rwlock", RW_DEFAULT, NULL);
@@ -1064,6 +1124,11 @@ restart:
     insmntque(tvc, afs_globalVFS);
 #endif /* AFS_OSF_ENV */
 #endif /* AFS_DUX40_ENV */
+#ifdef AFS_FBSD70_ENV
+#ifndef AFS_FBSD80_ENV /* yup.  they put it back. */
+    insmntque(AFSTOV(tvc), afs_globalVFS);
+#endif
+#endif
 #if defined(AFS_SGI_ENV)
     VN_SET_DPAGES(&(tvc->v), (struct pfdat *)NULL);
     osi_Assert((tvc->v.v_flag & VINACT) == 0);
@@ -1095,16 +1160,13 @@ restart:
 }                              /*afs_NewVCache */
 
 
-/*
- * afs_FlushActiveVcaches
+/*!
+ * ???
  *
- * Description:
- *     ???
+ * LOCK: afs_FlushActiveVcaches afs_xvcache N
  *
- * Parameters:
- *     doflocks : Do we handle flocks?
+ * \param doflocks : Do we handle flocks?
  */
-/* LOCK: afs_FlushActiveVcaches afs_xvcache N */
 void
 afs_FlushActiveVcaches(register afs_int32 doflocks)
 {
@@ -1252,11 +1314,8 @@ afs_FlushActiveVcaches(register afs_int32 doflocks)
 
 
 
-/*
- * afs_VerifyVCache
- *
- * Description:
- *     Make sure a cache entry is up-to-date status-wise.
+/*!
+ *   Make sure a cache entry is up-to-date status-wise.
  *
  * NOTE: everywhere that calls this can potentially be sped up
  *       by checking CStatd first, and avoiding doing the InitReq
@@ -1265,11 +1324,26 @@ afs_FlushActiveVcaches(register afs_int32 doflocks)
  *  Anymore, the only places that call this KNOW already that the
  *  vcache is not up-to-date, so we don't screw around.
  *
- * Parameters:
- *     avc  : Ptr to vcache entry to verify.
- *     areq : ???
+ * \param avc  : Ptr to vcache entry to verify.
+ * \param areq : ???
  */
 
+/*!
+ * 
+ *   Make sure a cache entry is up-to-date status-wise.
+ *   
+ *   NOTE: everywhere that calls this can potentially be sped up
+ *       by checking CStatd first, and avoiding doing the InitReq
+ *       if this is up-to-date.
+ *
+ *   Anymore, the only places that call this KNOW already that the
+ * vcache is not up-to-date, so we don't screw around.
+ *
+ * \param avc Pointer to vcache entry to verify.
+ * \param areq
+ *
+ * \return 0 for success or other error codes.
+ */
 int
 afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq)
 {
@@ -1319,20 +1393,14 @@ afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq)
 }                              /*afs_VerifyVCache */
 
 
-/*
- * afs_SimpleVStat
- *
- * Description:
- *     Simple copy of stat info into cache.
+/*!
+ * Simple copy of stat info into cache.
  *
- * Parameters:
- *     avc   : Ptr to vcache entry involved.
- *     astat : Ptr to stat info to copy.
+ * Callers:as of 1992-04-29, only called by WriteVCache
  *
- * Environment:
- *     Nothing interesting.
+ * \param avc   Ptr to vcache entry involved.
+ * \param astat Ptr to stat info to copy.
  *
- * Callers:  as of 1992-04-29, only called by WriteVCache
  */
 static void
 afs_SimpleVStat(register struct vcache *avc,
@@ -1415,20 +1483,17 @@ afs_SimpleVStat(register struct vcache *avc,
 }                              /*afs_SimpleVStat */
 
 
-/*
- * afs_WriteVCache
+/*!
+ * Store the status info *only* back to the server for a
+ * fid/vrequest.
  *
- * Description:
- *     Store the status info *only* back to the server for a
- *     fid/vrequest.
+ * Environment: Must be called with a shared lock held on the vnode.
  *
- * Parameters:
- *     avc     : Ptr to the vcache entry.
- *     astatus : Ptr to the status info to store.
- *     areq    : Ptr to the associated vrequest.
+ * \param avc Ptr to the vcache entry.
+ * \param astatus Ptr to the status info to store.
+ * \param areq Ptr to the associated vrequest.
  *
- * Environment:
- *     Must be called with a shared lock held on the vnode.
+ * \return Operation status.
  */
 
 int
@@ -1444,7 +1509,6 @@ afs_WriteVCache(register struct vcache *avc,
     AFS_STATCNT(afs_WriteVCache);
     afs_Trace2(afs_iclSetp, CM_TRACE_WVCACHE, ICL_TYPE_POINTER, avc,
               ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
-
     do {
        tc = afs_Conn(&avc->fid, areq, SHARED_LOCK);
        if (tc) {
@@ -1484,24 +1548,111 @@ afs_WriteVCache(register struct vcache *avc,
     return code;
 
 }                              /*afs_WriteVCache */
+#if defined(AFS_DISCON_ENV)
 
-/*
- * afs_ProcessFS
+/*!
+ * Store status info only locally, set the proper disconnection flags
+ * and add to dirty list.
  *
- * Description:
- *     Copy astat block into vcache info
+ * \param avc The vcache to be written locally.
+ * \param astatus Get attr fields from local store.
+ * \param attrs This one is only of the vs_size.
  *
- * Parameters:
- *     avc   : Ptr to vcache entry.
- *     astat : Ptr to stat block to copy in.
- *     areq  : Ptr to associated request.
+ * \note Must be called with a shared lock on the vnode
+ */
+int afs_WriteVCacheDiscon(register struct vcache *avc,
+                               register struct AFSStoreStatus *astatus,
+                               struct vattr *attrs)
+{
+    afs_int32 code = 0;
+    afs_int32 flags = 0;
+
+    UpgradeSToWLock(&avc->lock, 700);
+
+    if (!astatus->Mask) {
+
+       return code;
+
+    } else {
+
+       /* Set attributes. */
+       if (astatus->Mask & AFS_SETMODTIME) {
+               avc->m.Date = astatus->ClientModTime;
+               flags |= VDisconSetTime;
+       }
+
+       if (astatus->Mask & AFS_SETOWNER) {
+               printf("Not allowed yet. \n");
+               //avc->m.Owner = astatus->Owner;
+       }
+
+       if (astatus->Mask & AFS_SETGROUP) {
+               printf("Not allowed yet. \n");
+               //avc->m.Group =  astatus->Group;
+       }
+
+       if (astatus->Mask & AFS_SETMODE) {
+               avc->m.Mode = astatus->UnixModeBits;
+
+#if 0  /* XXX: Leaving this out, so it doesn't mess up the file type flag.*/
+
+               if (vType(avc) == VREG) {
+                       avc->m.Mode |= S_IFREG;
+               } else if (vType(avc) == VDIR) {
+                       avc->m.Mode |= S_IFDIR;
+               } else if (vType(avc) == VLNK) {
+                       avc->m.Mode |= S_IFLNK;
+                       if ((avc->m.Mode & 0111) == 0)
+                               avc->mvstat = 1;
+               }
+#endif
+               flags |= VDisconSetMode;
+        }              /* if(astatus.Mask & AFS_SETMODE) */
+
+     }                         /* if (!astatus->Mask) */
+
+     if (attrs->va_size > 0) {
+       /* XXX: Do I need more checks? */
+       /* Truncation operation. */
+       flags |= VDisconTrunc;
+     }
+
+    ObtainWriteLock(&afs_DDirtyVCListLock, 701);
+
+    if (flags) {
+       /* Add to disconnected dirty list and set dirty flag.*/
+       if (!avc->ddirty_flags ||
+               (avc->ddirty_flags == VDisconShadowed)) {
+               /* Not in dirty list. */
+               AFS_DISCON_ADD_DIRTY(avc, 1);
+       }
+
+       avc->ddirty_flags |= flags;
+    }
+
+    ReleaseWriteLock(&afs_DDirtyVCListLock);
+
+    /* XXX: How about the rest of the fields? */
+
+    ConvertWToSLock(&avc->lock);
+
+    return code;
+}
+
+#endif
+
+/*!
+ * Copy astat block into vcache info
  *
- * Environment:
- *     Must be called under a write lock
+ * \note This code may get dataversion and length out of sync if the file has
+ * been modified.  This is less than ideal.  I haven't thought about it sufficiently 
+ * to be certain that it is adequate.
  *
- * Note: this code may get dataversion and length out of sync if the file has
- *       been modified.  This is less than ideal.  I haven't thought about
- *       it sufficiently to be certain that it is adequate.
+ * \note Environment: Must be called under a write lock
+ *
+ * \param avc  Ptr to vcache entry.
+ * \param astat Ptr to stat block to copy in.
+ * \param areq Ptr to associated request.
  */
 void
 afs_ProcessFS(register struct vcache *avc,
@@ -1587,6 +1738,19 @@ afs_ProcessFS(register struct vcache *avc,
 }                              /*afs_ProcessFS */
 
 
+/*!
+ * Get fid from server.
+ *
+ * \param afid 
+ * \param areq Request to be passed on.
+ * \param name Name of ?? to lookup.
+ * \param OutStatus Fetch status.
+ * \param CallBackp 
+ * \param serverp
+ * \param tsyncp
+ *
+ * \return Success status of operation.
+ */
 int
 afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq,
                 char *name, struct VenusFid *nfid,
@@ -1600,7 +1764,7 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq,
     struct AFSFetchStatus OutDirStatus;
     XSTATS_DECLS;
     if (!name)
-       name = "";              /* XXX */
+       name = "";              /* XXX */    
     do {
        tc = afs_Conn(afid, areq, SHARED_LOCK);
        if (tc) {
@@ -1625,21 +1789,19 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq,
 }
 
 
-/*
+/*!
  * afs_GetVCache
  *
- * Description:
- *     Given a file id and a vrequest structure, fetch the status
- *     information associated with the file.
+ * Given a file id and a vrequest structure, fetch the status
+ * information associated with the file.
  *
- * Parameters:
- *     afid : File ID.
- *     areq : Ptr to associated vrequest structure, specifying the
- *             user whose authentication tokens will be used.
- *      avc  : caller may already have a vcache for this file, which is
- *             already held.
+ * \param afid File ID.
+ * \param areq Ptr to associated vrequest structure, specifying the
+ *  user whose authentication tokens will be used.
+ * \param avc Caller may already have a vcache for this file, which is
+ *  already held.
  *
- * Environment:
+ * \note Environment:
  *     The cache entry is returned with an increased vrefCount field.
  *     The entry must be discarded by calling afs_PutVCache when you
  *     are through using the pointer to the cache entry.
@@ -1655,11 +1817,12 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq,
  *     of a parent dir cache entry, given a file (to check its access
  *     control list).  It also allows renames to be handled easily by
  *     locking directories in a constant order.
- * NB.  NewVCache -> FlushVCache presently (4/10/95) drops the xvcache lock.
+ * 
+ * \note NB.  NewVCache -> FlushVCache presently (4/10/95) drops the xvcache lock.
+ *
+ * \note Might have a vcache structure already, which must
+ *  already be held by the caller 
  */
-   /* might have a vcache structure already, which must
-    * already be held by the caller */
-
 struct vcache *
 afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
              afs_int32 * cached, struct vcache *avc)
@@ -1694,7 +1857,8 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
        if (cached)
            *cached = 1;
        osi_Assert((tvc->states & CVInit) == 0);
-       if (tvc->states & CStatd) {
+       /* If we are in readdir, return the vnode even if not statd */
+       if ((tvc->states & CStatd) || afs_InReadDir(tvc)) {
            ReleaseSharedLock(&afs_xvcache);
            return tvc;
        }
@@ -1763,6 +1927,20 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
          ObtainWriteLock(&tvc->lock, 954);
        if (!iheldthelock)
            VOP_UNLOCK(vp, LK_EXCLUSIVE, current_proc());
+#elif defined(AFS_FBSD80_ENV)
+       iheldthelock = VOP_ISLOCKED(vp);
+       if (!iheldthelock) {
+           /* nosleep/sleep lock order reversal */
+           int glocked = ISAFS_GLOCK();
+           if (glocked)
+               AFS_GUNLOCK();
+           vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+           if (glocked)
+               AFS_GLOCK();
+       }
+       vinvalbuf(vp, V_SAVE, curthread, PINOD, 0);
+       if (!iheldthelock)
+           VOP_UNLOCK(vp, 0);
 #elif defined(AFS_FBSD60_ENV)
        iheldthelock = VOP_ISLOCKED(vp, curthread);
        if (!iheldthelock)
@@ -1836,9 +2014,31 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
        if (afs_DynrootNewVnode(tvc, &OutStatus)) {
            afs_ProcessFS(tvc, &OutStatus, areq);
            tvc->states |= CStatd | CUnique;
+           tvc->parentVnode  = OutStatus.ParentVnode;
+           tvc->parentUnique = OutStatus.ParentUnique;
            code = 0;
        } else {
-           code = afs_FetchStatus(tvc, afid, areq, &OutStatus);
+
+           if (AFS_IS_DISCONNECTED) {
+               /* Nothing to do otherwise...*/
+               code = ENETDOWN;
+               printf("Network is down in afs_GetCache");
+           } else
+               code = afs_FetchStatus(tvc, afid, areq, &OutStatus);
+
+           /* For the NFS translator's benefit, make sure
+            * non-directory vnodes always have their parent FID set
+            * correctly, even when created as a result of decoding an
+            * NFS filehandle.  It would be nice to also do this for
+            * directories, but we can't because the fileserver fills
+            * in the FID of the directory itself instead of that of
+            * its parent.
+            */
+            if (!code && OutStatus.FileType != Directory &&
+               !tvc->parentVnode) {
+               tvc->parentVnode  = OutStatus.ParentVnode;
+               tvc->parentUnique = OutStatus.ParentUnique;
+            }
        }
     }
 
@@ -1856,6 +2056,19 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
 
 
 
+/*!
+ * Lookup a vcache by fid. Look inside the cache first, if not
+ * there, lookup the file on the server, and then get it's fresh
+ * cache entry.
+ * 
+ * \param afid
+ * \param areq 
+ * \param cached Is element cached? If NULL, don't answer.
+ * \param adp
+ * \param aname
+ *
+ * \return The found element or NULL.
+ */
 struct vcache *
 afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
                 afs_int32 * cached, struct vcache *adp, char *aname)
@@ -1912,9 +2125,14 @@ afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
     nfid = *afid;
     now = osi_Time();
     origCBs = afs_allCBs;      /* if anything changes, we don't have a cb */
-    code =
-       afs_RemoteLookup(&adp->fid, areq, aname, &nfid, &OutStatus, &CallBack,
-                        &serverp, &tsync);
+    
+    if (AFS_IS_DISCONNECTED) {
+       printf("Network is down in afs_LookupVcache\n");
+        code = ENETDOWN;
+    } else 
+        code =
+           afs_RemoteLookup(&adp->fid, areq, aname, &nfid, &OutStatus, 
+                            &CallBack, &serverp, &tsync);
 
 #if    defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
   loop2:
@@ -2040,6 +2258,9 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
 #ifdef AFS_OSF_ENV
     int vg;
 #endif
+#ifdef AFS_DARWIN80_ENV
+    vnode_t tvp;
+#endif
 
     start = osi_Time();
 
@@ -2095,8 +2316,16 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
                afs_osi_Sleep(&tvc->states);
                goto rootvc_loop;
             }
-            if (vnode_get(AFSTOV(tvc)))       /* this bumps ref count */
-                continue;
+           tvp = AFSTOV(tvc);
+           if (vnode_get(tvp))       /* this bumps ref count */
+               continue;
+           if (vnode_ref(tvp)) {
+               AFS_GUNLOCK();
+               /* AFSTOV(tvc) may be NULL */
+               vnode_put(tvp);
+               AFS_GLOCK();
+               continue;
+           }
 #endif
            break;
        }
@@ -2114,6 +2343,7 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
         if (tvc) {
             AFS_GUNLOCK();
             vnode_put(AFSTOV(tvc));
+            vnode_rele(AFSTOV(tvc));
             AFS_GLOCK();
         }
 #endif
@@ -2136,7 +2366,7 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
        if (cached)
            *cached = 1;
        afs_stats_cmperf.vcacheHits++;
-#ifdef AFS_OSF_ENV
+#if    defined(AFS_OSF_ENV) || defined(AFS_DARWIN80_ENV)
        /* we already bumped the ref count in the for loop above */
 #else /* AFS_OSF_ENV */
        osi_vnhold(tvc, 0);
@@ -2258,9 +2488,70 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
 }
 
 
+/*!
+ * Update callback status and (sometimes) attributes of a vnode.
+ * Called after doing a fetch status RPC. Whilst disconnected, attributes
+ * shouldn't be written to the vcache here.
+ *
+ * \param avc
+ * \param afid
+ * \param areq
+ * \param Outsp Server status after rpc call.
+ * \param acb Callback for this vnode.
+ *
+ * \note The vcache must be write locked.
+ */
+void
+afs_UpdateStatus(struct vcache *avc,
+                       struct VenusFid *afid,
+                       struct vrequest *areq,
+                       struct AFSFetchStatus *Outsp,
+                       struct AFSCallBack *acb,
+                       afs_uint32 start)
+{
+    struct volume *volp;
 
-/*
- * must be called with avc write-locked
+    if (!AFS_IN_SYNC)
+       /* Dont write status in vcache if resyncing after a disconnection. */
+       afs_ProcessFS(avc, Outsp, areq);
+
+    volp = afs_GetVolume(afid, areq, READ_LOCK);
+    ObtainWriteLock(&afs_xcbhash, 469);
+    avc->states |= CTruth;
+    if (avc->callback /* check for race */ ) {
+       if (acb->ExpirationTime != 0) {
+           avc->cbExpires = acb->ExpirationTime + start;
+           avc->states |= CStatd;
+           avc->states &= ~CBulkFetching;
+           afs_QueueCallback(avc, CBHash(acb->ExpirationTime), volp);
+       } else if (avc->states & CRO) {
+           /* ordinary callback on a read-only volume -- AFS 3.2 style */
+           avc->cbExpires = 3600 + start;
+           avc->states |= CStatd;
+           avc->states &= ~CBulkFetching;
+           afs_QueueCallback(avc, CBHash(3600), volp);
+       } else {
+           afs_DequeueCallback(avc);
+           avc->callback = NULL;
+           avc->states &= ~(CStatd | CUnique);
+           if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1))
+               osi_dnlc_purgedp(avc);  /* if it (could be) a directory */
+       }
+    } else {
+       afs_DequeueCallback(avc);
+       avc->callback = NULL;
+       avc->states &= ~(CStatd | CUnique);
+       if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1))
+           osi_dnlc_purgedp(avc);      /* if it (could be) a directory */
+    }
+    ReleaseWriteLock(&afs_xcbhash);
+    if (volp)
+       afs_PutVolume(volp, READ_LOCK);
+
+}
+
+/*!
+ * Must be called with avc write-locked
  * don't absolutely have to invalidate the hint unless the dv has
  * changed, but be sure to get it right else there will be consistency bugs.
  */
@@ -2273,7 +2564,6 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid,
     register struct conn *tc;
     struct AFSCallBack CallBack;
     struct AFSVolSync tsync;
-    struct volume *volp;
     XSTATS_DECLS;
     do {
        tc = afs_Conn(afid, areq, SHARED_LOCK);
@@ -2297,38 +2587,7 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid,
              SHARED_LOCK, NULL));
 
     if (!code) {
-       afs_ProcessFS(avc, Outsp, areq);
-       volp = afs_GetVolume(afid, areq, READ_LOCK);
-       ObtainWriteLock(&afs_xcbhash, 469);
-       avc->states |= CTruth;
-       if (avc->callback /* check for race */ ) {
-           if (CallBack.ExpirationTime != 0) {
-               avc->cbExpires = CallBack.ExpirationTime + start;
-               avc->states |= CStatd;
-               avc->states &= ~CBulkFetching;
-               afs_QueueCallback(avc, CBHash(CallBack.ExpirationTime), volp);
-           } else if (avc->states & CRO) {     /* ordinary callback on a read-only volume -- AFS 3.2 style */
-               avc->cbExpires = 3600 + start;
-               avc->states |= CStatd;
-               avc->states &= ~CBulkFetching;
-               afs_QueueCallback(avc, CBHash(3600), volp);
-           } else {
-               afs_DequeueCallback(avc);
-               avc->callback = NULL;
-               avc->states &= ~(CStatd | CUnique);
-               if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1))
-                   osi_dnlc_purgedp(avc);      /* if it (could be) a directory */
-           }
-       } else {
-           afs_DequeueCallback(avc);
-           avc->callback = NULL;
-           avc->states &= ~(CStatd | CUnique);
-           if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1))
-               osi_dnlc_purgedp(avc);  /* if it (could be) a directory */
-       }
-       ReleaseWriteLock(&afs_xcbhash);
-       if (volp)
-           afs_PutVolume(volp, READ_LOCK);
+       afs_UpdateStatus(avc, afid, areq, Outsp, &CallBack, start);
     } else {
        /* used to undo the local callback, but that's too extreme.
         * There are plenty of good reasons that fetchstatus might return
@@ -2491,17 +2750,12 @@ afs_StuffVcache(register struct VenusFid *afid,
 }                              /*afs_StuffVcache */
 #endif
 
-/*
- * afs_PutVCache
- *
- * Description:
- *     Decrements the reference count on a cache entry.
+/*!
+ * Decrements the reference count on a cache entry.
  *
- * Parameters:
- *     avc : Pointer to the cache entry to decrement.
+ * \param avc Pointer to the cache entry to decrement.
  *
- * Environment:
- *     Nothing interesting.
+ * \note Environment: Nothing interesting.
  */
 void
 afs_PutVCache(register struct vcache *avc)
@@ -2521,6 +2775,39 @@ afs_PutVCache(register struct vcache *avc)
 }                              /*afs_PutVCache */
 
 
+/*!
+ * Reset a vcache entry, so local contents are ignored, and the
+ * server will be reconsulted next time the vcache is used
+ * 
+ * \param avc Pointer to the cache entry to reset
+ * \param acred 
+ *
+ * \note avc must be write locked on entry
+ */
+void
+afs_ResetVCache(struct vcache *avc, struct AFS_UCRED *acred) {
+    ObtainWriteLock(&afs_xcbhash, 456);
+    afs_DequeueCallback(avc);
+    avc->states &= ~(CStatd | CDirty); /* next reference will re-stat */
+    ReleaseWriteLock(&afs_xcbhash);
+    /* now find the disk cache entries */
+    afs_TryToSmush(avc, acred, 1);
+    osi_dnlc_purgedp(avc);
+    if (avc->linkData && !(avc->states & CCore)) {
+       afs_osi_Free(avc->linkData, strlen(avc->linkData) + 1);
+       avc->linkData = NULL;
+    }
+}
+
+/*!
+ * Sleepa when searching for a vcache. Releases all the pending locks,
+ * sleeps then obtains the previously released locks.
+ *
+ * \param vcache Enter sleep state.
+ * \param flag Determines what locks to use.
+ *
+ * \return 
+ */
 static void findvc_sleep(struct vcache *avc, int flag) {
     if (flag & IS_SLOCK) {
            ReleaseSharedLock(&afs_xvcache);
@@ -2542,23 +2829,18 @@ static void findvc_sleep(struct vcache *avc, int flag) {
        }
     }
 }
-/*
- * afs_FindVCache
+/*!
+ * Find a vcache entry given a fid.
  *
- * Description:
- *     Find a vcache entry given a fid.
+ * \param afid Pointer to the fid whose cache entry we desire.
+ * \param retry (SGI-specific) tell the caller to drop the lock on xvcache,
+ *  unlock the vnode, and try again.
+ * \param flag Bit 1 to specify whether to compute hit statistics.  Not
+ *  set if FindVCache is called as part of internal bookkeeping.
  *
- * Parameters:
- *     afid : Pointer to the fid whose cache entry we desire.
- *      retry: (SGI-specific) tell the caller to drop the lock on xvcache,
- *             unlock the vnode, and try again.
- *      flags: bit 1 to specify whether to compute hit statistics.  Not
- *             set if FindVCache is called as part of internal bookkeeping.
- *
- * Environment:
- *     Must be called with the afs_xvcache lock at least held at
- *     the read level.  In order to do the VLRU adjustment, the xvcache lock
- *      must be shared-- we upgrade it here.
+ * \note Environment: Must be called with the afs_xvcache lock at least held at
+ * the read level.  In order to do the VLRU adjustment, the xvcache lock
+ * must be shared-- we upgrade it here.
  */
 
 struct vcache *
@@ -2570,6 +2852,9 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
 #if defined( AFS_OSF_ENV)
     int vg;
 #endif
+#ifdef AFS_DARWIN80_ENV
+    vnode_t tvp;
+#endif
 
     AFS_STATCNT(afs_FindVCache);
 
@@ -2594,8 +2879,16 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
                 findvc_sleep(tvc, flag);
                goto findloop;
             }
-            if (vnode_get(AFSTOV(tvc)))
-                continue;
+           tvp = AFSTOV(tvc);
+           if (vnode_get(tvp))
+               continue;
+           if (vnode_ref(tvp)) {
+               AFS_GUNLOCK();
+               /* AFSTOV(tvc) may be NULL */
+               vnode_put(tvp);
+               AFS_GLOCK();
+               continue;
+           }
 #endif
            break;
        }
@@ -2605,7 +2898,7 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
     if (tvc) {
        if (retry)
            *retry = 0;
-#if !defined(AFS_OSF_ENV)
+#if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN80_ENV)
        osi_vnhold(tvc, retry); /* already held, above */
        if (retry && *retry)
            return 0;
@@ -2663,28 +2956,22 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
     return tvc;
 }                              /*afs_FindVCache */
 
-/*
- * afs_NFSFindVCache
- *
- * Description:
- *     Find a vcache entry given a fid. Does a wildcard match on what we
- *     have for the fid. If more than one entry, don't return anything.
+/*!
+ * Find a vcache entry given a fid. Does a wildcard match on what we
+ * have for the fid. If more than one entry, don't return anything.
  *
- * Parameters:
- *     avcp : Fill in pointer if we found one and only one.
- *     afid : Pointer to the fid whose cache entry we desire.
- *      retry: (SGI-specific) tell the caller to drop the lock on xvcache,
+ * \param avcp Fill in pointer if we found one and only one.
+ * \param afid Pointer to the fid whose cache entry we desire.
+ * \param retry (SGI-specific) tell the caller to drop the lock on xvcache,
  *             unlock the vnode, and try again.
- *      flags: bit 1 to specify whether to compute hit statistics.  Not
+ * \param flags bit 1 to specify whether to compute hit statistics.  Not
  *             set if FindVCache is called as part of internal bookkeeping.
  *
- * Environment:
- *     Must be called with the afs_xvcache lock at least held at
- *     the read level.  In order to do the VLRU adjustment, the xvcache lock
- *      must be shared-- we upgrade it here.
+ * \note Environment: Must be called with the afs_xvcache lock at least held at
+ *  the read level.  In order to do the VLRU adjustment, the xvcache lock
+ *  must be shared-- we upgrade it here.
  *
- * Return value:
- *     number of matches found.
+ * \return Number of matches found.
  */
 
 int afs_duplicate_nfs_fids = 0;
@@ -2699,6 +2986,9 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
 #ifdef  AFS_OSF_ENV
     int vg;
 #endif
+#ifdef AFS_DARWIN80_ENV
+    vnode_t tvp;
+#endif
 
     AFS_STATCNT(afs_FindVCache);
 
@@ -2714,7 +3004,6 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
            && ((tvc->fid.Fid.Unique & 0xffffff) == afid->Fid.Unique)
            && (tvc->fid.Cell == afid->Cell)) {
            if (tvc->states & CVInit) {
-               int lock;
                ReleaseSharedLock(&afs_xvcache);
                afs_osi_Sleep(&tvc->states);
                goto loop;
@@ -2735,10 +3024,19 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
                afs_osi_Sleep(&tvc->states);
                goto loop;
             }
-            if (vnode_get(AFSTOV(tvc))) {
-                /* This vnode no longer exists. */
-                continue;
-            }
+           tvp = AFSTOV(tvc);
+           if (vnode_get(tvp)) {
+               /* This vnode no longer exists. */
+               continue;
+           }
+           if (vnode_ref(tvp)) {
+               /* This vnode no longer exists. */
+               AFS_GUNLOCK();
+               /* AFSTOV(tvc) may be NULL */
+               vnode_put(tvp);
+               AFS_GLOCK();
+               continue;
+           }
 #endif /* AFS_DARWIN80_ENV */
            count++;
            if (found_tvc) {
@@ -2826,10 +3124,10 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
 
 
 
-/*
- * afs_vcacheInit
- *
+/*!
  * Initialize vcache related variables
+ *
+ * \param astatSize
  */
 void
 afs_vcacheInit(int astatSize)
@@ -2853,7 +3151,7 @@ afs_vcacheInit(int astatSize)
     freeVCList = NULL;
 #endif
 
-    RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
+    AFS_RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
     LOCK_INIT(&afs_xvcb, "afs_xvcb");
 
 #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
@@ -2894,9 +3192,8 @@ afs_vcacheInit(int astatSize)
        QInit(&afs_vhashTV[i]);
 }
 
-/*
- * shutdown_vcache
- *
+/*!
+ * Shutdown vcache.
  */
 void
 shutdown_vcache(void)
@@ -2979,19 +3276,46 @@ shutdown_vcache(void)
     }
     afs_cbrSpace = 0;
 
-#ifdef  KERNEL_HAVE_PIN
-    unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
-#endif
 #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
     afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
 #endif
+#ifdef  KERNEL_HAVE_PIN
+    unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
+#endif
 
 #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
     freeVCList = Initial_freeVCList = 0;
 #endif
-    RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
+    AFS_RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
     LOCK_INIT(&afs_xvcb, "afs_xvcb");
     QInit(&VLRU);
     for(i = 0; i < VCSIZE; ++i)
        QInit(&afs_vhashTV[i]);
 }
+
+#ifdef AFS_DISCON_ENV
+void afs_DisconGiveUpCallbacks() {
+    int i;
+    struct vcache *tvc;
+    int nq=0;
+            
+    ObtainWriteLock(&afs_xvcache, 1002); /* XXX - should be a unique number */
+    
+    /* Somehow, walk the set of vcaches, with each one coming out as tvc */
+    for (i = 0; i < VCSIZE; i++) {
+        for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
+            if ((tvc->states & CRO) == 0 && tvc->callback) {
+                afs_QueueVCB(tvc);
+                tvc->callback = NULL;
+                nq++;
+            }
+        }
+    }
+    /*printf("%d callbacks to be discarded. queued ... ", nq);*/
+    afs_FlushVCBs(0);
+    
+    ReleaseWriteLock(&afs_xvcache);
+    /*printf("gone\n");*/
+}
+
+#endif