Windows: FindObjectInfo refcnt under lock
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 2 Apr 2013 04:40:54 +0000 (00:40 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 6 Apr 2013 02:26:47 +0000 (19:26 -0700)
AFSFindObjectInfo performed the search of Volume object tree protected by
the TreeLock but dropped the lock before incrementing the reference count.
This behavior contributed to a race with the AFSPrimaryVolumeWorkerThread
which has to drop the VolumeCB TreeLock periodically in order to safely
cleanup FCBs.

Change-Id: I0cba4a118e4835edee7702db97846567618e0adf
Reviewed-on: http://gerrit.openafs.org/9719
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
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/afsrdr/kernel/lib/AFSGeneric.cpp

index 3e85ec2..060b3bb 100644 (file)
@@ -6179,6 +6179,11 @@ AFSFindObjectInfo( IN AFSVolumeCB *VolumeCB,
     AFSObjectInfoCB *pObjectInfo = NULL;
     LONG             lCount;
 
+    ullIndex = AFSCreateLowIndex( FileId);
+
+    AFSAcquireShared( VolumeCB->ObjectInfoTree.TreeLock,
+                      TRUE);
+
     if ( AFSIsEqualFID( &VolumeCB->ObjectInformation.FileId, FileId))
     {
 
@@ -6187,16 +6192,9 @@ AFSFindObjectInfo( IN AFSVolumeCB *VolumeCB,
     else
     {
 
-        AFSAcquireExcl( VolumeCB->ObjectInfoTree.TreeLock,
-                        TRUE);
-
-        ullIndex = AFSCreateLowIndex( FileId);
-
         ntStatus = AFSLocateHashEntry( VolumeCB->ObjectInfoTree.TreeHead,
                                        ullIndex,
                                        (AFSBTreeEntry **)&pObjectInfo);
-
-        AFSReleaseResource( VolumeCB->ObjectInfoTree.TreeLock);
     }
 
     if ( NT_SUCCESS( ntStatus)) {
@@ -6211,6 +6209,8 @@ AFSFindObjectInfo( IN AFSVolumeCB *VolumeCB,
                       lCount));
     }
 
+    AFSReleaseResource( VolumeCB->ObjectInfoTree.TreeLock);
+
     return pObjectInfo;
 }