]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not swap out already swapped out objects.
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 25 Feb 2012 04:20:25 +0000 (21:20 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 25 Feb 2012 04:20:25 +0000 (21:20 -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 7428775780bf3f19a8580ff349624e71728a7874..278142633433c1368d07607d95418b0c5179c1c9 100644 (file)
@@ -363,6 +363,7 @@ StoreEntry::mayStartSwapOut()
 
     // must be checked in the caller
     assert(!EBIT_TEST(flags, ENTRY_ABORTED));
+    assert(!swappingOut());
 
     if (!Config.cacheSwap.n_configured)
         return false;
@@ -382,11 +383,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()) {