bp = cm_data.bufHeaderBaseAddress;
data = cm_data.bufDataBaseAddress;
+ lock_ObtainWrite(&buf_globalLock);
for (i=0; i<cm_data.buf_nbuffers; i++) {
lock_InitializeMutex(&bp->mx, "Buffer mutex", LOCK_HIERARCHY_BUFFER);
bp->userp = NULL;
* extent was not returned by the file system driver.
* clean up the mess.
*/
+ buf_RemoveFromRedirQueue(NULL, bp);
bp->dataVersion = CM_BUF_VERSION_BAD;
- _InterlockedAnd(&bp->qFlags, ~CM_BUF_QREDIR);
- osi_QRemoveHT( (osi_queue_t **) &cm_data.buf_redirListp,
- (osi_queue_t **) &cm_data.buf_redirListEndp,
- &bp->q);
- buf_DecrementRedirCount();
bp->redirq.nextp = bp->redirq.prevp = NULL;
bp->redirLastAccess = 0;
bp->redirReleaseRequested = 0;
- buf_Release(bp);
+ buf_ReleaseLocked(bp, TRUE);
}
bp++;
}
* extent was not returned by the file system driver.
* clean up the mess.
*/
+ buf_RemoveFromRedirQueue(NULL, bp);
bp->dataVersion = CM_BUF_VERSION_BAD;
- _InterlockedAnd(&bp->qFlags, ~CM_BUF_QREDIR);
- osi_QRemoveHT( (osi_queue_t **) &cm_data.buf_redirListp,
- (osi_queue_t **) &cm_data.buf_redirListEndp,
- &bp->q);
- buf_DecrementRedirCount();
bp->redirq.nextp = bp->redirq.prevp = NULL;
bp->redirLastAccess = 0;
bp->redirReleaseRequested = 0;
- buf_Release(bp);
+ buf_ReleaseLocked(bp, TRUE);
}
+ lock_ReleaseWrite(&buf_globalLock);
}
#ifdef TESTING
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;
+ afs_uint64 n_bufs, n_nonzero, n_busy, n_dirty, n_own, n_redir;
#ifdef TESTING
buf_ValidateBufQueues();
n_own = 0;
n_busy = 0;
n_dirty = 0;
+ n_redir = 0;
lock_ObtainRead(&scp->bufCreateLock);
lock_ObtainWrite(&buf_globalLock);
continue;
}
+ /* leave the buffer alone if held by the redirector */
+ if (bp->qFlags & CM_BUF_QREDIR) {
+ n_redir++;
+ continue;
+ }
+
if (bp->flags & CM_BUF_DIRTY) {
n_dirty++;
- /* leave the buffer alone if held by the redirector */
- if (bp->qFlags & CM_BUF_QREDIR)
- continue;
-
/* protect against cleaning the same buffer more than once. */
if (cleaned)
continue;
lock_ReleaseWrite(&buf_globalLock);
lock_ReleaseRead(&scp->bufCreateLock);
- osi_Log1(afsd_logp, "buf_GetNewLocked: Free Buffer List has %u buffers none free", n_bufs);
+ 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);
if (RDR_Initialized) {
{
lock_AssertWrite(&buf_globalLock);
- lock_ObtainMutex(&scp->redirMx);
+ if (scp) {
+ lock_ObtainMutex(&scp->redirMx);
+ }
if (bufp->qFlags & CM_BUF_QINLRU) {
_InterlockedAnd(&bufp->qFlags, ~CM_BUF_QINLRU);
&bufp->redirq);
scp->redirLastAccess = bufp->redirLastAccess;
InterlockedIncrement(&scp->redirBufCount);
- }
- lock_ReleaseMutex(&scp->redirMx);
+ lock_ReleaseMutex(&scp->redirMx);
+ }
}
void
if (!(bufp->qFlags & CM_BUF_QREDIR))
return;
- lock_ObtainMutex(&scp->redirMx);
+ if (scp) {
+ lock_ObtainMutex(&scp->redirMx);
+ }
_InterlockedAnd(&bufp->qFlags, ~CM_BUF_QREDIR);
osi_QRemoveHT( (osi_queue_t **) &cm_data.buf_redirListp,
(osi_queue_t **) &cm_data.buf_redirListEndp,
&bufp->q);
buf_DecrementRedirCount();
+
if (scp) {
osi_QRemoveHT( (osi_queue_t **) &scp->redirQueueH,
(osi_queue_t **) &scp->redirQueueT,
&bufp->redirq);
+
InterlockedDecrement(&scp->redirBufCount);
+ lock_ReleaseMutex(&scp->redirMx);
}
-
- lock_ReleaseMutex(&scp->redirMx);
}
void
if (!(bufp->qFlags & CM_BUF_QREDIR))
return;
- lock_ObtainMutex(&scp->redirMx);
+ if (scp) {
+ lock_ObtainMutex(&scp->redirMx);
+ }
osi_QRemoveHT( (osi_queue_t **) &cm_data.buf_redirListp,
(osi_queue_t **) &cm_data.buf_redirListEndp,
(osi_queue_t **) &scp->redirQueueT,
&bufp->redirq);
scp->redirLastAccess = bufp->redirLastAccess;
- }
- lock_ReleaseMutex(&scp->redirMx);
+ lock_ReleaseMutex(&scp->redirMx);
+ }
}