From 08d446424873c2d46b00b6d4604766051e5ba837 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 25 Oct 2012 14:33:29 -0400 Subject: [PATCH] Windows: AFSCleanup re-organization Reorganize the activities of the AFSCleanup() for File FCBs so that the Fcb Resource can be dropped prior to issuing the cleanup request to the cache manager. The cache manager can block for a long period of time while flushing data and holding the Fcb resource blocks all subsequent CreateFile requests. Change-Id: Ieaf3653ebf487670bce1043e73be093eb77a8736 Reviewed-on: http://gerrit.openafs.org/8307 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp | 76 +++++++++++++++++++----------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp index 3e370ab..43ac6ab 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp @@ -574,6 +574,34 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject, stFileCleanup.FileAccess = pCcb->FileAccess; // + // Remove the share access at this time since we may not get the close for sometime on this FO. + // + + IoRemoveShareAccess( pFileObject, + &pFcb->ShareAccess); + + + // + // We don't need the name array after the user closes the handle on the file + // + + if( pCcb->NameArray != NULL) + { + + AFSFreeNameArray( pCcb->NameArray); + + pCcb->NameArray = NULL; + } + + // + // Release the Fcb Resource across the call to the service + // which may block for quite a while if flushing of the + // data is required. + // + + AFSReleaseResource( &pFcb->NPFcb->Resource); + + // // Push the request to the service // @@ -587,6 +615,13 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject, pResultCB, &ulResultLen); + // + // Regain exclusive access to the Fcb + // + + AFSAcquireExcl( &pFcb->NPFcb->Resource, + TRUE); + if ( NT_SUCCESS( ntStatus)) { @@ -614,25 +649,6 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject, } // - // Remove the share access at this time since we may not get the close for sometime on this FO. - // - - IoRemoveShareAccess( pFileObject, - &pFcb->ShareAccess); - - // - // We don't need the name array after the user closes the handle on the file - // - - if( pCcb->NameArray != NULL) - { - - AFSFreeNameArray( pCcb->NameArray); - - pCcb->NameArray = NULL; - } - - // // Decrement the open child handle count // @@ -652,7 +668,14 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject, lCount); } - AFSReleaseResource( &pFcb->NPFcb->Resource); + + lCount = InterlockedDecrement( &pFcb->OpenHandleCount); + + AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSCleanup (File) Decrement handle count on Fcb %08lX Cnt %d\n", + pFcb, + lCount); if( BooleanFlagOn( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE)) { @@ -664,17 +687,16 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject, ClearFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE); + AFSReleaseResource( &pFcb->NPFcb->Resource); + AFSPerformObjectInvalidate( pObjectInfo, AFS_INVALIDATE_DATA_VERSION); } + else + { - lCount = InterlockedDecrement( &pFcb->OpenHandleCount); - - AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING, - AFS_TRACE_LEVEL_VERBOSE, - "AFSCleanup (File) Decrement handle count on Fcb %08lX Cnt %d\n", - pFcb, - lCount); + AFSReleaseResource( &pFcb->NPFcb->Resource); + } break; } -- 1.9.4