* space from the buffer pool. In that case, the buffer will be returned
* without being hashed into the hash table.
*/
-long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *reqp, cm_buf_t **bufpp)
+long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *reqp,
+ afs_uint32 flags, cm_buf_t **bufpp)
{
cm_buf_t *bp; /* buffer we're dealing with */
cm_buf_t *nextBp; /* next buffer in file hash chain */
afs_uint32 i; /* temp */
afs_uint64 n_bufs, n_nonzero, n_busy, n_dirty, n_own, n_redir;
+ int bufCreateLocked = !!(flags & BUF_GET_FLAG_BUFCREATE_LOCKED);
#ifdef TESTING
buf_ValidateBufQueues();
n_dirty = 0;
n_redir = 0;
- lock_ObtainRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ObtainRead(&scp->bufCreateLock);
lock_ObtainWrite(&buf_globalLock);
/* check to see if we lost the race */
if (buf_ExistsLocked(scp, offsetp)) {
lock_ReleaseWrite(&buf_globalLock);
- lock_ReleaseRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ReleaseRead(&scp->bufCreateLock);
return CM_BUF_EXISTS;
}
if (!cm_data.buf_freeListEndp)
{
lock_ReleaseWrite(&buf_globalLock);
- lock_ReleaseRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ReleaseRead(&scp->bufCreateLock);
if ( RDR_Initialized )
goto rdr_release;
*/
buf_HoldLocked(bp);
lock_ReleaseWrite(&buf_globalLock);
- lock_ReleaseRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ReleaseRead(&scp->bufCreateLock);
/*
* grab required lock and clean.
/* but first obtain the locks we gave up
* before the buf_CleanAsync() call */
- lock_ObtainRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ObtainRead(&scp->bufCreateLock);
lock_ObtainWrite(&buf_globalLock);
/*
*/
if (buf_ExistsLocked(scp, offsetp)) {
lock_ReleaseWrite(&buf_globalLock);
- lock_ReleaseRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ReleaseRead(&scp->bufCreateLock);
return CM_BUF_EXISTS;
}
buf_IncrementUsedCount();
lock_ReleaseWrite(&buf_globalLock);
- lock_ReleaseRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ReleaseRead(&scp->bufCreateLock);
*bufpp = bp;
return 0;
} /* for all buffers in lru queue */
lock_ReleaseWrite(&buf_globalLock);
- lock_ReleaseRead(&scp->bufCreateLock);
+ if (!bufCreateLocked)
+ lock_ReleaseRead(&scp->bufCreateLock);
osi_Log2(afsd_logp, "buf_GetNewLocked: Free Buffer List has %u buffers none free; redir %u", n_bufs, n_redir);
osi_Log4(afsd_logp, "... nonzero %u; own %u; busy %u; dirty %u", n_nonzero, n_own, n_busy, n_dirty);
*
* The scp must be unlocked when passed in unlocked.
*/
-long buf_Get(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *reqp, cm_buf_t **bufpp)
+long buf_Get(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *reqp, afs_uint32 flags, cm_buf_t **bufpp)
{
cm_buf_t *bp;
long code;
}
/* otherwise, we have to create a page */
- code = buf_GetNewLocked(scp, &pageOffset, reqp, &bp);
+ code = buf_GetNewLocked(scp, &pageOffset, reqp, flags, &bp);
switch (code) {
case 0:
/* the requested buffer was created */
extern cm_buf_t *buf_FindAll(struct cm_fid *, osi_hyper_t *, afs_uint32 flags);
-extern long buf_GetNewLocked(struct cm_scache *, osi_hyper_t *, cm_req_t *, cm_buf_t **);
+extern long buf_GetNewLocked(struct cm_scache *, osi_hyper_t *, cm_req_t *, afs_uint32, cm_buf_t **);
-extern long buf_Get(struct cm_scache *, osi_hyper_t *, cm_req_t *, cm_buf_t **);
+extern long buf_Get(struct cm_scache *, osi_hyper_t *, cm_req_t *, afs_uint32, cm_buf_t **);
+
+#define BUF_GET_FLAG_BUFCREATE_LOCKED 1
extern afs_uint32 buf_CleanLocked(cm_scache_t *, cm_buf_t *, cm_req_t *, afs_uint32 flags, afs_uint32 *);
rxheld = 0;
}
- code = buf_Get(scp, &offset, reqp, &bp);
+ code = buf_Get(scp, &offset, reqp, 0, &bp);
if (code)
break;
if (LargeIntegerGreaterThanOrEqualTo(pageBase, fileSize))
break;
- code = buf_Get(scp, &pageBase, reqp, &tbp);
+ code = buf_Get(scp, &pageBase, reqp, 0, &tbp);
if (code) {
lock_ObtainWrite(&scp->rw);
cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
offset.HighPart, offset.LowPart);
lock_ReleaseWrite(&op->scp->rw);
- code = buf_Get(op->scp, &offset, &op->req, &bufferp);
+ code = buf_Get(op->scp, &offset, &op->req, 0, &bufferp);
lock_ObtainWrite(&op->scp->rw);
goto _has_buffer;
}
- code = buf_Get(op->scp, &bufferOffset, &op->req, &bufferp);
+ code = buf_Get(op->scp, &bufferOffset, &op->req, 0, &bufferp);
if (code) {
osi_Log1(afsd_logp, " buf_Get returned code 0x%x", code);
bufferp = NULL;
return code;
thyper.HighPart = 0; thyper.LowPart = 0;
- code = buf_Get(scp, &thyper, reqp, &bufferp);
+ code = buf_Get(scp, &thyper, reqp, 0, &bufferp);
if (code)
return code;
bufferp = NULL;
}
- code = buf_Get(scp, &thyper, reqp, &bufferp);
+ code = buf_Get(scp, &thyper, reqp, 0, &bufferp);
if (code) {
/* if buf_Get() fails we do not have a buffer object to lock */
bufferp = NULL;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, reqp, &bufp);
+ code = buf_Get(scp, &thyper, reqp, 0, &bufp);
lock_ObtainWrite(&scp->rw);
if (code) goto done;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, reqp, &bufp);
+ code = buf_Get(scp, &thyper, reqp, 0, &bufp);
if (bufp)
lock_ObtainMutex(&bufp->mx);
bufferp = NULL;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &req, &bufferp);
+ code = buf_Get(scp, &thyper, &req, 0, &bufferp);
lock_ObtainMutex(&dsp->mx);
/* now, if we're doing a star match, do bulk fetching of all of
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &req, &bufferp);
+ code = buf_Get(scp, &thyper, &req, 0, &bufferp);
lock_ObtainWrite(&scp->rw);
if (code) goto done;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &req, &bufferp);
+ code = buf_Get(scp, &thyper, &req, 0, &bufferp);
lock_ObtainMutex(&bufferp->mx);
lock_ObtainWrite(&scp->rw);
bufferp = NULL;
}
lock_ReleaseWrite(&scp->rw);
- code = buf_Get(scp, &thyper, &req, &bufferp);
+ code = buf_Get(scp, &thyper, &req, 0, &bufferp);
lock_ObtainWrite(&scp->rw);
if (code) {
osi_Log2(smb_logp, "T2 search dir buf_Get scp %x failed %d", scp, code);
rwheld = 0;
}
- code = buf_Get(scp, &offset, reqp, &bufp);
+ code = buf_Get(scp, &offset, reqp, 0, &bufp);
if (code) {
/*
* any error from buf_Get() is non-fatal.
QueueLength = 0;
thyper.QuadPart = ByteOffset.QuadPart;
- code = buf_Get(scp, &thyper, &req, &bufp);
+ code = buf_Get(scp, &thyper, &req, 0, &bufp);
if (code == 0) {
lock_ObtainMutex(&bufp->mx);
bBufRelease = TRUE;