From: Alex Rousskov Date: Fri, 10 Feb 2012 00:01:17 +0000 (-0700) Subject: Do not swap out swapped out objects. X-Git-Tag: BumpSslServerFirst.take05~12^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4094b3119426b9b4924b150bb36fdb0ee1d73880;p=thirdparty%2Fsquid.git Do not swap out swapped out objects. 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. --- diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 7e896c5ca0..832a543d36 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -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()) {