From f849fb1f6be4d4f8c34d150c8cdce1435a7125bf Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 29 Dec 2012 00:29:45 -0500 Subject: [PATCH] Windows: AFSClose() DirOpenReferenceCount handling Unless the caller of AFSRemoveCcb() steals the DirectoryCB object from the AFSCcb before calling AFSRemoveCcb(), AFSRemoveCcb() will release the reference count. In all but one case where the DirectoryCB must be accessed after the AFSCcb is destroyed AFSClose() can now let AFSRemoveCcb() do the work. Change-Id: I8d631d79b2465cd6f2e31444fd052270b078915c Reviewed-on: http://gerrit.openafs.org/8854 Reviewed-by: Derrick Brashear Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSClose.cpp | 48 ++++---------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSClose.cpp b/src/WINNT/afsrdr/kernel/lib/AFSClose.cpp index 2c19d7d..d095302 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSClose.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSClose.cpp @@ -144,8 +144,6 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, NULL, NULL); - pDirCB = pCcb->DirectoryCB; - // // Remove the Ccb and de-allocate it // @@ -153,18 +151,6 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, AFSRemoveCcb( pFcb, pCcb); - lCount = InterlockedDecrement( &pDirCB->DirOpenReferenceCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSClose (IOCtl) Decrement count on %wZ DE %p Ccb %p Cnt %d\n", - &pDirCB->NameInformation.FileName, - pDirCB, - pCcb, - lCount); - - ASSERT( lCount >= 0); - // // If this is not the root then decrement the open child reference count // @@ -211,8 +197,6 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2; - pDirCB = pCcb->DirectoryCB; - // // Remove the Ccb and de-allocate it // @@ -220,18 +204,6 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, AFSRemoveCcb( pFcb, pCcb); - lCount = InterlockedDecrement( &pDirCB->DirOpenReferenceCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSClose Decrement (Root ALL) count on %wZ DE %p Ccb %p Cnt %d\n", - &pDirCB->NameInformation.FileName, - pDirCB, - pCcb, - lCount); - - ASSERT( lCount >= 0); - AFSReleaseResource( &pFcb->NPFcb->Resource); lCount = InterlockedDecrement( &pFcb->OpenReferenceCount); @@ -332,6 +304,12 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, pDirCB = pCcb->DirectoryCB; // + // Steal the DirOpenReferenceCount from the Ccb + // + + pCcb->DirectoryCB = NULL; + + // // Remove the Ccb and de-allocate it // @@ -534,8 +512,6 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, NULL); */ - pDirCB = pCcb->DirectoryCB; - // // Remove the Ccb and de-allocate it // @@ -543,18 +519,6 @@ AFSClose( IN PDEVICE_OBJECT LibDeviceObject, AFSRemoveCcb( pFcb, pCcb); - lCount = InterlockedDecrement( &pDirCB->DirOpenReferenceCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSClose (Share) Decrement count on %wZ DE %p Ccb %p Cnt %d\n", - &pDirCB->NameInformation.FileName, - pDirCB, - pCcb, - lCount); - - ASSERT( lCount >= 0); - // // If this is not the root then decrement the open child reference count // -- 1.9.4