Windows: deadlock bet. DirEntry lock + DirectoryNodeHdr.TreeLock
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 15 Jan 2012 16:08:23 +0000 (11:08 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 18 Jan 2012 23:12:27 +0000 (15:12 -0800)
The DirectoryNodeHdr.TreeLock must be obtained before the
DirEntry->NonPaged->Lock.  In AFSLocateNameEntry(), the
DirEntry lock is obtained before the TreeLock when processing
a symlink object.  For that case obtain the TreeLOCK first.
Drop it if it is not required.

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

src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp

index 1c8b261..3b3f306 100644 (file)
@@ -305,6 +305,9 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                         try_return( ntStatus);
                     }
 
+                    AFSAcquireExcl( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                                    TRUE);
+
                     AFSAcquireExcl( &pDirEntry->NonPaged->Lock,
                                     TRUE);
 
@@ -333,9 +336,6 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                         // Directory TreeLock should be exclusively held
                         //
 
-                        AFSAcquireExcl( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock,
-                                        TRUE);
-
                         ntStatus = AFSVerifyEntry( AuthGroup,
                                                    pDirEntry);
 
@@ -372,6 +372,11 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                             continue;
                         }
                     }
+                    else
+                    {
+
+                        AFSReleaseResource( pCurrentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                    }
 
                     //
                     // If we were given a zero length target name then deny access to the entry