dafs-drop-volheaders-20080925
authorSteven Jenkins <steven@endpoint.com>
Thu, 25 Sep 2008 08:50:01 +0000 (08:50 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 25 Sep 2008 08:50:01 +0000 (08:50 +0000)
LICENSE IPL10
FIXES 117470

Under certain demand salvage scenarios, it is possible for a stale header
to remain cached with the needsSalvaged flag asserted. Although this will
not affect clients accessing the volume over afsint, it is an issue for
volser clients. VAttachVolumeByName in volser will always attempt to pull
the header over FSSYNC before doing a disk read, under the assumption that
a cached entry in the fileserver will be more current than what is on
disk. This patch causes the fileserver to aggresively invalidate disk
header cache entries when a salvage is in-progress.

src/vol/volume.c

index 0e1bdcf..851ce38 100644 (file)
@@ -2914,7 +2914,8 @@ GetVolume(Error * ec, Error * client_ec, VolId volumeId, Volume * hint, int flag
               }
               *ec = VOFFLINE;
           }
-          ReleaseVolumeHeader(vp->header);
+          VChangeState_r(vp, VOL_STATE_UNATTACHED);
+          FreeVolumeHeader(vp);
           vp = NULL;
           break;
        }
@@ -3922,8 +3923,13 @@ VRequestSalvage_r(Error * ec, Volume * vp, int reason, int flags)
        vp->salvage.reason = reason;
        vp->stats.last_salvage = FT_ApproxTime();
        if (flags & VOL_SALVAGE_INVALIDATE_HEADER) {
-           /* XXX this should likely be changed to FreeVolumeHeader() */
-           ReleaseVolumeHeader(vp->header);
+           /* Instead of ReleaseVolumeHeader, we do FreeVolumeHeader() 
+               so that the the next VAttachVolumeByVp_r() invocation 
+               of attach2() will pull in a cached header 
+               entry and fail, then load a fresh one from disk and attach 
+               it to the volume.             
+           */
+           FreeVolumeHeader(vp);
        }
        if (vp->stats.salvages < SALVAGE_COUNT_MAX) {
            VChangeState_r(vp, VOL_STATE_SALVAGING);
@@ -6180,7 +6186,12 @@ VInitVolumeHeaderCache(afs_uint32 howMany)
     volume_hdr_LRU.stats.used = howMany;
     volume_hdr_LRU.stats.attached = 0;
     hp = (struct volHeader *)(calloc(howMany, sizeof(struct volHeader)));
+    assert(hp != NULL);
+
     while (howMany--)
+       /* We are using ReleaseVolumeHeader to initialize the values on the header list
+        * to ensure they have the right values
+        */
        ReleaseVolumeHeader(hp++);
 }
 
@@ -6377,7 +6388,7 @@ LoadVolumeHeader(Error * ec, Volume * vp)
 #endif /* AFS_DEMAND_ATTACH_FS */
     if (*ec) {
        /* maintain (nUsers==0) => header in LRU invariant */
-       ReleaseVolumeHeader(vp->header);
+       FreeVolumeHeader(vp);
     }
 }