DAFS: Skip hosts with invalid flags on restore
[openafs.git] / src / viced / host.c
index 3d864a3..558f7a7 100644 (file)
@@ -3367,6 +3367,16 @@ h_stateRestoreHost(struct fs_dump_state * state)
        osi_Assert(hcps != NULL);
     }
 
+    if ((hdsk.hostFlags & HWHO_INPROGRESS) || !(hdsk.hostFlags & ALTADDR)) {
+       char hoststr[16];
+       ViceLog(0, ("h_stateRestoreHost: skipping host %s:%d due to invalid flags 0x%x\n",
+                   afs_inet_ntoa_r(hdsk.host, hoststr), (int)ntohs(hdsk.port),
+                   (unsigned)hdsk.hostFlags));
+       bail = 0;
+       state->h_map.entries[hdsk.index].valid = FS_STATE_IDX_SKIPPED;
+       goto done;
+    }
+
     /* for restoring state, we better be able to get a host! */
     host = GetHT();
     osi_Assert(host != NULL);
@@ -3399,6 +3409,7 @@ h_stateRestoreHost(struct fs_dump_state * state)
     h_InsertList_r(host);
 
     /* setup host id map entry */
+    state->h_map.entries[hdsk.index].valid = FS_STATE_IDX_VALID;
     state->h_map.entries[hdsk.index].old_idx = hdsk.index;
     state->h_map.entries[hdsk.index].new_idx = host->index;
 
@@ -3464,7 +3475,8 @@ h_OldToNew(struct fs_dump_state * state, afs_uint32 old, afs_uint32 * new)
     if (old >= state->h_map.len) {
        ViceLog(0, ("h_OldToNew: index %d is out of range\n", old));
        ret = 1;
-    } else if (state->h_map.entries[old].old_idx != old) { /* sanity check */
+    } else if (state->h_map.entries[old].valid != FS_STATE_IDX_VALID ||
+               state->h_map.entries[old].old_idx != old) { /* sanity check */
        ViceLog(0, ("h_OldToNew: index %d points to an invalid host record\n", old));
        ret = 1;
     } else {