Windows: Interlocked for cm_buf cmFlags
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 10 Aug 2011 15:42:59 +0000 (11:42 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Thu, 11 Aug 2011 06:15:54 +0000 (23:15 -0700)
Change-Id: I7ed2847afdcbc94c9023c6686d3c81f7863d7f61
Reviewed-on: http://gerrit.openafs.org/5196
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_dcache.c
src/WINNT/afsd/cm_scache.c

index e62a20b..dd6946e 100644 (file)
@@ -2019,7 +2019,7 @@ long buf_CleanDirtyBuffers(cm_scache_t *scp)
        if (!cm_FidCmp(fidp, &bp->fid) && (bp->flags & CM_BUF_DIRTY)) {
             buf_Hold(bp);
            lock_ObtainMutex(&bp->mx);
-           bp->cmFlags &= ~CM_BUF_CMSTORING;
+           _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMSTORING);
            bp->flags &= ~CM_BUF_DIRTY;
             bp->dirty_offset = 0;
             bp->dirty_length = 0;
index 8c00319..73d455f 100644 (file)
@@ -843,7 +843,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af
                 lock_ObtainWrite(&scp->rw);
                 rxheld = 1;
             }
-            bp->cmFlags &= ~CM_BUF_CMBKGFETCH;
+            _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH);
             buf_Release(bp);
             bp = NULL;
             continue;
@@ -858,7 +858,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af
         if (code == 0)
             fetched = LargeIntegerAdd(fetched, tblocksize);
         buf_Release(bp);
-        bp->cmFlags &= ~CM_BUF_CMBKGFETCH;
+        _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH);
     }
 
     if (!rxheld) {
@@ -873,7 +873,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af
     {
         bp = buf_Find(scp, &offset);
         if (bp) {
-            bp->cmFlags &= ~CM_BUF_CMBKGFETCH;
+            _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH);
             buf_Release(bp);
         }
     }
@@ -964,7 +964,7 @@ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, afs_uint32 coun
             rwheld = 1;
         }
 
-        bp->cmFlags |= CM_BUF_CMBKGFETCH;
+        _InterlockedOr(&bp->cmFlags, CM_BUF_CMBKGFETCH);
         buf_Release(bp);
     }
 
@@ -1956,7 +1956,7 @@ long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *userp
                         * PREFETCHING flag, so the reader waiting for
                         * this buffer will start a prefetch.
                         */
