Windows: AFSTearDownFcbExtents loop conditional
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 21 Jul 2012 16:17:46 +0000 (12:17 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Sun, 22 Jul 2012 03:20:48 +0000 (20:20 -0700)
If there are extents in the list with a non-zero ActiveCount,
those extents will be skipped and the list 'le' will never
become empty.  Add an additional condition to ensure that the
loop is only executed once for each extent in the list.

Change-Id: I48adf7c49282181d0a34135ac50f7fa1a165c735
Reviewed-on: http://gerrit.openafs.org/7810
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

index 16621da..3e5b68e 100644 (file)
@@ -150,8 +150,8 @@ AFSTearDownFcbExtents( IN AFSFcb *Fcb,
     AFSNonPagedFcb      *pNPFcb = Fcb->NPFcb;
     LIST_ENTRY          *le, *leNext;
     AFSExtent           *pEntry;
-    LONG                 lExtentCount = 0;
-    ULONG                ulReleaseCount = 0, ulProcessCount = 0;
+    LONG                 lExtentCount = 0, lProcessCount = 0;
+    ULONG                ulReleaseCount = 0;
     size_t               sz;
     AFSReleaseExtentsCB *pRelease = NULL;
     BOOLEAN              locked = FALSE;
@@ -217,16 +217,18 @@ AFSTearDownFcbExtents( IN AFSFcb *Fcb,
         for( le = Fcb->Specific.File.ExtentsLists[AFS_EXTENTS_LIST].Flink,
              lExtentCount = 0;
              lExtentCount < Fcb->Specific.File.ExtentCount;
-             lExtentCount += ulProcessCount)
+             lExtentCount += lProcessCount)
         {
 
             RtlZeroMemory( pRelease,
                            sizeof( AFSReleaseExtentsCB ) +
                            (AFS_MAXIMUM_EXTENT_RELEASE_COUNT * sizeof ( AFSFileExtentCB )));
 
-            for( ulProcessCount = 0, ulReleaseCount = 0;
-                 !IsListEmpty( le) && ulReleaseCount < AFS_MAXIMUM_EXTENT_RELEASE_COUNT;
-                 ulProcessCount++, le = leNext)
+            for( lProcessCount = 0, ulReleaseCount = 0;
+                 !IsListEmpty( le) &&
+                 ulReleaseCount < AFS_MAXIMUM_EXTENT_RELEASE_COUNT &&
+                 lExtentCount + lProcessCount < Fcb->Specific.File.ExtentCount;
+                 lProcessCount++, le = leNext)
             {
 
                 leNext = le->Flink;
@@ -310,7 +312,7 @@ AFSTearDownFcbExtents( IN AFSFcb *Fcb,
                 // request would be a corruption.
                 //
 
-                sz = sizeof( AFSReleaseExtentsCB ) + (ulProcessCount * sizeof ( AFSFileExtentCB ));
+                sz = sizeof( AFSReleaseExtentsCB ) + (lProcessCount * sizeof ( AFSFileExtentCB ));
 
                 ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_RELEASE_FILE_EXTENTS,
                                               AFS_REQUEST_FLAG_SYNCHRONOUS,