Windows: Adjust extent release strategy
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 26 May 2012 22:11:06 +0000 (18:11 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 6 Jun 2012 15:06:44 +0000 (08:06 -0700)
All extents were flushed whenever AFSReleaseExtentsWithFlush was
executed.  This included a call at the completion of each
NonCached Read operation which could result in heavy thrashing
as the data would be released prior to it being needed by the
application.

This patchset makes the following adjustments.  First,
AFSReleaseExtentsWithFlush() has been modified to release all
but 1024 extents belonging to the file.  Second, NonCached Reads
only execute AFSReleaseExtentsWithFlush() when there are more
than 4096 extents associated with the file.  Third,
AFSReleaseExtentsWithFlush() now has a 'bReleaseAll' parameter
which is used for calls from AFSCleanup() and AFSFlushExtents()
which need to be able to flush all extents attached to a FCB.

Change-Id: Id8b05f02c59eb46b1881e4d905a511a2597455e8
Reviewed-on: http://gerrit.openafs.org/7520
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp
src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSFlushBuffers.cpp
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/AFSRead.cpp
src/WINNT/afsrdr/kernel/lib/AFSWorker.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h

index fc6af33..28d4ffc 100644 (file)
@@ -557,6 +557,9 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                         AFSWaitOnQueuedFlushes( pFcb);
 
                         ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE;
+
+                        AFSTearDownFcbExtents( pFcb,
+                                               &pCcb->AuthGroup);
                     }
 
                     //
index b90915b..6d503d4 100644 (file)
@@ -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)
index d868a49..eedfd9a 100644 (file)
@@ -126,7 +126,8 @@ AFSFlushBuffers( IN PDEVICE_OBJECT LibDeviceObject,
         {
 
             AFSReleaseExtentsWithFlush( pFcb,
-                                        &pCcb->AuthGroup);
+                                        &pCcb->AuthGroup,
+                                        TRUE);
 
             ntStatus = STATUS_SUCCESS;
         }
index a8804f6..ac81d7c 100644 (file)
@@ -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);
             }
         }
 
index 1e8dbb9..775c9aa 100644 (file)
@@ -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:
 
index 2af9c67..9239c40 100644 (file)
@@ -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);
index 0b66669..ffe1754 100644 (file)
@@ -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,