AFSMarkDirty( IN AFSFcb *Fcb,
IN AFSExtent *StartExtent,
IN ULONG ExtentsCount,
- IN LARGE_INTEGER *StartingByte)
+ IN LARGE_INTEGER *StartingByte,
+ IN BOOLEAN DerefExtents)
{
AFSNonPagedFcb *pNPFcb = Fcb->NPFcb;
ULONG ulCount = 0;
BOOLEAN bInsertTail = FALSE, bInsertHead = FALSE;
LONG lCount;
+ BOOLEAN bLocked = FALSE;
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
&Fcb->NPFcb->Specific.File.ExtentsResource,
PsGetCurrentThread());
- AFSAcquireShared( &Fcb->NPFcb->Specific.File.ExtentsResource, TRUE);
+ if( !ExIsResourceAcquiredLite( &Fcb->NPFcb->Specific.File.ExtentsResource))
+ {
+ AFSAcquireShared( &Fcb->NPFcb->Specific.File.ExtentsResource, TRUE);
+ bLocked = TRUE;
+ }
AFSAcquireExcl( &pNPFcb->Specific.File.DirtyExtentsListLock,
TRUE);
pExtent,
pExtent->ActiveCount);
- ASSERT( pExtent->ActiveCount > 0);
-
- lCount = InterlockedDecrement( &pExtent->ActiveCount);
+ if( DerefExtents)
+ {
+ ASSERT( pExtent->ActiveCount > 0);
+ lCount = InterlockedDecrement( &pExtent->ActiveCount);
+ }
pExtent = pNextExtent;
&Fcb->NPFcb->Specific.File.ExtentsResource,
PsGetCurrentThread());
- AFSReleaseResource( &Fcb->NPFcb->Specific.File.ExtentsResource );
+ if( bLocked)
+ {
+ AFSReleaseResource( &Fcb->NPFcb->Specific.File.ExtentsResource );
+ }
return;
}
LARGE_INTEGER liCurrentTime, liLastRequestTime;
AFSDeviceExt *pControlDevExt = (AFSDeviceExt *)AFSControlDeviceObject->DeviceExtension;
PFILE_OBJECT pCacheFileObject = NULL;
+ BOOLEAN bDerefExtents = FALSE;
__Enter
{
AFSReferenceActiveExtents( pStartExtent,
extentsCount);
+ bDerefExtents = TRUE;
+
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSNonCachedWrite Releasing(2) Fcb extents lock %08lX SHARED %08lX\n",
try_return( ntStatus);
}
- //
- // Since this is dirty we can mark the extents dirty now.
- // AFSMarkDirty will dereference the extents. Do not call
- // AFSDereferenceActiveExtents() in this code path.
- //
-
- AFSMarkDirty( pFcb,
- pStartExtent,
- extentsCount,
- &StartingByte);
+try_exit:
- if (!bPagingIo)
+ if( NT_SUCCESS( ntStatus) &&
+ pStartExtent != NULL &&
+ Irp->IoStatus.Information > 0)
{
+
//
- // This was an uncached user write - tell the server to do
- // the flush when the worker thread next wakes up
+ // Since this is dirty we can mark the extents dirty now.
+ // AFSMarkDirty will dereference the extents. Do not call
+ // AFSDereferenceActiveExtents() in this code path.
//
- pFcb->Specific.File.LastServerFlush.QuadPart = 0;
- }
- //
- // All done
- //
+ AFSMarkDirty( pFcb,
+ pStartExtent,
+ extentsCount,
+ &StartingByte,
+ bDerefExtents);
-try_exit:
+ if (!bPagingIo)
+ {
+ //
+ // This was an uncached user write - tell the server to do
+ // the flush when the worker thread next wakes up
+ //
+ pFcb->Specific.File.LastServerFlush.QuadPart = 0;
+ }
+ }
if( pCacheFileObject != NULL)
{
AFSMarkDirty( IN AFSFcb *pFcb,
IN AFSExtent *StartExtent,
IN ULONG ExtentsCount,
- IN LARGE_INTEGER *StartingByte);
+ IN LARGE_INTEGER *StartingByte,
+ IN BOOLEAN DerefExtents);
BOOLEAN
AFSTearDownFcbExtents( IN AFSFcb *Fcb,