From 25792e246362a201743533a970f90dbc77d0ed5c Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Mon, 20 Jun 2016 15:29:45 -0400 Subject: [PATCH] afs: more cache truncation stats Add counters for cache too full and waiting to drain occurrences. These will be used in later commits to indicate how often the cache truncation is required and how often the cache manager is waiting for cache truncation to complete. Change-Id: I4aa802729f0910dff1fb3e90b2d44d36df8bf8f3 Reviewed-on: https://gerrit.openafs.org/13168 Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- src/afs/SOLARIS/osi_vnodeops.c | 2 ++ src/afs/afs.h | 1 + src/afs/afs_dcache.c | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/src/afs/SOLARIS/osi_vnodeops.c b/src/afs/SOLARIS/osi_vnodeops.c index e2cedf08f9..81147d57ef 100644 --- a/src/afs/SOLARIS/osi_vnodeops.c +++ b/src/afs/SOLARIS/osi_vnodeops.c @@ -697,6 +697,8 @@ afs_nfsrdwr(struct vcache *avc, struct uio *auio, enum uio_rw arw, && (afs_blocksUsed > PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks))) { if (afs_blocksUsed - afs_blocksDiscarded > PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) { + if (afs_WaitForCacheDrain == 0) + afs_WaitForCacheDrainCount++; afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); } diff --git a/src/afs/afs.h b/src/afs/afs.h index 407eb89024..3492627a84 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -1360,6 +1360,7 @@ extern afs_int32 *afs_dcnextTbl; /*Dcache hash table links */ extern afs_int32 afs_cacheFiles; /*Size of afs_indexTable */ extern afs_int32 afs_cacheBlocks; /*1K blocks in cache */ extern afs_int32 afs_cacheStats; /*Stat entries in cache */ +extern afs_uint32 afs_WaitForCacheDrainCount; extern struct vcache *afs_vhashT[VCSIZE]; /*Stat cache hash table */ extern struct afs_q afs_vhashTV[VCSIZE]; /* cache hash table on volume */ extern afs_int32 afs_initState; /*Initialization state */ diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 2a03f2b3c5..41eeb84e19 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -95,6 +95,8 @@ afs_size_t afs_vmMappingEnd; /* !< For large files (>= 2GB) the VM int afs_WaitForCacheDrain = 0; int afs_TruncateDaemonRunning = 0; int afs_CacheTooFull = 0; +afs_uint32 afs_CacheTooFullCount = 0; +afs_uint32 afs_WaitForCacheDrainCount = 0; afs_int32 afs_dcentries; /*!< In-memory dcache entries */ @@ -395,6 +397,7 @@ void afs_MaybeWakeupTruncateDaemon(void) { if (!afs_CacheTooFull && afs_CacheIsTooFull()) { + afs_CacheTooFullCount++; afs_CacheTooFull = 1; if (!afs_TruncateDaemonRunning) afs_osi_Wakeup((int *)afs_CacheTruncateDaemon); @@ -2435,6 +2438,8 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, ReleaseReadLock(&avc->lock); while ((afs_blocksUsed - afs_blocksDiscarded) > PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) { + if (afs_WaitForCacheDrain == 0) + afs_WaitForCacheDrainCount++; afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); } @@ -3781,6 +3786,8 @@ afs_ObtainDCacheForWriting(struct vcache *avc, afs_size_t filePos, ReleaseWriteLock(&avc->lock); if (afs_blocksUsed - afs_blocksDiscarded > PERCENT(CM_WAITFORDRAINPCT, afs_cacheBlocks)) { + if (afs_WaitForCacheDrain == 0) + afs_WaitForCacheDrainCount++; afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); }