diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp index fc6af33338..28d4ffc424 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp @@ -557,6 +557,9 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject, AFSWaitOnQueuedFlushes( pFcb); ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE; + + AFSTearDownFcbExtents( pFcb, + &pCcb->AuthGroup); } // diff --git a/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp b/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp index b90915b22b..6d503d4fca 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp @@ -2885,7 +2885,8 @@ try_exit: NTSTATUS AFSReleaseExtentsWithFlush( IN AFSFcb *Fcb, - IN GUID *AuthGroup) + IN GUID *AuthGroup, + IN BOOLEAN bReleaseAll) { AFSNonPagedFcb *pNPFcb = Fcb->NPFcb; AFSExtent *pExtent; @@ -2956,18 +2957,15 @@ AFSReleaseExtentsWithFlush( IN AFSFcb *Fcb, try_return ( ntStatus = STATUS_INSUFFICIENT_RESOURCES ); } - if( Fcb->OpenHandleCount > 0) + if( Fcb->OpenHandleCount > 0 && + !bReleaseAll) { // // Don't release everything ... // - // - // For now release everything - // - - //ulRemainingExtentLength = 1500; + ulRemainingExtentLength = 1024; } while( Fcb->Specific.File.ExtentLength > (LONG)ulRemainingExtentLength) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSFlushBuffers.cpp b/src/WINNT/afsrdr/kernel/lib/AFSFlushBuffers.cpp index d868a4999d..eedfd9a225 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSFlushBuffers.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSFlushBuffers.cpp @@ -126,7 +126,8 @@ AFSFlushBuffers( IN PDEVICE_OBJECT LibDeviceObject, { AFSReleaseExtentsWithFlush( pFcb, - &pCcb->AuthGroup); + &pCcb->AuthGroup, + TRUE); ntStatus = STATUS_SUCCESS; } diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index a8804f668b..ac81d7c3cd 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -7028,7 +7028,8 @@ AFSCleanupFcb( IN AFSFcb *Fcb, { AFSReleaseExtentsWithFlush( Fcb, - NULL); + NULL, + TRUE); } } @@ -7073,7 +7074,8 @@ AFSCleanupFcb( IN AFSFcb *Fcb, { AFSReleaseExtentsWithFlush( Fcb, - NULL); + NULL, + TRUE); } } diff --git a/src/WINNT/afsrdr/kernel/lib/AFSRead.cpp b/src/WINNT/afsrdr/kernel/lib/AFSRead.cpp index 1e8dbb97fb..775c9aa577 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSRead.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSRead.cpp @@ -691,8 +691,14 @@ AFSNonCachedRead( IN PDEVICE_OBJECT DeviceObject, // The data is there now. Give back the extents now so the service // has some in hand // - (VOID) AFSReleaseExtentsWithFlush( pFcb, - &pCcb->AuthGroup); + + if ( pFcb->Specific.File.ExtentLength > 4096) + { + + (VOID) AFSReleaseExtentsWithFlush( pFcb, + &pCcb->AuthGroup, + FALSE); + } try_exit: diff --git a/src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp b/src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp index 2af9c67d40..9239c40e87 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp @@ -739,7 +739,8 @@ AFSWorkerThread( IN PVOID Context) { AFSReleaseExtentsWithFlush( pWorkItem->Specific.Fcb.Fcb, - &pWorkItem->AuthGroup); + &pWorkItem->AuthGroup, + FALSE); } ASSERT( pWorkItem->Specific.Fcb.Fcb->OpenReferenceCount != 0); diff --git a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h index 0b666696e3..ffe175434b 100644 --- a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h +++ b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h @@ -395,7 +395,8 @@ AFSFlushExtents( IN AFSFcb *pFcb, NTSTATUS AFSReleaseExtentsWithFlush( IN AFSFcb *Fcb, - IN GUID *AuthGroup); + IN GUID *AuthGroup, + IN BOOLEAN bReleaseAll); NTSTATUS AFSReleaseCleanExtents( IN AFSFcb *Fcb,