cm_data.buf_nOrigBuffers = cm_data.buf_nbuffers;
/* lower hash size to a prime number */
- cm_data.buf_hashSize = osi_PrimeLessThan(CM_BUF_HASHSIZE);
+ cm_data.buf_hashSize = osi_PrimeLessThan((afs_uint32)(cm_data.buf_nbuffers/7 + 1));
/* create hash table */
memset((void *)cm_data.buf_hashTablepp, 0, cm_data.buf_hashSize * sizeof(cm_buf_t *));
*/
cm_buf_t *buf_FindLocked(struct cm_scache *scp, osi_hyper_t *offsetp)
{
- long i;
+ afs_uint32 i;
cm_buf_t *bp;
i = BUF_HASH(&scp->fid, offsetp);
* have any lock conflicts, so we can grab the buffer lock out of
* order in the locking hierarchy.
*/
- osi_Log2( buf_logp, "buf_Recycle recycles 0x%p, off 0x%x",
- bp, bp->offset.LowPart);
+ osi_Log3( buf_logp, "buf_Recycle recycles 0x%p, off 0x%x:%08x",
+ bp, bp->offset.HighPart, bp->offset.LowPart);
osi_assert(bp->refCount == 0);
osi_assert(!(bp->flags & (CM_BUF_READING | CM_BUF_WRITING | CM_BUF_DIRTY)));
*/
lock_ReleaseMutex(&bp->mx);
*bufpp = bp;
- osi_Log3(buf_logp, "buf_GetNew returning bp 0x%p for scp 0x%p, offset 0x%x",
- bp, scp, offsetp->LowPart);
+ osi_Log4(buf_logp, "buf_GetNew returning bp 0x%p for scp 0x%p, offset 0x%x:%08x",
+ bp, scp, offsetp->HighPart, offsetp->LowPart);
return 0;
}
}
lock_ReleaseWrite(&buf_globalLock);
- osi_Log3(buf_logp, "buf_Get returning bp 0x%p for scp 0x%p, offset 0x%x",
- bp, scp, offsetp->LowPart);
+ osi_Log4(buf_logp, "buf_Get returning bp 0x%p for scp 0x%p, offset 0x%x:%08x",
+ bp, scp, offsetp->HighPart, offsetp->LowPart);
#ifdef TESTING
buf_ValidateBufQueues();
#endif /* TESTING */
*/
long buf_CleanAndReset(void)
{
- long i;
+ afs_uint32 i;
cm_buf_t *bp;
cm_req_t req;
int zilch;
cm_buf_t *bp;
char output[1024];
- int i;
+ afs_uint32 i;
if (cm_data.buf_hashTablepp == NULL)
return -1;
{
StringCbPrintfA(output, sizeof(output),
"%s bp=0x%08X, hash=%d, fid (cell=%d, volume=%d, "
- "vnode=%d, unique=%d), size=%d flags=0x%x, refCount=%d\r\n",
+ "vnode=%d, unique=%d), offset=%x:%08x, dv=%d, "
+ "flags=0x%x, cmFlags=0x%x, refCount=%d\r\n",
cookie, (void *)bp, i, bp->fid.cell, bp->fid.volume,
- bp->fid.vnode, bp->fid.unique, bp->size, bp->flags, bp->refCount);
+ bp->fid.vnode, bp->fid.unique, bp->offset.HighPart,
+ bp->offset.LowPart, bp->dataVersion, bp->flags,
+ bp->cmFlags, bp->refCount);
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
}
}
for(bp = cm_data.buf_freeListEndp; bp; bp=(cm_buf_t *) osi_QPrev(&bp->q)) {
StringCbPrintfA(output, sizeof(output),
"%s bp=0x%08X, fid (cell=%d, volume=%d, "
- "vnode=%d, unique=%d), size=%d flags=0x%x, refCount=%d\r\n",
+ "vnode=%d, unique=%d), offset=%x:%08x, dv=%d, "
+ "flags=0x%x, cmFlags=0x%x, refCount=%d\r\n",
cookie, (void *)bp, bp->fid.cell, bp->fid.volume,
- bp->fid.vnode, bp->fid.unique, bp->size, bp->flags, bp->refCount);
+ bp->fid.vnode, bp->fid.unique, bp->offset.HighPart,
+ bp->offset.LowPart, bp->dataVersion, bp->flags,
+ bp->cmFlags, bp->refCount);
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
}
StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_FreeListEndp.\r\n", cookie);
for(bp = cm_data.buf_dirtyListEndp; bp; bp=(cm_buf_t *) osi_QPrev(&bp->q)) {
StringCbPrintfA(output, sizeof(output),
"%s bp=0x%08X, fid (cell=%d, volume=%d, "
- "vnode=%d, unique=%d), size=%d flags=0x%x, refCount=%d\r\n",
+ "vnode=%d, unique=%d), offset=%x:%08x, dv=%d, "
+ "flags=0x%x, cmFlags=0x%x, refCount=%d\r\n",
cookie, (void *)bp, bp->fid.cell, bp->fid.volume,
- bp->fid.vnode, bp->fid.unique, bp->size, bp->flags, bp->refCount);
+ bp->fid.vnode, bp->fid.unique, bp->offset.HighPart,
+ bp->offset.LowPart, bp->dataVersion, bp->flags,
+ bp->cmFlags, bp->refCount);
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
}
StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_dirtyListEndp.\r\n", cookie);
/* backup over pointer to the buffer */
#define BUF_OVERTOBUF(op) ((cm_buf_t *)(((char *)op) - ((long)(&((cm_buf_t *)0)->over))))
-#ifdef notdef
-/* pretend we have logs, too */
-typedef char cm_log_t;
-#endif
-
#define CM_BUF_MAGIC ('B' | 'U' <<8 | 'F'<<16 | 'F'<<24)
/* represents a single buffer */
unsigned long refCount; /* reference count (buf_globalLock) */
long idCounter; /* counter for softrefs; bumped at each recycle */
long dirtyCounter; /* bumped at each dirty->clean transition */
-#ifdef notdef
- cm_log_t *logp; /* log for this buffer, if any */
- osi_hyper_t lsn; /* lsn to force to (last LSN changing this buffer) */
-#endif /* notdef */
osi_hyper_t offset; /* offset */
cm_fid_t fid; /* file ID */
#ifdef DEBUG
/* the fid at the time of fid assignment. */
#endif
long flags; /* flags we're using */
- long size; /* size in bytes of this buffer */
char *datap; /* data in this buffer */
unsigned long error; /* last error code, if CM_BUF_ERROR is set */
cm_user_t *userp; /* user who wrote to the buffer last */
extern cm_buf_t *buf_Find(struct cm_scache *, osi_hyper_t *);
-extern HANDLE buf_GetFileHandle(long);
-
extern long buf_GetNewLocked(struct cm_scache *, osi_hyper_t *, cm_buf_t **);
extern long buf_Get(struct cm_scache *, osi_hyper_t *, cm_buf_t **);
}
afs_uint64
-ComputeSizeOfDataHT(void)
+ComputeSizeOfDataHT(afs_uint64 cacheBlocks)
{
afs_uint64 size;
- size = osi_PrimeLessThan(CM_BUF_HASHSIZE) * sizeof(cm_buf_t *);
+ size = osi_PrimeLessThan((afs_uint32)(cacheBlocks/7 + 1)) * sizeof(cm_buf_t *);
return size;
}
+ ComputeSizeOfSCacheHT(stats)
+ ComputeSizeOfDNLCache()
+ ComputeSizeOfDataBuffers(cacheBlocks, blockSize)
- + 2 * ComputeSizeOfDataHT()
+ + 2 * ComputeSizeOfDataHT(cacheBlocks)
+ ComputeSizeOfDataHeaders(cacheBlocks);
return size;
}
cm_data.buf_nbuffers = cacheBlocks;
cm_data.buf_nOrigBuffers = 0;
cm_data.buf_blockSize = CM_BUF_BLOCKSIZE;
- cm_data.buf_hashSize = CM_BUF_HASHSIZE;
+ cm_data.buf_hashSize = osi_PrimeLessThan((afs_uint32)(cacheBlocks/7 + 1));
cm_data.mountRootGen = time(NULL);
cm_data.dnlcBaseAddress = (cm_nc_t *) baseAddress;
baseAddress += ComputeSizeOfDNLCache();
cm_data.buf_hashTablepp = (cm_buf_t **) baseAddress;
- baseAddress += ComputeSizeOfDataHT();
+ baseAddress += ComputeSizeOfDataHT(cacheBlocks);
cm_data.buf_fileHashTablepp = (cm_buf_t **) baseAddress;
- baseAddress += ComputeSizeOfDataHT();
+ baseAddress += ComputeSizeOfDataHT(cacheBlocks);
cm_data.bufHeaderBaseAddress = (cm_buf_t *) baseAddress;
baseAddress += ComputeSizeOfDataHeaders(cacheBlocks);
cm_data.bufDataBaseAddress = (char *) baseAddress;