/* watch for transition from empty to one element */
if (!cm_data.buf_freeListEndp)
cm_data.buf_freeListEndp = cm_data.buf_freeListp;
- bp->qFlags |= CM_BUF_QINLRU;
+ _InterlockedOr(&bp->qFlags, CM_BUF_QINLRU);
}
if (!writeLocked)
/* watch for transition from empty to one element */
if (!cm_data.buf_freeListEndp)
cm_data.buf_freeListEndp = cm_data.buf_freeListp;
- bp->qFlags |= CM_BUF_QINLRU;
+ _InterlockedOr(&bp->qFlags, CM_BUF_QINLRU);
}
lock_ReleaseWrite(&buf_globalLock);
}
#endif
*bpp = bp->dirtyp;
bp->dirtyp = NULL;
- bp->qFlags &= ~CM_BUF_QINDL;
+ _InterlockedAnd(&bp->qFlags, ~CM_BUF_QINDL);
if (cm_data.buf_dirtyListp == NULL)
cm_data.buf_dirtyListEndp = NULL;
else if (cm_data.buf_dirtyListEndp == bp)
cm_data.buf_allp = bp;
osi_QAdd((osi_queue_t **)&cm_data.buf_freeListp, &bp->q);
- bp->qFlags |= CM_BUF_QINLRU;
+ _InterlockedOr(&bp->qFlags, CM_BUF_QINLRU);
lock_InitializeMutex(&bp->mx, "Buffer mutex", LOCK_HIERARCHY_BUFFER);
/* grab appropriate number of bytes from aligned zone */
bp->userp = NULL;
bp->waitCount = 0;
bp->waitRequests = 0;
- bp->flags &= ~CM_BUF_WAITING;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_WAITING);
bp++;
}
}
osi_Log1(buf_logp, "buf_WaitIO CM_BUF_WAITING already set for 0x%p", bp);
} else {
osi_Log1(buf_logp, "buf_WaitIO CM_BUF_WAITING set for 0x%p", bp);
- bp->flags |= CM_BUF_WAITING;
+ _InterlockedOr(&bp->flags, CM_BUF_WAITING);
bp->waitCount = bp->waitRequests = 1;
}
osi_SleepM((LONG_PTR)bp, &bp->mx);
bp->waitCount--;
if (bp->waitCount == 0) {
osi_Log1(buf_logp, "buf_WaitIO CM_BUF_WAITING reset for 0x%p", bp);
- bp->flags &= ~CM_BUF_WAITING;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_WAITING);
bp->waitRequests = 0;
}
if (code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BADFD || code == CM_ERROR_NOACCESS ||
code == CM_ERROR_QUOTA || code == CM_ERROR_SPACE || code == CM_ERROR_TOOBIG ||
code == CM_ERROR_READONLY || code == CM_ERROR_NOSUCHPATH){
- bp->flags &= ~CM_BUF_DIRTY;
- bp->flags |= CM_BUF_ERROR;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY);
+ _InterlockedOr(&bp->flags, CM_BUF_ERROR);
bp->dirty_offset = 0;
bp->dirty_length = 0;
bp->error = code;
if (nextBp)
nextBp->fileHashBackp = prevBp;
- bp->qFlags &= ~CM_BUF_QINHASH;
+ _InterlockedAnd(&bp->qFlags, ~CM_BUF_QINHASH);
}
/* make the fid unrecognizable */
memset(&bp->fid, 0, sizeof(cm_fid_t));
/* clean up junk flags */
- bp->flags &= ~(CM_BUF_EOF | CM_BUF_ERROR);
+ _InterlockedAnd(&bp->flags, ~(CM_BUF_EOF | CM_BUF_ERROR));
bp->dataVersion = CM_BUF_VERSION_BAD; /* unknown so far */
}
if (scp) {
lock_AssertWrite(&buf_globalLock);
- bp->qFlags |= CM_BUF_QINHASH;
+ _InterlockedOr(&bp->qFlags, CM_BUF_QINHASH);
bp->fid = scp->fid;
#ifdef DEBUG
bp->scp = scp;
cm_data.buf_freeListEndp = (cm_buf_t *) osi_QPrev(&bp->q);
}
osi_QRemove((osi_queue_t **) &cm_data.buf_freeListp, &bp->q);
- bp->qFlags &= ~CM_BUF_QINLRU;
+ _InterlockedAnd(&bp->qFlags, ~CM_BUF_QINLRU);
/* prepare to return it. Give it a refcount */
bp->refCount = 1;
* implementation of Readp is cm_BufRead() which simply sets
* tcount to 0 and returns success.
*/
- bp->flags |= CM_BUF_READING;
+ _InterlockedOr(&bp->flags, CM_BUF_READING);
code = (*cm_buf_opsp->Readp)(bp, cm_data.buf_blockSize, &tcount, NULL);
#ifdef DISKCACHE95
/* failure or queued */
if (code != ERROR_IO_PENDING) {
bp->error = code;
- bp->flags |= CM_BUF_ERROR;
- bp->flags &= ~CM_BUF_READING;
+ _InterlockedOr(&bp->flags, CM_BUF_ERROR);
+ _InterlockedAnd(&bp->flags, ~CM_BUF_READING);
if (bp->flags & CM_BUF_WAITING) {
osi_Log1(buf_logp, "buf_Get Waking bp 0x%p", bp);
osi_Wakeup((LONG_PTR) bp);
if (tcount < (unsigned long) cm_data.buf_blockSize) {
memset(bp->datap+tcount, 0, cm_data.buf_blockSize - tcount);
if (tcount == 0)
- bp->flags |= CM_BUF_EOF;
+ _InterlockedOr(&bp->flags, CM_BUF_EOF);
}
- bp->flags &= ~CM_BUF_READING;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_READING);
if (bp->flags & CM_BUF_WAITING) {
osi_Log1(buf_logp, "buf_Get Waking bp 0x%p", bp);
osi_Wakeup((LONG_PTR) bp);
if (cm_data.buf_freeListEndp == bp)
cm_data.buf_freeListEndp = (cm_buf_t *) osi_QPrev(&bp->q);
osi_QRemove((osi_queue_t **) &cm_data.buf_freeListp, &bp->q);
- bp->qFlags &= ~CM_BUF_QINLRU;
+ _InterlockedAnd(&bp->qFlags, ~CM_BUF_QINLRU);
}
lock_ReleaseWrite(&buf_globalLock);
osi_Log1(buf_logp, "buf_SetDirty 0x%p", bp);
/* set dirty bit */
- bp->flags |= CM_BUF_DIRTY;
+ _InterlockedOr(&bp->flags, CM_BUF_DIRTY);
/* and turn off EOF flag, since it has associated data now */
- bp->flags &= ~CM_BUF_EOF;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_EOF);
bp->dirty_offset = offset;
bp->dirty_length = length;
cm_data.buf_dirtyListEndp = bp;
}
bp->dirtyp = NULL;
- bp->qFlags |= CM_BUF_QINDL;
+ _InterlockedOr(&bp->qFlags, CM_BUF_QINDL);
}
lock_ReleaseWrite(&buf_globalLock);
}
*/
if (LargeIntegerLessThanOrEqualTo(*sizep, bufp->offset)) {
/* truncating the entire page */
- bufp->flags &= ~CM_BUF_DIRTY;
+ _InterlockedAnd(&bufp->flags, ~CM_BUF_DIRTY);
bufp->dirty_offset = 0;
bufp->dirty_length = 0;
bufp->dataVersion = CM_BUF_VERSION_BAD; /* known bad */
* page therefore contains data that can no longer be stored.
*/
lock_ObtainMutex(&bp->mx);
- bp->flags &= ~CM_BUF_DIRTY;
- bp->flags |= CM_BUF_ERROR;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY);
+ _InterlockedOr(&bp->flags, CM_BUF_ERROR);
bp->error = CM_ERROR_BADFD;
bp->dirty_offset = 0;
bp->dirty_length = 0;
* Do not waste the time attempting to store to
* the file server when we know it will fail.
*/
- bp->flags &= ~CM_BUF_DIRTY;
- bp->flags |= CM_BUF_ERROR;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY);
+ _InterlockedOr(&bp->flags, CM_BUF_ERROR);
bp->dirty_offset = 0;
bp->dirty_length = 0;
bp->error = code;
buf_Hold(bp);
lock_ObtainMutex(&bp->mx);
_InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMSTORING);
- bp->flags &= ~CM_BUF_DIRTY;
+ _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY);
bp->dirty_offset = 0;
bp->dirty_length = 0;
- bp->flags |= CM_BUF_ERROR;
+ _InterlockedOr(&bp->flags, CM_BUF_ERROR);
bp->error = VNOVNODE;
bp->dataVersion = CM_BUF_VERSION_BAD; /* bad */
bp->dirtyCounter++;