]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DAFS: Add explicit 'valid' field for index maps
authorAndrew Deason <adeason@sinenomine.net>
Thu, 29 Sep 2011 20:22:35 +0000 (15:22 -0500)
committerDerrick Brashear <shadow@dementix.org>
Fri, 30 Sep 2011 23:51:41 +0000 (16:51 -0700)
The CB, FE, and host serialization structures were just using the
relevant indices to determine whether or not an entry mapping and old
index to a new index was populated with actual data. For host
structures, this really isn't sufficient, since our index can be 0,
and the structure is calloc'd, so the index in the structure could
also be 0.

Add a flag explicitly stating whether or not the structure has been
filled in, to make this unambiguous.

Change-Id: Ia69e25fa73e10dc10cf3ddf08bb4feb2c9958674
Reviewed-on: http://gerrit.openafs.org/5526
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/tviced/serialize_state.h
src/viced/callback.c
src/viced/host.c

index b213518bb230026f681d423e7c6fe72c3830d54d..6478e714ea39f55f1640319aacbc227e810db038 100644 (file)
@@ -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 */
 };
index d9b9b186671473c2d82da9c647519c7018f4dfb8..4da7d73edf79db060724f2841ce89b5f68e0f33f 100644 (file)
@@ -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 {
index 3d864a3031c681b20bac601ad8e36d07ce51a373..7f94344193835c1debcdda782ccdc0978830b285 100644 (file)
@@ -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 {