From 48b51b4ac78990faf0d5ab921a01b6470d295a63 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Fri, 24 Feb 2012 21:20:25 -0700 Subject: [PATCH] Do not swap out already 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. --- src/store_swapout.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 7428775780..2781426334 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -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()) { -- 2.47.2