Author: dgorbachev
Date: Sun Aug 16 03:20:50 2009
New Revision: 42724
URL:
http://svn.reactos.org/svn/reactos?rev=42724&view=rev
Log:
Synchronize with paging I/O.
Modified:
trunk/reactos/drivers/filesystems/ext2/src/close.c
Modified: trunk/reactos/drivers/filesystems/ext2/src/close.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ext2/s…
==============================================================================
--- trunk/reactos/drivers/filesystems/ext2/src/close.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ext2/src/close.c [iso-8859-1] Sun Aug 16 03:20:50
2009
@@ -115,6 +115,7 @@
PtrExt2VCB PtrVCB = NULL;
PtrExt2NTRequiredFCB PtrReqdFCB = NULL;
PERESOURCE PtrResourceAcquired = NULL;
+ PERESOURCE PtrPagingIoResourceAcquired = NULL;
BOOLEAN CompleteIrp = TRUE;
BOOLEAN PostRequest = FALSE;
@@ -180,10 +181,11 @@
{
DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [Close]",
PtrFileObject);
}
+
i = 1;
while( !AcquiredVCB )
{
- DebugTraceState( "VCB AC:0x%LX SW:0x%LX EX:0x%LX [Close]",
PtrVCB->VCBResource.ActiveCount, PtrVCB->VCBResource.NumberOfExclusiveWaiters,
PtrVCB->VCBResource.NumberOfSharedWaiters );
+ DebugTraceState( "VCB AC:0x%LX EX:0x%LX SW:0x%LX [Close]",
PtrVCB->VCBResource.ActiveCount, PtrVCB->VCBResource.NumberOfExclusiveWaiters,
PtrVCB->VCBResource.NumberOfSharedWaiters );
if(! ExAcquireResourceExclusiveLite( &(PtrVCB->VCBResource), FALSE ) )
{
DebugTrace(DEBUG_TRACE_MISC, "*** VCB Acquisition FAILED [Close]", 0);
@@ -231,13 +233,14 @@
{
DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [Close]",
PtrFileObject);
}
+
+ PtrReqdFCB = &PtrFCB->NTRequiredFCB;
+
i = 1;
while( !PtrResourceAcquired )
{
- PtrReqdFCB = &(PtrFCB->NTRequiredFCB);
-
- DebugTraceState( "FCBMain AC:0x%LX SW:0x%LX EX:0x%LX [Close]",
PtrReqdFCB->MainResource.ActiveCount,
PtrReqdFCB->MainResource.NumberOfExclusiveWaiters,
PtrReqdFCB->MainResource.NumberOfSharedWaiters );
- if(! ExAcquireResourceExclusiveLite( &(PtrFCB->NTRequiredFCB.MainResource ),
FALSE ) )
+ DebugTraceState( "FCBMain AC:0x%LX EX:0x%LX SW:0x%LX [Close]",
PtrReqdFCB->MainResource.ActiveCount,
PtrReqdFCB->MainResource.NumberOfExclusiveWaiters,
PtrReqdFCB->MainResource.NumberOfSharedWaiters );
+ if(! ExAcquireResourceExclusiveLite( &(PtrReqdFCB->MainResource), FALSE ) )
{
DebugTrace(DEBUG_TRACE_MISC, "*** FCB Acquisition FAILED [Close]", 0);
if( BlockForResource && i != 1000 )
@@ -261,7 +264,40 @@
else
{
DebugTrace(DEBUG_TRACE_MISC, "*** FCB acquired [Close]", 0);
- PtrResourceAcquired = & ( PtrFCB->NTRequiredFCB.MainResource );
+ PtrResourceAcquired = & ( PtrReqdFCB->MainResource );
+ }
+ i *= 10;
+ }
+
+ i = 1;
+ while( !PtrPagingIoResourceAcquired )
+ {
+ DebugTraceState( "FCBPaging AC:0x%LX EX:0x%LX SW:0x%LX [Close]",
PtrReqdFCB->PagingIoResource.ActiveCount,
PtrReqdFCB->PagingIoResource.NumberOfExclusiveWaiters,
PtrReqdFCB->PagingIoResource.NumberOfSharedWaiters );
+ if(! ExAcquireResourceExclusiveLite( &(PtrReqdFCB->PagingIoResource), FALSE )
)
+ {
+ DebugTrace(DEBUG_TRACE_MISC, "*** FCB Acquisition FAILED [Close]", 0);
+ if( BlockForResource && i != 1000 )
+ {
+ LARGE_INTEGER Delay;
+
+ // KeSetPriorityThread( PsGetCurrentThread(), LOW_REALTIME_PRIORITY );
+
+ Delay.QuadPart = -500 * i;
+ KeDelayExecutionThread( KernelMode, FALSE, &Delay );
+ DebugTrace(DEBUG_TRACE_MISC, "*** Retrying... after 50 * %ld ms
[Close]", i);
+ }
+ else
+ {
+ if( i == 1000 )
+ DebugTrace(DEBUG_TRACE_MISC, "*** Reposting... [Close]", 0 );
+ PostRequest = TRUE;
+ try_return( RC = STATUS_PENDING );
+ }
+ }
+ else
+ {
+ DebugTrace(DEBUG_TRACE_MISC, "*** FCB acquired [Close]", 0);
+ PtrPagingIoResourceAcquired = & ( PtrReqdFCB->PagingIoResource );
}
i *= 10;
}
@@ -372,11 +408,22 @@
DebugTrace(DEBUG_TRACE_MISC, "^^^^^Deleting FCB [Close]", 0);
RemoveEntryList( &PtrFCB->NextFCB );
+ if ( PtrPagingIoResourceAcquired )
+ {
+ Ext2ReleaseResource(PtrPagingIoResourceAcquired);
+ DebugTraceState( "Resource AC:0x%LX EX:0x%LX SW:0x%LX
[Close]",
+ PtrPagingIoResourceAcquired->ActiveCount,
+ PtrPagingIoResourceAcquired->NumberOfExclusiveWaiters,
+ PtrPagingIoResourceAcquired->NumberOfSharedWaiters );
+
+ PtrPagingIoResourceAcquired = NULL;
+ }
+
if ( PtrResourceAcquired )
{
Ext2ReleaseResource(PtrResourceAcquired);
DebugTrace(DEBUG_TRACE_MISC, "*** FCB Released [Close]", 0);
- DebugTraceState( "Resource AC:0x%LX SW:0x%LX EX:0x%LX [Close]",
+ DebugTraceState( "Resource AC:0x%LX EX:0x%LX SW:0x%LX
[Close]",
PtrResourceAcquired->ActiveCount,
PtrResourceAcquired->NumberOfExclusiveWaiters,
PtrResourceAcquired->NumberOfSharedWaiters );
@@ -385,8 +432,9 @@
{
DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [Close]",
PtrFileObject);
}
- PtrResourceAcquired = FALSE;
- }
+ PtrResourceAcquired = NULL;
+ }
+
Ext2ReleaseFCB( PtrFCB );
}
@@ -407,11 +455,22 @@
}
finally
{
+ if ( PtrPagingIoResourceAcquired )
+ {
+ Ext2ReleaseResource(PtrPagingIoResourceAcquired);
+ DebugTraceState( "Resource AC:0x%LX EX:0x%LX SW:0x%LX [Close]",
+ PtrPagingIoResourceAcquired->ActiveCount,
+ PtrPagingIoResourceAcquired->NumberOfExclusiveWaiters,
+ PtrPagingIoResourceAcquired->NumberOfSharedWaiters );
+
+ PtrPagingIoResourceAcquired = NULL;
+ }
+
if ( PtrResourceAcquired )
{
Ext2ReleaseResource(PtrResourceAcquired);
DebugTrace(DEBUG_TRACE_MISC, "*** FCB Released [Close]", 0);
- DebugTraceState( "Resource AC:0x%LX SW:0x%LX EX:0x%LX [Close]",
+ DebugTraceState( "Resource AC:0x%LX EX:0x%LX SW:0x%LX [Close]",
PtrResourceAcquired->ActiveCount,
PtrResourceAcquired->NumberOfExclusiveWaiters,
PtrResourceAcquired->NumberOfSharedWaiters );
@@ -420,14 +479,14 @@
{
DebugTrace(DEBUG_TRACE_FILE_OBJ, "###### File Pointer 0x%LX [Close]",
PtrFileObject);
}
- PtrResourceAcquired = FALSE;
+ PtrResourceAcquired = NULL;
}
if (AcquiredVCB)
{
ASSERT(PtrVCB);
Ext2ReleaseResource(&(PtrVCB->VCBResource));
- DebugTraceState( "VCB AC:0x%LX SW:0x%LX EX:0x%LX [Close]",
PtrVCB->VCBResource.ActiveCount, PtrVCB->VCBResource.NumberOfExclusiveWaiters,
PtrVCB->VCBResource.NumberOfSharedWaiters );
+ DebugTraceState( "VCB AC:0x%LX EX:0x%LX SW:0x%LX [Close]",
PtrVCB->VCBResource.ActiveCount, PtrVCB->VCBResource.NumberOfExclusiveWaiters,
PtrVCB->VCBResource.NumberOfSharedWaiters );
DebugTrace(DEBUG_TRACE_MISC, "*** VCB Released [Close]", 0);
AcquiredVCB = FALSE;