From fcf1079f580fe1f2afa86f5e0312792817d52d2f Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 2 May 2012 16:57:11 -0400 Subject: [PATCH] Windows: buf_RemoveFromRedirQueue in buf_Init use buf_RemoveFromRedirQueue in buf_Init instead of the roughly duplicated code. Change-Id: Ibf070d3e44f7a0749d1046c9d1168bdfb9aa6f2b Reviewed-on: http://gerrit.openafs.org/7310 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_buf.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 5e9d3cf88a..0938239e72 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -518,6 +518,7 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers) bp = cm_data.bufHeaderBaseAddress; data = cm_data.bufDataBaseAddress; + lock_ObtainWrite(&buf_globalLock); for (i=0; imx, "Buffer mutex", LOCK_HIERARCHY_BUFFER); bp->userp = NULL; @@ -530,16 +531,12 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers) * 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++; } @@ -556,17 +553,14 @@ long buf_Init(int newFile, cm_buf_ops_t *opsp, afs_uint64 nbuffers) * 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