vol: rate-limit volume usage updates

Add threshold and time rate-limit parameters for volume usage
updates to disk.  This reduces the amount of i/o needed for
volume usage statistics on very busy fileservers.  Set the
default to limit updates to one every 5 seconds per volume.

Reviewed-on: http://gerrit.openafs.org/5803
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 639ca379e47fbe550d090fff9e635ad24e8e34f0)

Change-Id: I29b8240515afe5585b3eef000dbf40110fd4620f
Reviewed-on: http://gerrit.openafs.org/8582
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Reviewed-by: Paul Smeddle <paul.smeddle@gmail.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Michael Meffie 2011-11-03 17:09:28 -04:00 committed by Stephan Wiesand
parent f13eaa0172
commit e1baf1af4c
2 changed files with 15 additions and 2 deletions

View File

@ -512,6 +512,8 @@ VOptDefaults(ProgramType pt, VolumePackageOptions *opts)
opts->canUseSALVSYNC = 0; opts->canUseSALVSYNC = 0;
opts->interrupt_rxcall = NULL; opts->interrupt_rxcall = NULL;
opts->usage_threshold = 128;
opts->usage_rate_limit = 5;
#ifdef FAST_RESTART #ifdef FAST_RESTART
opts->unsafe_attach = 1; opts->unsafe_attach = 1;
@ -6533,10 +6535,16 @@ VBumpVolumeUsage_r(Volume * vp)
if (now - V_dayUseDate(vp) > OneDay) if (now - V_dayUseDate(vp) > OneDay)
VAdjustVolumeStatistics_r(vp); VAdjustVolumeStatistics_r(vp);
/* /*
* Save the volume header image to disk after every 128 bumps to dayUse. * Save the volume header image to disk after a threshold of bumps to dayUse,
* at most every usage_rate_limit seconds.
*/ */
if ((V_dayUse(vp)++ & 127) == 0) { V_dayUse(vp)++;
vp->usage_bumps_outstanding++;
if (vp->usage_bumps_outstanding >= vol_opts.usage_threshold
&& vp->usage_bumps_next_write <= now) {
Error error; Error error;
vp->usage_bumps_outstanding = 0;
vp->usage_bumps_next_write = now + vol_opts.usage_rate_limit;
VUpdateVolume_r(&error, vp, VOL_UPDATE_WAIT); VUpdateVolume_r(&error, vp, VOL_UPDATE_WAIT);
} }
} }

View File

@ -255,6 +255,9 @@ typedef struct VolumePackageOptions {
void (*interrupt_rxcall) (struct rx_call *call, afs_int32 error); void (*interrupt_rxcall) (struct rx_call *call, afs_int32 error);
/**< callback to interrupt RX calls accessing /**< callback to interrupt RX calls accessing
* a going-offline volume */ * a going-offline volume */
afs_int32 usage_threshold; /*< number of accesses before writing volume header */
afs_int32 usage_rate_limit; /*< minimum number of seconds before writing volume
* header, after usage_threshold is exceeded */
} VolumePackageOptions; } VolumePackageOptions;
/* Magic numbers and version stamps for each type of file */ /* Magic numbers and version stamps for each type of file */
@ -701,6 +704,8 @@ typedef struct Volume {
VolumeVLRUState vlru; /* state specific to the VLRU */ VolumeVLRUState vlru; /* state specific to the VLRU */
FSSYNC_VolOp_info * pending_vol_op; /* fssync command info for any pending vol ops */ FSSYNC_VolOp_info * pending_vol_op; /* fssync command info for any pending vol ops */
#endif /* AFS_DEMAND_ATTACH_FS */ #endif /* AFS_DEMAND_ATTACH_FS */
int usage_bumps_outstanding; /**< to rate limit the usage update i/o by accesses */
int usage_bumps_next_write; /**< to rate limit the usage update i/o by time */
} Volume; } Volume;
struct volHeader { struct volHeader {