From: Jeffrey Altman Date: Wed, 20 Mar 2013 14:04:41 +0000 (-0400) Subject: Windows: buf_CleanVnode avoid lock contention X-Git-Tag: openafs-stable-1_8_0pre1~1284 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=cda4f6c3ff92a35e2ff8b2eb114729144fff165f Windows: buf_CleanVnode avoid lock contention In the middle of the big loop do not obtain buf_globalLock unless cm_buf.qFlags & CM_BUF_QREDIR is non-zero. buf_globalLock is heavily contested and any reduction in contention is an improvement. CM_BUF_QREDIR is never set when 'cm_directIO' is true (now the default) so this is a huge win. Change-Id: I0b150bf77a0f1d748f94026d3b74bc7d90e7c3c6 Reviewed-on: http://gerrit.openafs.org/9636 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 0a5a3d2..d35fbbe 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -2252,14 +2252,16 @@ long buf_CleanVnode(struct cm_scache *scp, cm_user_t *userp, cm_req_t *reqp) * it back in order to determine whether or not it is in * fact dirty. */ - lock_ObtainRead(&buf_globalLock); if (bp->qFlags & CM_BUF_QREDIR) { - osi_Log1(buf_logp,"buf_CleanVnode buffer held by redirector bp 0x%p", bp); + lock_ObtainRead(&buf_globalLock); + if (bp->qFlags & CM_BUF_QREDIR) { + osi_Log1(buf_logp,"buf_CleanVnode buffer held by redirector bp 0x%p", bp); - /* Retrieve single extent from the redirector */ - buf_RDRShakeAnExtentFree(bp, reqp); + /* Retrieve single extent from the redirector */ + buf_RDRShakeAnExtentFree(bp, reqp); + } + lock_ReleaseRead(&buf_globalLock); } - lock_ReleaseRead(&buf_globalLock); lock_ObtainMutex(&bp->mx); if ((bp->flags & CM_BUF_DIRTY)) {