Windows: buf_CleanVnode avoid lock contention
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 20 Mar 2013 14:04:41 +0000 (10:04 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 22 Mar 2013 14:29:29 +0000 (07:29 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_buf.c

index 0a5a3d2..d35fbbe 100644 (file)
@@ -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)) {