-                        tbufp->cmFlags |= CM_BUF_CMFULLYFETCHED;
+                        _InterlockedOr(&tbufp->cmFlags, CM_BUF_CMFULLYFETCHED);
                         lock_ObtainWrite(&scp->rw);
                         if (scp->flags & CM_SCACHEFLAG_WAITING) {
                             osi_Log1(afsd_logp, "CM GetBuffer Waking scp 0x%p", scp);
@@ -2013,7 +2013,7 @@ long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *userp
                  * PREFETCHING flag, so the reader waiting for
                  * this buffer will start a prefetch.
                  */
-                tbufp->cmFlags |= CM_BUF_CMFULLYFETCHED;
+                _InterlockedOr(&tbufp->cmFlags, CM_BUF_CMFULLYFETCHED);
                 lock_ObtainWrite(&scp->rw);
                 if (scp->flags & CM_SCACHEFLAG_WAITING) {
                     osi_Log1(afsd_logp, "CM GetBuffer Waking scp 0x%p", scp);
index d4a8b7a..49b409a 100644 (file)
@@ -164,7 +164,7 @@ long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
            osi_QDFree(qdp);
            if (bufp) {
                lock_ObtainMutex(&bufp->mx);
-               bufp->cmFlags &= ~CM_BUF_CMSTORING;
+               _InterlockedAnd(&bufp->cmFlags, ~CM_BUF_CMSTORING);
                bufp->flags &= ~CM_BUF_DIRTY;
                 bufp->dirty_offset = 0;
                 bufp->dirty_length = 0;
@@ -186,7 +186,7 @@ long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
            osi_QDFree(qdp);
            if (bufp) {
                lock_ObtainMutex(&bufp->mx);
-               bufp->cmFlags &= ~CM_BUF_CMFETCHING;
+               _InterlockedAnd(&bufp->cmFlags, ~CM_BUF_CMFETCHING);
                bufp->flags &= ~CM_BUF_DIRTY;
                 bufp->dirty_offset = 0;
                 bufp->dirty_length = 0;
@@ -1386,7 +1386,7 @@ long cm_SyncOp(cm_scache_t *scp, cm_buf_t *bufp, cm_user_t *userp, cm_req_t *req
         osi_SetQData(qdp, bufp);
 
         buf_Hold(bufp);
-        bufp->cmFlags |= CM_BUF_CMFETCHING;
+        _InterlockedOr(&bufp->cmFlags, CM_BUF_CMFETCHING);
         osi_QAdd((osi_queue_t **) &scp->bufReadsp, &qdp->q);
     }
 
@@ -1404,13 +1404,13 @@ long cm_SyncOp(cm_scache_t *scp, cm_buf_t *bufp, cm_user_t *userp, cm_req_t *req
         qdp = osi_QDAlloc();
         osi_SetQData(qdp, bufp);
         buf_Hold(bufp);
-        bufp->cmFlags |= CM_BUF_CMSTORING;
+        _InterlockedOr(&bufp->cmFlags, CM_BUF_CMSTORING);
         osi_QAdd((osi_queue_t **) &scp->bufWritesp, &qdp->q);
     }
 
     if (bufp && (flags & CM_SCACHESYNC_WRITE)) {
         /* mark the buffer as being written to. */
-        bufp->cmFlags |= CM_BUF_CMWRITING;
+        _InterlockedOr(&bufp->cmFlags, CM_BUF_CMWRITING);
     }
 
     return 0;
@@ -1459,7 +1459,7 @@ void cm_SyncOpDone(cm_scache_t *scp, cm_buf_t *bufp, afs_uint32 flags)
            osi_QDFree(qdp);
            release = 1;
        }
-        bufp->cmFlags &= ~(CM_BUF_CMFETCHING | CM_BUF_CMFULLYFETCHED);
+        _InterlockedAnd(&bufp->cmFlags, ~(CM_BUF_CMFETCHING | CM_BUF_CMFULLYFETCHED));
         if (bufp->flags & CM_BUF_WAITING) {
             osi_Log2(afsd_logp, "CM SyncOpDone FetchData Waking [scp 0x%p] bufp 0x%p", scp, bufp);
             osi_Wakeup((LONG_PTR) &bufp);
@@ -1482,7 +1482,7 @@ void cm_SyncOpDone(cm_scache_t *scp, cm_buf_t *bufp, afs_uint32 flags)
            osi_QDFree(qdp);
            release = 1;
        }
-        bufp->cmFlags &= ~CM_BUF_CMSTORING;
+        _InterlockedAnd(&bufp->cmFlags, ~CM_BUF_CMSTORING);
         if (bufp->flags & CM_BUF_WAITING) {
             osi_Log2(afsd_logp, "CM SyncOpDone StoreData Waking [scp 0x%p] bufp 0x%p", scp, bufp);
             osi_Wakeup((LONG_PTR) &bufp);
@@ -1493,7 +1493,7 @@ void cm_SyncOpDone(cm_scache_t *scp, cm_buf_t *bufp, afs_uint32 flags)
 
     if (bufp && (flags & CM_SCACHESYNC_WRITE)) {
         osi_assertx(bufp->cmFlags & CM_BUF_CMWRITING, "!CM_BUF_CMWRITING");
-        bufp->cmFlags &= ~CM_BUF_CMWRITING;
+        _InterlockedAnd(&bufp->cmFlags, ~CM_BUF_CMWRITING);
     }
 
     /* and wakeup anyone who is waiting */