From b2c1313f2f39ffff22a2a991dcb01428f118a3c7 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 18 Aug 2011 21:58:50 -0400 Subject: [PATCH] Windows: Be more efficient when processing locks Do not drop the cm_scacheLock only to reacquire it a few lines later. Do not manually set the tail of the queue when osi_RemoveHT does it for us. Change-Id: I61b2e54a4864760d257dfcd2841c2c15f1ee41fe Reviewed-on: http://gerrit.openafs.org/5300 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_vnodeops.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 5698f0af7b..2abcf6bbc4 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -4857,15 +4857,15 @@ long cm_Lock(cm_scache_t *scp, unsigned char sLockType, if (force_client_lock && code != CM_ERROR_WOULDBLOCK) code = 0; + cm_HoldUser(userp); + lock_ObtainWrite(&cm_scacheLock); fileLock = cm_GetFileLock(); - lock_ReleaseWrite(&cm_scacheLock); #ifdef DEBUG fileLock->fid = scp->fid; #endif fileLock->key = key; fileLock->lockType = Which; - cm_HoldUser(userp); fileLock->userp = userp; fileLock->range = range; fileLock->flags = (code == 0 ? 0 : @@ -4878,7 +4878,6 @@ long cm_Lock(cm_scache_t *scp, unsigned char sLockType, fileLock->lastUpdate = (code == 0 && !force_client_lock) ? time(NULL) : 0; - lock_ObtainWrite(&cm_scacheLock); osi_QAddT(&scp->fileLocksH, &scp->fileLocksT, &fileLock->fileq); cm_HoldSCacheNoLock(scp); fileLock->scp = scp; @@ -5085,8 +5084,6 @@ long cm_UnlockByKey(cm_scache_t * scp, fileLock->range.length, fileLock->lockType); - if (scp->fileLocksT == q) - scp->fileLocksT = osi_QPrev(q); osi_QRemoveHT(&scp->fileLocksH, &scp->fileLocksT, q); if (IS_LOCK_CLIENTONLY(fileLock)) { @@ -5209,8 +5206,6 @@ long cm_Unlock(cm_scache_t *scp, /* discard lock record */ lock_ConvertRToW(&cm_scacheLock); - if (scp->fileLocksT == q) - scp->fileLocksT = osi_QPrev(q); osi_QRemoveHT(&scp->fileLocksH, &scp->fileLocksT, q); /* @@ -5787,8 +5782,6 @@ long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead) handleCode: if (code != 0 && code != CM_ERROR_WOULDBLOCK) { lock_ObtainWrite(&cm_scacheLock); - if (scp->fileLocksT == &oldFileLock->fileq) - scp->fileLocksT = osi_QPrev(&oldFileLock->fileq); osi_QRemoveHT(&scp->fileLocksH, &scp->fileLocksT, &oldFileLock->fileq); lock_ReleaseWrite(&cm_scacheLock); }