From: Jeffrey Altman Date: Sat, 29 Dec 2012 05:36:44 +0000 (-0500) Subject: Windows: AFSNotifyFileCreate() DirOpenReferenceCount handling X-Git-Tag: upstream/1.8.0_pre1^2~1634 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5ef1aeb60f14ca3807a2855c23cb011e0fc046fb;p=packages%2Fo%2Fopenafs.git Windows: AFSNotifyFileCreate() DirOpenReferenceCount handling This patchset consolidates the releasing of the DirOpenReferenceCount within AFSNotifyFileCreate() into the try_exit block. This clarifies the logic and avoids duplicate code blocks. Change-Id: I82e964f579f9e8b6e095291ace0bbe2cdac5af60 Reviewed-on: http://gerrit.openafs.org/8855 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp index 821daba59..8563a599e 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp @@ -1526,10 +1526,13 @@ AFSNotifyFileCreate( IN GUID *AuthGroup, LONG lCount; LARGE_INTEGER liOldDataVersion; AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension; + BOOLEAN bReleaseParentTreeLock = FALSE; __Enter { + *DirNode = NULL; + // // Init the control block for the request // @@ -1602,6 +1605,8 @@ AFSNotifyFileCreate( IN GUID *AuthGroup, AFSAcquireExcl( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock, TRUE); + bReleaseParentTreeLock = TRUE; + if( ParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1) { @@ -1642,21 +1647,8 @@ AFSNotifyFileCreate( IN GUID *AuthGroup, &pResultCB->DirEnum.FileId)) { - lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSNotifyFileCreate Increment count on %wZ DE %p Cnt %d\n", - &pDirNode->NameInformation.FileName, - pDirNode, - lCount); - - ASSERT( lCount >= 0); - *DirNode = pDirNode; - AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock); - try_return( ntStatus = STATUS_REPARSE); } else @@ -1766,8 +1758,6 @@ AFSNotifyFileCreate( IN GUID *AuthGroup, ParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1; - AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock); - try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES); } @@ -1833,8 +1823,6 @@ AFSNotifyFileCreate( IN GUID *AuthGroup, ParentObjectInfo->DataVersion.QuadPart); } - AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock); - // // Return the directory node // @@ -1843,6 +1831,27 @@ AFSNotifyFileCreate( IN GUID *AuthGroup, try_exit: + if ( *DirNode != NULL) + { + + lCount = InterlockedIncrement( &(*DirNode)->DirOpenReferenceCount); + + AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSNotifyFileCreate Increment count on %wZ DE %p Cnt %d\n", + &(*DirNode)->NameInformation.FileName, + *DirNode, + lCount); + + ASSERT( lCount >= 0); + } + + if ( bReleaseParentTreeLock) + { + + AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock); + } + if( pResultCB != NULL) {