volser: Preserve needsSalvaged during restore
authorAndrew Deason <adeason@sinenomine.net>
Wed, 9 Nov 2011 23:04:09 +0000 (17:04 -0600)
committerDerrick Brashear <shadow@dementix.org>
Thu, 10 Nov 2011 03:19:25 +0000 (19:19 -0800)
Some of the routines during a volume restore may set needsSalvaged, if
an inconsistency is detected while writing the given volume data.
However, after the data is read, we set the volume header information
to what was found in the dump stream, ignoring any needsSalvaged that
may have been set.

To ensure that inconsistent volumes in this situation actually get
demand-salvaged (for DAFS) or offlined (non-DAFS), keep the value of
needsSalvaged in the header, if it was set.

Change-Id: I575d14d84120be0fbbeb185ed2726f1285e6f2ce
Reviewed-on: http://gerrit.openafs.org/5822
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/volser/dumpstuff.c

index af0fc5a..3a6639a 100644 (file)
@@ -1226,6 +1226,8 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
     vol.cloneId = cookie->clone;
     vol.parentId = cookie->parent;
 
+    V_needsSalvaged(vp) = 0;
+
     tdelo = delo;
     while (1) {
        if (ReadVnodes(iodp, vp, 0, b1, s1, b2, s2, tdelo)) {
@@ -1267,6 +1269,11 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 
   clean:
     ClearVolumeStats(&vol);
+    if (V_needsSalvaged(vp)) {
+       /* needsSalvaged may have been set while we tried to write volume data.
+        * prevent it from getting overwritten. */
+       vol.needsSalvaged = V_needsSalvaged(vp);
+    }
     CopyVolumeHeader(&vol, &V_disk(vp));
     V_destroyMe(vp) = 0;
     VUpdateVolume(&vupdate, vp);