}
*ec = VOFFLINE;
}
- ReleaseVolumeHeader(vp->header);
+ VChangeState_r(vp, VOL_STATE_UNATTACHED);
+ FreeVolumeHeader(vp);
vp = NULL;
break;
}
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);
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++);
}
#endif /* AFS_DEMAND_ATTACH_FS */
if (*ec) {
/* maintain (nUsers==0) => header in LRU invariant */
- ReleaseVolumeHeader(vp->header);
+ FreeVolumeHeader(vp);
}
}