mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 06:50:12 +00:00
viced: Ignore on-disk fsstate HashTable data
Currently, if the fileserver tries to restore fsstate.dat and the included FE hashtable does not match our in-memory size (FEHASH_SIZE), we'll discard the entire state file. This is unnecessary, since we could just add the FEs to our hashtable ourselves; the on-disk hashtable data is not required. Furthermore, loading the hashtable from disk isn't even terribly efficient when the hashtable sizes do match, since any indices need to be converted from the on-disk values to in-memory values (fe_OldToNew). So if we're processing the FE hashtable indices anyway, we might as well just add them to the hashtable like normal, and ignore the values on disk. So, ignore loading the "fehash" data from the fsstate file, and just add file entries to our hashtable as we read them in. This ends up being slightly faster, simpler, and more flexible, since we don't need to worry about reflecting any changes to our hashtable in the fsstate.dat file. At least for now, we still write our hashtable data to fsstate.dat, in case other utilities (or older fileservers) need it. [adeason@sinenomine.net: Converted to always ignore on-disk hashtable data.] Change-Id: Ie53a24a5d24906ac55d13eb22713b73dc4bfaab2 Reviewed-on: https://gerrit.openafs.org/14738 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
ef7aeddec1
commit
f3629f87da
@ -1713,7 +1713,6 @@ static int cb_stateSaveFEHash(struct fs_dump_state * state);
|
|||||||
static int cb_stateSaveFEs(struct fs_dump_state * state);
|
static int cb_stateSaveFEs(struct fs_dump_state * state);
|
||||||
static int cb_stateSaveFE(struct fs_dump_state * state, struct FileEntry * fe);
|
static int cb_stateSaveFE(struct fs_dump_state * state, struct FileEntry * fe);
|
||||||
static int cb_stateRestoreTimeouts(struct fs_dump_state * state);
|
static int cb_stateRestoreTimeouts(struct fs_dump_state * state);
|
||||||
static int cb_stateRestoreFEHash(struct fs_dump_state * state);
|
|
||||||
static int cb_stateRestoreFEs(struct fs_dump_state * state);
|
static int cb_stateRestoreFEs(struct fs_dump_state * state);
|
||||||
static int cb_stateRestoreFE(struct fs_dump_state * state);
|
static int cb_stateRestoreFE(struct fs_dump_state * state);
|
||||||
static int cb_stateRestoreCBs(struct fs_dump_state * state, struct FileEntry * fe,
|
static int cb_stateRestoreCBs(struct fs_dump_state * state, struct FileEntry * fe,
|
||||||
@ -1814,11 +1813,15 @@ cb_stateRestore(struct fs_dump_state * state)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb_stateRestoreFEHash(state)) {
|
/*
|
||||||
ViceLog(0, ("cb_stateRestore: failed to restore FE HashTable slab\n"));
|
* Note that we do not look at fehash_offset, and we skip reading in
|
||||||
ret = 1;
|
* state->cb_fehash_hdr and all of the FE hash entries. Instead of loading
|
||||||
goto done;
|
* the FE hashtable from disk, we'll just populate our hashtable ourselves
|
||||||
}
|
* as we load in the FEs. Loading the hashtable from disk currently isn't
|
||||||
|
* any faster (since we need to fixup the indices regardless), and
|
||||||
|
* populating the hashtable ourselves is a bit simpler and makes it easier
|
||||||
|
* to alter our hashing scheme.
|
||||||
|
*/
|
||||||
|
|
||||||
/* restore FEs and CBs from disk */
|
/* restore FEs and CBs from disk */
|
||||||
if (cb_stateRestoreFEs(state)) {
|
if (cb_stateRestoreFEs(state)) {
|
||||||
@ -1846,12 +1849,6 @@ cb_stateRestoreIndices(struct fs_dump_state * state)
|
|||||||
if (state->fe_map.entries[i].new_idx) {
|
if (state->fe_map.entries[i].new_idx) {
|
||||||
fe = itofe(state->fe_map.entries[i].new_idx);
|
fe = itofe(state->fe_map.entries[i].new_idx);
|
||||||
|
|
||||||
/* restore the fe->fnext entry */
|
|
||||||
if (fe_OldToNew(state, fe->fnext, &fe->fnext)) {
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* restore the fe->firstcb entry */
|
/* restore the fe->firstcb entry */
|
||||||
if (cb_OldToNew(state, fe->firstcb, &fe->firstcb)) {
|
if (cb_OldToNew(state, fe->firstcb, &fe->firstcb)) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@ -1917,14 +1914,6 @@ cb_stateRestoreIndices(struct fs_dump_state * state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore the FE hash table queue heads */
|
|
||||||
for (i = 0; i < state->cb_fehash_hdr->records; i++) {
|
|
||||||
if (fe_OldToNew(state, HashTable[i], &HashTable[i])) {
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2281,54 +2270,6 @@ cb_stateSaveFEHash(struct fs_dump_state * state)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
cb_stateRestoreFEHash(struct fs_dump_state * state)
|
|
||||||
{
|
|
||||||
int ret = 0, len;
|
|
||||||
|
|
||||||
if (fs_stateReadHeader(state, &state->cb_hdr->fehash_offset,
|
|
||||||
state->cb_fehash_hdr,
|
|
||||||
sizeof(struct callback_state_fehash_header))) {
|
|
||||||
ViceLog(0, ("cb_stateRestoreFEHash: failed to restore cb_fehash_hdr\n"));
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state->cb_fehash_hdr->magic != CALLBACK_STATE_FEHASH_MAGIC) {
|
|
||||||
ViceLog(0, ("cb_stateRestoreFEHash: invalid cb_fehash_hdr magic 0x%x != 0x%x\n",
|
|
||||||
state->cb_fehash_hdr->magic, CALLBACK_STATE_FEHASH_MAGIC));
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (state->cb_fehash_hdr->records != FEHASH_SIZE) {
|
|
||||||
ViceLog(0, ("cb_stateRestoreFEHash: records %d != %d\n",
|
|
||||||
state->cb_fehash_hdr->records, FEHASH_SIZE));
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = state->cb_fehash_hdr->records * sizeof(afs_uint32);
|
|
||||||
|
|
||||||
if (state->cb_fehash_hdr->len !=
|
|
||||||
(sizeof(struct callback_state_fehash_header) + len)) {
|
|
||||||
ViceLog(0, ("cb_stateRestoreFEHash: header len %d != %d + %d\n",
|
|
||||||
state->cb_fehash_hdr->len,
|
|
||||||
(int)sizeof(struct callback_state_fehash_header),
|
|
||||||
len));
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fs_stateRead(state, HashTable, len)) {
|
|
||||||
ViceLog(0, ("cb_stateRestoreFEHash: failed read of HashTable\n"));
|
|
||||||
ret = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cb_stateSaveFEs(struct fs_dump_state * state)
|
cb_stateSaveFEs(struct fs_dump_state * state)
|
||||||
{
|
{
|
||||||
@ -2357,6 +2298,12 @@ cb_stateRestoreFEs(struct fs_dump_state * state)
|
|||||||
{
|
{
|
||||||
int count, nFEs, ret = 0;
|
int count, nFEs, ret = 0;
|
||||||
|
|
||||||
|
if (fs_stateSeek(state, &state->cb_hdr->fe_offset)) {
|
||||||
|
ViceLog(0, ("cb_stateRestoreFEs: error seeking to FE offset\n"));
|
||||||
|
ret = 1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
nFEs = state->cb_hdr->nFEs;
|
nFEs = state->cb_hdr->nFEs;
|
||||||
|
|
||||||
for (count = 0; count < nFEs; count++) {
|
for (count = 0; count < nFEs; count++) {
|
||||||
@ -2598,6 +2545,7 @@ cb_stateDiskEntryToFE(struct fs_dump_state * state,
|
|||||||
struct FEDiskEntry * in, struct FileEntry * out)
|
struct FEDiskEntry * in, struct FileEntry * out)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int hash;
|
||||||
|
|
||||||
memcpy(out, &in->fe, sizeof(struct FileEntry));
|
memcpy(out, &in->fe, sizeof(struct FileEntry));
|
||||||
|
|
||||||
@ -2612,6 +2560,11 @@ cb_stateDiskEntryToFE(struct fs_dump_state * state,
|
|||||||
state->fe_map.entries[in->index].old_idx = in->index;
|
state->fe_map.entries[in->index].old_idx = in->index;
|
||||||
state->fe_map.entries[in->index].new_idx = fetoi(out);
|
state->fe_map.entries[in->index].new_idx = fetoi(out);
|
||||||
|
|
||||||
|
/* Add this new FE to the HashTable. */
|
||||||
|
hash = FEHash(out->volid, out->unique);
|
||||||
|
out->fnext = HashTable[hash];
|
||||||
|
HashTable[hash] = fetoi(out);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user