Windows: AFSMarkDirty() require ExtentsResource held
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 23 Oct 2012 00:40:21 +0000 (20:40 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sun, 28 Oct 2012 01:51:05 +0000 (18:51 -0700)
Instead of dynamically testing if the ExtentsResource is held
and if not acquire it within AFSMarkDirty(), simply require that
it be held.  AFSMarkDirty() is only called from one location.

Change-Id: If30fc05fead4c9e0604555239e9b862659de3e8b
Reviewed-on: http://gerrit.openafs.org/8304
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp

index a5c2984..3862c61 100644 (file)
@@ -3363,7 +3363,6 @@ AFSMarkDirty( IN AFSFcb *Fcb,
     ULONG ulCount = 0;
     BOOLEAN bInsertTail = FALSE, bInsertHead = FALSE;
     LONG lCount;
-    BOOLEAN bLocked = FALSE;
 
     AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
                   AFS_TRACE_LEVEL_VERBOSE,
@@ -3371,11 +3370,7 @@ AFSMarkDirty( IN AFSFcb *Fcb,
                   &Fcb->NPFcb->Specific.File.ExtentsResource,
                   PsGetCurrentThread());
 
-    if( !ExIsResourceAcquiredLite( &Fcb->NPFcb->Specific.File.ExtentsResource))
-    {
-        AFSAcquireShared( &Fcb->NPFcb->Specific.File.ExtentsResource, TRUE);
-        bLocked = TRUE;
-    }
+    ASSERT( ExIsResourceAcquiredLite( &pNPFcb->Specific.File.ExtentsResource));
 
     AFSAcquireExcl( &pNPFcb->Specific.File.DirtyExtentsListLock,
                     TRUE);
@@ -3537,11 +3532,6 @@ AFSMarkDirty( IN AFSFcb *Fcb,
                   &Fcb->NPFcb->Specific.File.ExtentsResource,
                   PsGetCurrentThread());
 
-    if( bLocked)
-    {
-        AFSReleaseResource( &Fcb->NPFcb->Specific.File.ExtentsResource );
-    }
-
     return;
 }
 
index 6f528b4..b5232b4 100644 (file)
@@ -1301,6 +1301,14 @@ try_exit:
             Irp->IoStatus.Information > 0)
         {
 
+           if ( !bLocked)
+           {
+
+               AFSAcquireShared( &pFcb->NPFcb->Specific.File.ExtentsResource,
+                                 TRUE);
+               bLocked = TRUE;
+           }
+
             //
             // Since this is dirty we can mark the extents dirty now.
             // AFSMarkDirty will dereference the extents.  Do not call