abstract-reset-vcache-20090119
[openafs.git] / src / afs / afs_vcache.c
index 3307e51..e298083 100644 (file)
@@ -1624,7 +1624,7 @@ int afs_WriteVCacheDiscon(register struct vcache *avc,
        if (!avc->ddirty_flags ||
                (avc->ddirty_flags == VDisconShadowed)) {
                /* Not in dirty list. */
-               AFS_DISCON_ADD_DIRTY(avc);
+               AFS_DISCON_ADD_DIRTY(avc, 1);
        }
 
        avc->ddirty_flags |= flags;
@@ -2020,16 +2020,9 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
        } else {
 
            if (AFS_IS_DISCONNECTED) {
-               if (AFS_IS_DISCON_RW) {
-                   if (vType(tvc) == VDIR)
-                       OutStatus.FileType = Directory;
-
-                   code = tvc?0:ENOENT;
-               } else {
-                   /* Nothing to do otherwise...*/
-                   code = ENETDOWN;
-                   printf("Network is down in afs_GetCache");
-               }
+               /* Nothing to do otherwise...*/
+               code = ENETDOWN;
+               printf("Network is down in afs_GetCache");
            } else
                code = afs_FetchStatus(tvc, afid, areq, &OutStatus);
 
@@ -2783,6 +2776,30 @@ afs_PutVCache(register struct vcache *avc)
 
 
 /*!
+ * 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.
  *
@@ -3288,10 +3305,8 @@ void afs_DisconGiveUpCallbacks() {
     for (i = 0; i < VCSIZE; i++) {
         for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
             if ((tvc->states & CRO) == 0 && tvc->callback) {
-                /* XXX - should we check if the callback has expired here? */
                 afs_QueueVCB(tvc);
                 tvc->callback = NULL;
-                tvc->states &- ~(CStatd | CUnique);
                 nq++;
             }
         }