diff --git a/src/tviced/serialize_state.h b/src/tviced/serialize_state.h index b213518bb2..6478e714ea 100644 --- a/src/tviced/serialize_state.h +++ b/src/tviced/serialize_state.h @@ -39,6 +39,9 @@ #define HOST_STATE_VALID_WINDOW 1800 /* 30 minutes */ +/* values for the 'valid' field in idx_map_entry_t */ +#define FS_STATE_IDX_VALID 1 + /* * on-disk structures */ @@ -205,6 +208,7 @@ struct AVDiskEntry { * dump runtime state */ struct idx_map_entry_t { + byte valid; /* whether or not this entry has been populated */ afs_uint32 old_idx; /* host hash id from last runtime */ afs_uint32 new_idx; /* host hash id for this runtime */ }; diff --git a/src/viced/callback.c b/src/viced/callback.c index d9b9b18667..4da7d73edf 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -2522,6 +2522,7 @@ cb_stateDiskEntryToFE(struct fs_dump_state * state, ret = 1; goto done; } + state->fe_map.entries[in->index].valid = FS_STATE_IDX_VALID; state->fe_map.entries[in->index].old_idx = in->index; state->fe_map.entries[in->index].new_idx = fetoi(out); @@ -2552,6 +2553,7 @@ cb_stateDiskEntryToCB(struct fs_dump_state * state, ret = 1; goto done; } + state->cb_map.entries[in->index].valid = FS_STATE_IDX_VALID; state->cb_map.entries[in->index].old_idx = in->index; state->cb_map.entries[in->index].new_idx = cbtoi(out); @@ -2586,7 +2588,8 @@ fe_OldToNew(struct fs_dump_state * state, afs_uint32 old, afs_uint32 * new) if (old >= state->fe_map.len) { ViceLog(0, ("fe_OldToNew: index %d is out of range\n", old)); ret = 1; - } else if (state->fe_map.entries[old].old_idx != old) { /* sanity check */ + } else if (state->fe_map.entries[old].valid != FS_STATE_IDX_VALID || + state->fe_map.entries[old].old_idx != old) { /* sanity check */ ViceLog(0, ("fe_OldToNew: index %d points to an invalid FileEntry record\n", old)); ret = 1; } else { @@ -2611,7 +2614,8 @@ cb_OldToNew(struct fs_dump_state * state, afs_uint32 old, afs_uint32 * new) if (old >= state->cb_map.len) { ViceLog(0, ("cb_OldToNew: index %d is out of range\n", old)); ret = 1; - } else if (state->cb_map.entries[old].old_idx != old) { /* sanity check */ + } else if (state->cb_map.entries[old].valid != FS_STATE_IDX_VALID || + state->cb_map.entries[old].old_idx != old) { /* sanity check */ ViceLog(0, ("cb_OldToNew: index %d points to an invalid CallBack record\n", old)); ret = 1; } else { diff --git a/src/viced/host.c b/src/viced/host.c index 3d864a3031..7f94344193 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -3399,6 +3399,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 +3465,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 {