]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not swap out swapped out objects.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 10 Feb 2012 00:01:17 +0000 (17:01 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 10 Feb 2012 00:01:17 +0000 (17:01 -0700)
I noticed that sometimes Squid would start swapping out an entry that was
recently loaded from disk and was still on disk. That wastes disk
resources (at best).

The old StoreEntry::mayStartSwapOut() code assumed that when swap_status is
not SWAPOUT_NONE it is SWAPOUT_WRITING, but SWAPOUT_WRITING is impossible
after recent StoreEntry::swapOut() modifications because mayStartSwapOut() is
only called when we are not swappingOut() already. SWAPOUT_DONE is possible.

src/store_swapout.cc

index 7e896c5ca023dbc6958788e8c784fa5f72fdbe15..832a543d362ec1369b0a7d0fe0a9b061c0294152 100644 (file)
@@ -364,6 +364,7 @@ StoreEntry::mayStartSwapOut()
 
     // must be checked in the caller
     assert(!EBIT_TEST(flags, ENTRY_ABORTED));
+    assert(!swappingOut());
 
     if (!Config.cacheSwap.n_configured)
         return false;
@@ -383,11 +384,11 @@ StoreEntry::mayStartSwapOut()
         return true;
     }
 
-    // if we are swapping out already, do not repeat same checks
-    if (swap_status != SWAPOUT_NONE) {
-        debugs(20, 3,  HERE << " already started");
-        decision = MemObject::SwapOut::swPossible;
-        return true;
+    // if we swapped out already, do not start over
+    if (swap_status == SWAPOUT_DONE) {
+        debugs(20, 3,  HERE << "already did");
+        decision = MemObject::SwapOut::swImpossible;
+        return false;
     }
 
     if (!checkCachable()) {