From: Jeffrey Altman Date: Sun, 9 Dec 2012 06:18:03 +0000 (-0500) Subject: Windows: buf_usedCount can be 64-bit X-Git-Tag: openafs-stable-1_8_0pre1~1724 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=b454f2ef0ea4efae0d703947ba67d4fd00545685 Windows: buf_usedCount can be 64-bit If buf_usedCount is 64-bit, must use 64-bit Interlocked operations. Define buf_IncrementUsedCount() and buf_DecrementUsedCount() macros to wrap the 32-bit and 64-bit Interlocked operations as appropriate. Change-Id: Icbcb4d20530cc33b43e3c58c3ce74251b12c1e93 Reviewed-on: http://gerrit.openafs.org/8729 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 2b9cfcf..cc7072b 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -537,7 +537,7 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers) bp->redirLastAccess = 0; bp->redirReleaseRequested = 0; buf_ReleaseLocked(bp, TRUE); - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); } bp++; } @@ -560,7 +560,7 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers) bp->redirLastAccess = 0; bp->redirReleaseRequested = 0; buf_ReleaseLocked(bp, TRUE); - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); } lock_ReleaseWrite(&buf_globalLock); } @@ -835,7 +835,7 @@ afs_uint32 buf_CleanLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, bp->error = code; bp->dataVersion = CM_BUF_VERSION_BAD; bp->dirtyCounter++; - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); } while ((bp->flags & CM_BUF_DIRTY) == CM_BUF_DIRTY) { @@ -882,7 +882,7 @@ afs_uint32 buf_CleanLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, bp->error = code; bp->dataVersion = CM_BUF_VERSION_BAD; bp->dirtyCounter++; - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); break; } @@ -1485,7 +1485,7 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *req } if ( cm_data.buf_usedCount < cm_data.buf_nbuffers) - InterlockedIncrement(&cm_data.buf_usedCount); + buf_IncrementUsedCount(); lock_ReleaseWrite(&buf_globalLock); lock_ReleaseRead(&scp->bufCreateLock); @@ -1999,7 +1999,7 @@ long buf_Truncate(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp, bufp->dirty_length = 0; bufp->dataVersion = CM_BUF_VERSION_BAD; /* known bad */ bufp->dirtyCounter++; - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); } else { /* don't set dirty, since dirty implies @@ -2098,7 +2098,7 @@ long buf_FlushCleanPages(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp) bp->dataVersion = CM_BUF_VERSION_BAD; /* known bad */ bp->dirtyCounter++; lock_ReleaseMutex(&bp->mx); - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); } else if (!(scp->flags & CM_SCACHEFLAG_RO)) { if (code) { goto skip; @@ -2126,7 +2126,7 @@ long buf_FlushCleanPages(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp) buf_ReleaseLocked(bp, TRUE); didRelease = 1; if (bp->dataVersion != CM_BUF_VERSION_BAD) - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); buf_Recycle(bp); } } @@ -2172,7 +2172,7 @@ long buf_InvalidateBuffers(cm_scache_t * scp) for (bp = cm_data.buf_fileHashTablepp[i]; bp; bp = bp->fileHashp) { if (cm_FidCmp(&bp->fid, &scp->fid) == 0) { bp->dataVersion = CM_BUF_VERSION_BAD; - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); found = 1; } } @@ -2283,7 +2283,7 @@ long buf_CleanVnode(struct cm_scache *scp, cm_user_t *userp, cm_req_t *reqp) bp->error = code; bp->dataVersion = CM_BUF_VERSION_BAD; bp->dirtyCounter++; - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); break; case CM_ERROR_TIMEDOUT: case CM_ERROR_ALLDOWN: @@ -2567,7 +2567,7 @@ long buf_CleanDirtyBuffers(cm_scache_t *scp) } lock_ReleaseMutex(&bp->mx); buf_Release(bp); - InterlockedDecrement(&cm_data.buf_usedCount); + buf_DecrementUsedCount(); } } return 0; diff --git a/src/WINNT/afsd/cm_buf.h b/src/WINNT/afsd/cm_buf.h index 0184d6e..09801b5 100644 --- a/src/WINNT/afsd/cm_buf.h +++ b/src/WINNT/afsd/cm_buf.h @@ -257,11 +257,15 @@ buf_MoveToHeadOfRedirQueue(cm_scache_t *scp, cm_buf_t *bufp); #define buf_DecrementRedirCount() InterlockedDecrement(&cm_data.buf_redirCount) #define buf_IncrementFreeCount() InterlockedIncrement(&cm_data.buf_freeCount) #define buf_DecrementFreeCount() InterlockedDecrement(&cm_data.buf_freeCount) +#define buf_IncrementUsedCount() InterlockedIncrement(&cm_data.buf_usedCount) +#define buf_DecrementUsedCount() InterlockedDecrement(&cm_data.buf_usedCount) #else #define buf_IncrementRedirCount() InterlockedIncrement64(&cm_data.buf_redirCount) #define buf_DecrementRedirCount() InterlockedDecrement64(&cm_data.buf_redirCount) #define buf_IncrementFreeCount() InterlockedIncrement64(&cm_data.buf_freeCount) #define buf_DecrementFreeCount() InterlockedDecrement64(&cm_data.buf_freeCount) +#define buf_IncrementUsedCount() InterlockedIncrement64(&cm_data.buf_usedCount) +#define buf_DecrementUsedCount() InterlockedDecrement64(&cm_data.buf_usedCount) #endif /* error codes */