From: Andrew Deason Date: Fri, 6 May 2011 18:12:17 +0000 (-0500) Subject: dasalvager: unlink fsstate.dat when standalone X-Git-Tag: upstream/1.6.0.pre6^2~25 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=699c407bfbf0fad2667b231a1e73cdf1a0aec7b0;p=packages%2Fo%2Fopenafs.git 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. Reviewed-on: http://gerrit.openafs.org/4638 Tested-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 38efda16a2c5c9e74b5a23b5bdd2818a3353eec2) Change-Id: Ic931ce8118e8d76d799ce7e731451a6a4bf3c241 Reviewed-on: http://gerrit.openafs.org/4662 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index e9cfede73..0e31f4383 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -4130,22 +4130,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 */