mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
viced: Rationalise FS_STATS_DETAILED logging
Every RPC handler in the fileserver contained a copy of an identical code block to handle starting, stopping, and recording detailed logging statistics. Replace all of this with a structure and 4 helper functions, which will make maintenance much easier. Change-Id: Ie2b0fa13fcc3e261ba435f1560e7ab5adf477afb Reviewed-on: http://gerrit.openafs.org/4765 Reviewed-by: Jeffrey Altman <jaltman@openafs.org> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
69a3ffa323
commit
5fbea6da21
@ -26,7 +26,8 @@ DIR=$(srcdir)/../dir
|
||||
VOL=$(srcdir)/../vol
|
||||
FSINT=$(srcdir)/../fsint
|
||||
|
||||
VICEDOBJS=viced.o afsfileprocs.o host.o physio.o callback.o serialize_state.o
|
||||
VICEDOBJS=viced.o afsfileprocs.o host.o physio.o callback.o serialize_state.o \
|
||||
fsstats.o
|
||||
|
||||
VLSERVEROBJS=vldbint.cs.o vldbint.xdr.o
|
||||
|
||||
@ -74,6 +75,9 @@ physio.o: ${VICED}/physio.c
|
||||
callback.o: ${VICED}/callback.c
|
||||
$(AFS_CCRULE) $(VICED)/callback.c
|
||||
|
||||
fsstats.o: ${VICED}/fsstats.c
|
||||
$(AFS_CCRULE) $(VICED)/fsstats.c
|
||||
|
||||
serialize_state.o: ${TVICED}/serialize_state.c
|
||||
$(AFS_CCRULE) $(TVICED)/serialize_state.c
|
||||
|
||||
|
@ -26,7 +26,7 @@ RX = ..\rx
|
||||
RXOBJS = $(OUT)\xdr_int64.obj \
|
||||
$(OUT)\xdr_int32.obj
|
||||
|
||||
VICEDOBJS = $(OUT)\viced.obj $(OUT)\afsfileprocs.obj $(OUT)\host.obj $(OUT)\physio.obj $(OUT)\callback.obj
|
||||
VICEDOBJS = $(OUT)\viced.obj $(OUT)\afsfileprocs.obj $(OUT)\fsstats.obj $(OUT)\host.obj $(OUT)\physio.obj $(OUT)\callback.obj
|
||||
|
||||
TVICEDOBJS = $(OUT)\serialize_state.obj
|
||||
|
||||
|
@ -24,7 +24,8 @@ DIR=$(srcdir)/../dir
|
||||
VOL=$(srcdir)/../vol
|
||||
FSINT=$(srcdir)/../fsint
|
||||
|
||||
VICEDOBJS=viced.o afsfileprocs.o host.o physio.o callback.o serialize_state.o
|
||||
VICEDOBJS=viced.o afsfileprocs.o host.o physio.o callback.o serialize_state.o \
|
||||
fsstats.o
|
||||
|
||||
VLSERVEROBJS=vldbint.cs.o vldbint.xdr.o
|
||||
|
||||
@ -72,6 +73,8 @@ physio.o: ${VICED}/physio.c
|
||||
callback.o: ${VICED}/callback.c
|
||||
$(AFS_CCRULE) $(VICED)/callback.c
|
||||
|
||||
fsstats.o: ${VICED}/fsstats.c
|
||||
$(AFS_CCRULE) $(VICED)/fsstats.c
|
||||
|
||||
assert.o: ${UTIL}/assert.c
|
||||
$(AFS_CCRULE) $(UTIL)/assert.c
|
||||
|
@ -28,7 +28,7 @@ RX = ..\rx
|
||||
RXOBJS = $(OUT)\xdr_int64.obj \
|
||||
$(OUT)\xdr_int32.obj
|
||||
|
||||
VICEDOBJS = $(OUT)\viced.obj $(OUT)\afsfileprocs.obj $(OUT)\host.obj $(OUT)\physio.obj $(OUT)\callback.obj
|
||||
VICEDOBJS = $(OUT)\viced.obj $(OUT)\afsfileprocs.obj $(OUT)\fsstats.obj $(OUT)\host.obj $(OUT)\physio.obj $(OUT)\callback.obj
|
||||
|
||||
TVICEDRES = $(OUT)\fileserver.res
|
||||
|
||||
|
@ -51,7 +51,8 @@ objects=viced.o \
|
||||
afsfileprocs.o \
|
||||
host.o \
|
||||
physio.o \
|
||||
callback.o
|
||||
callback.o \
|
||||
fsstats.o
|
||||
|
||||
all: cbd fsprobe check_sysid fileserver ${TOP_INCDIR}/afs/fs_stats.h
|
||||
|
||||
|
@ -32,6 +32,7 @@ EXERES = $(OUT)\fileserver.res
|
||||
EXEOBJS =\
|
||||
$(OUT)\afsfileprocs.obj \
|
||||
$(OUT)\callback.obj \
|
||||
$(OUT)\fsstats.obj \
|
||||
$(OUT)\host.obj \
|
||||
$(OUT)\physio.obj \
|
||||
$(OUT)\viced.obj \
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -338,4 +338,19 @@ extern char FS_HostName[];
|
||||
extern afs_uint32 FS_HostAddr_NBO;
|
||||
extern afs_uint32 FS_HostAddr_HBO;
|
||||
|
||||
/* Logging helper functions */
|
||||
struct fsstats {
|
||||
int index;
|
||||
struct fs_stats_opTimingData *opP;
|
||||
struct fs_stats_xferData *xferP;
|
||||
struct timeval opStartTime;
|
||||
struct timeval xferStartTime;
|
||||
};
|
||||
|
||||
extern void fsstats_StartOp(struct fsstats *stats, int index);
|
||||
extern void fsstats_FinishOp(struct fsstats *stats, int code);
|
||||
extern void fsstats_StartXfer(struct fsstats *stats);
|
||||
extern void fsstats_FinishXfer(struct fsstats *, int, afs_sfsize_t,
|
||||
afs_sfsize_t, int *);
|
||||
|
||||
#endif /* __fs_stats_h */
|
||||
|
164
src/viced/fsstats.c
Normal file
164
src/viced/fsstats.c
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/* An abstracted interface for recording fs statistics data */
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
#include <roken.h>
|
||||
|
||||
#include <afs/afsint.h>
|
||||
#include <afs/ihandle.h>
|
||||
#include <afs/nfs.h>
|
||||
#include "viced.h"
|
||||
#include "fs_stats.h"
|
||||
|
||||
#if FS_STATS_DETAILED
|
||||
|
||||
void
|
||||
fsstats_StartOp(struct fsstats *stats, int index)
|
||||
{
|
||||
stats->index = index;
|
||||
stats->opP = &(afs_FullPerfStats.det.rpcOpTimes[index]);
|
||||
FS_LOCK;
|
||||
(stats->opP->numOps)++;
|
||||
FS_UNLOCK;
|
||||
FT_GetTimeOfDay(&stats->opStartTime, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
fsstats_FinishOp(struct fsstats *stats, int code)
|
||||
{
|
||||
struct timeval opStopTime, elapsedTime;
|
||||
|
||||
FT_GetTimeOfDay(&opStopTime, NULL);
|
||||
if (code == 0) {
|
||||
FS_LOCK;
|
||||
(stats->opP->numSuccesses)++;
|
||||
fs_stats_GetDiff(elapsedTime, stats->opStartTime, opStopTime);
|
||||
fs_stats_AddTo((stats->opP->sumTime), elapsedTime);
|
||||
fs_stats_SquareAddTo((stats->opP->sqrTime), elapsedTime);
|
||||
if (fs_stats_TimeLessThan(elapsedTime, (stats->opP->minTime))) {
|
||||
fs_stats_TimeAssign((stats->opP->minTime), elapsedTime);
|
||||
}
|
||||
if (fs_stats_TimeGreaterThan(elapsedTime, (stats->opP->maxTime))) {
|
||||
fs_stats_TimeAssign((stats->opP->maxTime), elapsedTime);
|
||||
}
|
||||
FS_UNLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fsstats_StartXfer(struct fsstats *stats)
|
||||
{
|
||||
FT_GetTimeOfDay(&stats->xferStartTime, NULL);
|
||||
stats->xferP = &(afs_FullPerfStats.det.xferOpTimes[stats->index]);
|
||||
}
|
||||
|
||||
void
|
||||
fsstats_FinishXfer(struct fsstats *stats, int code,
|
||||
afs_sfsize_t bytesToXfer, afs_sfsize_t bytesXferred,
|
||||
int *remainder)
|
||||
{
|
||||
struct timeval xferStopTime;
|
||||
struct timeval elapsedTime;
|
||||
|
||||
/*
|
||||
* At this point, the data transfer is done, for good or ill. Remember
|
||||
* when the transfer ended, bump the number of successes/failures, and
|
||||
* integrate the transfer size and elapsed time into the stats. If the
|
||||
* operation failed, we jump to the appropriate point.
|
||||
*/
|
||||
FT_GetTimeOfDay(&xferStopTime, 0);
|
||||
FS_LOCK;
|
||||
(stats->xferP->numXfers)++;
|
||||
if (code == 0) {
|
||||
(stats->xferP->numSuccesses)++;
|
||||
|
||||
/*
|
||||
* Bump the xfer sum by the number of bytes actually sent, NOT the
|
||||
* target number.
|
||||
*/
|
||||
*remainder += bytesXferred;
|
||||
(stats->xferP->sumBytes) += (*remainder >> 10);
|
||||
*remainder &= 0x3FF;
|
||||
if (bytesXferred < stats->xferP->minBytes)
|
||||
stats->xferP->minBytes = bytesXferred;
|
||||
if (bytesXferred > stats->xferP->maxBytes)
|
||||
stats->xferP->maxBytes = bytesXferred;
|
||||
|
||||
/*
|
||||
* Tally the size of the object. Note: we tally the actual size,
|
||||
* NOT the number of bytes that made it out over the wire.
|
||||
*/
|
||||
if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET0)
|
||||
(stats->xferP->count[0])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET1)
|
||||
(stats->xferP->count[1])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET2)
|
||||
(stats->xferP->count[2])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET3)
|
||||
(stats->xferP->count[3])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET4)
|
||||
(stats->xferP->count[4])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET5)
|
||||
(stats->xferP->count[5])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET6)
|
||||
(stats->xferP->count[6])++;
|
||||
else if (bytesToXfer <= FS_STATS_MAXBYTES_BUCKET7)
|
||||
(stats->xferP->count[7])++;
|
||||
else
|
||||
(stats->xferP->count[8])++;
|
||||
|
||||
fs_stats_GetDiff(elapsedTime, stats->xferStartTime, xferStopTime);
|
||||
fs_stats_AddTo((stats->xferP->sumTime), elapsedTime);
|
||||
fs_stats_SquareAddTo((stats->xferP->sqrTime), elapsedTime);
|
||||
if (fs_stats_TimeLessThan(elapsedTime, (stats->xferP->minTime))) {
|
||||
fs_stats_TimeAssign((stats->xferP->minTime), elapsedTime);
|
||||
}
|
||||
if (fs_stats_TimeGreaterThan(elapsedTime, (stats->xferP->maxTime))) {
|
||||
fs_stats_TimeAssign((stats->xferP->maxTime), elapsedTime);
|
||||
}
|
||||
}
|
||||
FS_UNLOCK;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
fsstats_StartOp(struct fsstats *stats, int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
fsstats_FinishOp(struct fsstats *stats, int code)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
fsstats_StartXfer(struct fsstats *stats)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
fsstats_FinishXfer(struct fsstats *stats, int code,
|
||||
afs_sfsize_t bytesToXfer, afs_sfsize_t bytesXferred,
|
||||
int *remainder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user