From: Andrew Deason Date: Fri, 6 May 2011 18:12:17 +0000 (-0500) Subject: dasalvager: unlink fsstate.dat when standalone X-Git-Tag: openafs-devel-1_7_1~498 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=38efda16a2c5c9e74b5a23b5bdd2818a3353eec2 dasalvager: unlink fsstate.dat when standalone If the DAFS salvager is running in a standalone mode, unlink the fileserver's fsstate.dat file if any volumes change. Otherwise, volume data could have changed and the fileserver will retain callback promises for the data in those volumes until it tries to attach the volume. This way, callbacks are broken via callback state reinitialization. A better solution is to record which volumes have changed, and the fileserver can break callbacks for them on startup. But this at least eliminates a regression from non-DAFS behavior. Change-Id: Ie443e7d43705c3015d21bd3cad1b1e05c88562be Reviewed-on: http://gerrit.openafs.org/4638 Tested-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 24f59f2..d92bd5b 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -4133,22 +4133,41 @@ SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp, IHandle_t * afs_printable_uint32_lu(vid)); } + if (!Testing && salvinfo->VolumeChanged) { #ifdef FSSYNC_BUILD_CLIENT - if (!Testing && salvinfo->VolumeChanged && salvinfo->useFSYNC) { - afs_int32 fsync_code; - - fsync_code = FSYNC_VolOp(vid, NULL, FSYNC_VOL_BREAKCBKS, FSYNC_SALVAGE, NULL); - if (fsync_code) { - Log("Error trying to tell the fileserver to break callbacks for " - "changed volume %lu; error code %ld\n", - afs_printable_uint32_lu(vid), - afs_printable_int32_ld(fsync_code)); - } else { - salvinfo->VolumeChanged = 0; + if (salvinfo->useFSYNC) { + afs_int32 fsync_code; + + fsync_code = FSYNC_VolOp(vid, NULL, FSYNC_VOL_BREAKCBKS, FSYNC_SALVAGE, NULL); + if (fsync_code) { + Log("Error trying to tell the fileserver to break callbacks for " + "changed volume %lu; error code %ld\n", + afs_printable_uint32_lu(vid), + afs_printable_int32_ld(fsync_code)); + } else { + salvinfo->VolumeChanged = 0; + } } - } #endif /* FSSYNC_BUILD_CLIENT */ +#if defined(AFS_DEMAND_ATTACH_FS) || defined(AFS_DEMAND_ATTACH_UTIL) + if (!salvinfo->useFSYNC) { + /* A volume's contents have changed, but the fileserver will not + * break callbacks on the volume until it tries to load the vol + * header. So, to reduce the amount of time a client could have + * stale data, remove fsstate.dat, so the fileserver will init + * callback state with all clients. This is a very coarse hammer, + * and in the future we should just record which volumes have + * changed. */ + code = unlink(AFSDIR_SERVER_FSSTATE_FILEPATH); + if (code && errno != ENOENT) { + Log("Error %d when trying to unlink FS state file %s\n", errno, + AFSDIR_SERVER_FSSTATE_FILEPATH); + } + } +#endif + } + /* Turn off the inUse bit; the volume's been salvaged! */ volHeader.inUse = 0; /* clear flag indicating inUse@last crash */ volHeader.needsSalvaged = 0; /* clear 'damaged' flag */