Windows: optimize InitCallback3 processing
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 1 Apr 2012 16:11:40 +0000 (12:11 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 3 Apr 2012 03:18:05 +0000 (20:18 -0700)
Do not drop and acquire locks if the cm_scache_t does not
have a callback.

Change-Id: I6f84729838e7e4c2d84c0a40f0811ed837b79287
Reviewed-on: http://gerrit.openafs.org/7007
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsd/cm_callback.c

index 1936698..5c326c4 100644 (file)
@@ -1065,34 +1065,35 @@ SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
        lock_ObtainWrite(&cm_scacheLock);
        for (hash = 0; hash < cm_data.scacheHashTableSize; hash++) {
             for (scp=cm_data.scacheHashTablep[hash]; scp; scp=scp->nextp) {
-                cm_HoldSCacheNoLock(scp);
-                lock_ReleaseWrite(&cm_scacheLock);
-                lock_ObtainWrite(&scp->rw);
-                discarded = 0;
                 if (scp->cbExpires > 0 && scp->cbServerp != NULL) {
-                    /* we have a callback, now decide if we should clear it */
-                    if (cm_ServerEqual(scp->cbServerp, tsp)) {
-                        osi_Log4(afsd_logp, "InitCallbackState3 Discarding SCache scp 0x%p vol %u vn %u uniq %u",
-                                  scp, scp->fid.volume, scp->fid.vnode, scp->fid.unique);
-                        discardFid = scp->fid;
-                        discardType = scp->fileType;
-                        cm_DiscardSCache(scp);
-                        discarded = 1;
+                    cm_HoldSCacheNoLock(scp);
+                    lock_ReleaseWrite(&cm_scacheLock);
+                    discarded = 0;
+                    lock_ObtainWrite(&scp->rw);
+                    if (scp->cbExpires > 0 && scp->cbServerp != NULL) {
+                        /* we have a callback, now decide if we should clear it */
+                        if (cm_ServerEqual(scp->cbServerp, tsp)) {
+                            osi_Log4(afsd_logp, "InitCallbackState3 Discarding SCache scp 0x%p vol %u vn %u uniq %u",
+                                     scp, scp->fid.volume, scp->fid.vnode, scp->fid.unique);
+                            discardFid = scp->fid;
+                            discardType = scp->fileType;
+                            cm_DiscardSCache(scp);
+                            discarded = 1;
+                        }
                     }
-                }
-                lock_ReleaseWrite(&scp->rw);
-                if (discarded) {
-                    cm_CallbackNotifyChange(scp);
-                    if (RDR_Initialized)
-                        RDR_InvalidateObject(discardFid.cell, discardFid.volume, discardFid.vnode, discardFid.unique,
-                                             discardFid.hash, discardType, AFS_INVALIDATE_EXPIRED);
-                }
-                lock_ObtainWrite(&cm_scacheLock);
-                cm_ReleaseSCacheNoLock(scp);
-
-                if (discarded && (scp->flags & CM_SCACHEFLAG_PURERO))
-                    cm_callbackDiscardROVolumeByFID(&scp->fid);
+                    lock_ReleaseWrite(&scp->rw);
+                    if (discarded) {
+                        cm_CallbackNotifyChange(scp);
+                        if (RDR_Initialized)
+                            RDR_InvalidateObject(discardFid.cell, discardFid.volume, discardFid.vnode, discardFid.unique,
+                                                 discardFid.hash, discardType, AFS_INVALIDATE_EXPIRED);
+                    }
+                    lock_ObtainWrite(&cm_scacheLock);
+                    cm_ReleaseSCacheNoLock(scp);
 
+                    if (discarded && (scp->flags & CM_SCACHEFLAG_PURERO))
+                        cm_callbackDiscardROVolumeByFID(&scp->fid);
+                }
             }  /* search one hash bucket */
        }       /* search all hash buckets */