]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-dafs-drop-volheaders-20080925
authorSteven Jenkins <steven@endpoint.com>
Thu, 25 Sep 2008 08:50:16 +0000 (08:50 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 25 Sep 2008 08:50:16 +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.

(cherry picked from commit 1659861640035f5405429194e72665839cff3720)

src/vol/volume.c

index eed4789d904c19dc7af0b7c43c442902e71ec9ee..5063059ba4c407fa010dd7c4456abf93a3fe2b92 100644 (file)
@@ -2920,7 +2920,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;
        }
@@ -3928,8 +3929,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);
@@ -6186,7 +6192,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++);
 }
 
@@ -6383,7 +6394,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);
     }
 }