From a48f1beba06762a67665ac5d58318a6661bd0d91 Mon Sep 17 00:00:00 2001 From: Shailesh Date: Fri, 13 Dec 2024 09:35:27 +0000 Subject: [PATCH] Maintenance: Remove change-minimizing MemObject::Io hack (#1957) Added in 2018 commit 4310f8b0. --- src/MemObject.h | 13 +++---------- src/MemStore.cc | 27 ++++++++++++++------------- src/store/Controller.cc | 5 +++-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/MemObject.h b/src/MemObject.h index 4479e402995..5a6caadb64e 100644 --- a/src/MemObject.h +++ b/src/MemObject.h @@ -168,19 +168,12 @@ class MemObject SwapOut swapout; - /* TODO: Remove this change-minimizing hack */ - using Io = Store::IoStatus; - static constexpr Io ioUndecided = Store::ioUndecided; - static constexpr Io ioReading = Store::ioReading; - static constexpr Io ioWriting = Store::ioWriting; - static constexpr Io ioDone = Store::ioDone; - /// State of an entry with regards to the [shared] in-transit table. class XitTable { public: /// associate our StoreEntry with a Transients entry at the given index - void open(const int32_t anIndex, const Io anIo) + void open(const int32_t anIndex, const Store::IoStatus anIo) { index = anIndex; io = anIo; @@ -194,7 +187,7 @@ class MemObject } int32_t index = -1; ///< entry position inside the in-transit table - Io io = ioUndecided; ///< current I/O state + Store::IoStatus io = Store::ioUndecided; ///< current I/O state }; XitTable xitTable; ///< current [shared] memory caching state for the entry @@ -205,7 +198,7 @@ class MemObject int32_t index = -1; ///< entry position inside the memory cache int64_t offset = 0; ///< bytes written/read to/from the memory cache so far - Io io = ioUndecided; ///< current I/O state + Store::IoStatus io = Store::ioUndecided; ///< current I/O state }; MemCache memCache; ///< current [shared] memory caching state for the entry diff --git a/src/MemStore.cc b/src/MemStore.cc index 3cbb8bc2d47..0ed1bf61bb5 100644 --- a/src/MemStore.cc +++ b/src/MemStore.cc @@ -21,6 +21,7 @@ #include "sbuf/Stream.h" #include "SquidConfig.h" #include "SquidMath.h" +#include "store/forward.h" #include "StoreStats.h" #include "tools.h" @@ -401,7 +402,7 @@ bool MemStore::anchorToCache(StoreEntry &entry) { Assure(!entry.hasMemStore()); - Assure(entry.mem().memCache.io != MemObject::ioDone); + Assure(entry.mem().memCache.io != Store::ioDone); if (!map) return false; @@ -462,7 +463,7 @@ MemStore::anchorEntry(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnc MemObject::MemCache &mc = e.mem_obj->memCache; mc.index = index; - mc.io = MemObject::ioReading; + mc.io = Store::ioReading; } /// copies the entire entry from shared to local memory @@ -656,7 +657,7 @@ MemStore::startCaching(StoreEntry &e) assert(e.mem_obj); e.mem_obj->memCache.index = index; - e.mem_obj->memCache.io = MemObject::ioWriting; + e.mem_obj->memCache.io = Store::ioWriting; slot->set(e); // Do not allow others to feed off an unknown-size entry because we will // stop swapping it out if it grows too large. @@ -850,19 +851,19 @@ MemStore::write(StoreEntry &e) debugs(20, 7, "entry " << e); switch (e.mem_obj->memCache.io) { - case MemObject::ioUndecided: + case Store::ioUndecided: if (!shouldCache(e) || !startCaching(e)) { - e.mem_obj->memCache.io = MemObject::ioDone; + e.mem_obj->memCache.io = Store::ioDone; e.memOutDecision(false); return; } break; - case MemObject::ioDone: - case MemObject::ioReading: + case Store::ioDone: + case Store::ioReading: return; // we should not write in all of the above cases - case MemObject::ioWriting: + case Store::ioWriting: break; // already decided to write and still writing } @@ -892,7 +893,7 @@ MemStore::completeWriting(StoreEntry &e) debugs(20, 5, "mem-cached all " << e.mem_obj->memCache.offset << " bytes of " << e); e.mem_obj->memCache.index = -1; - e.mem_obj->memCache.io = MemObject::ioDone; + e.mem_obj->memCache.io = Store::ioDone; map->closeForWriting(index); CollapsedForwarding::Broadcast(e); @@ -931,17 +932,17 @@ MemStore::disconnect(StoreEntry &e) assert(e.mem_obj); MemObject &mem_obj = *e.mem_obj; if (e.hasMemStore()) { - if (mem_obj.memCache.io == MemObject::ioWriting) { + if (mem_obj.memCache.io == Store::ioWriting) { map->abortWriting(mem_obj.memCache.index); mem_obj.memCache.index = -1; - mem_obj.memCache.io = MemObject::ioDone; + mem_obj.memCache.io = Store::ioDone; CollapsedForwarding::Broadcast(e); e.storeWriterDone(); } else { - assert(mem_obj.memCache.io == MemObject::ioReading); + assert(mem_obj.memCache.io == Store::ioReading); map->closeForReading(mem_obj.memCache.index); mem_obj.memCache.index = -1; - mem_obj.memCache.io = MemObject::ioDone; + mem_obj.memCache.io = Store::ioDone; } } } diff --git a/src/store/Controller.cc b/src/store/Controller.cc index b9dac9bad6d..c18fdf0a8fb 100644 --- a/src/store/Controller.cc +++ b/src/store/Controller.cc @@ -15,6 +15,7 @@ #include "SquidMath.h" #include "store/Controller.h" #include "store/Disks.h" +#include "store/forward.h" #include "store/LocalSearch.h" #include "tools.h" #include "Transients.h" @@ -801,7 +802,7 @@ Store::Controller::syncCollapsed(const sfileno xitIndex) bool found = false; bool inSync = false; - if (sharedMemStore && collapsed->mem_obj->memCache.io == MemObject::ioDone) { + if (sharedMemStore && collapsed->mem_obj->memCache.io == Store::ioDone) { found = true; inSync = true; debugs(20, 7, "already handled by memory store: " << *collapsed); @@ -868,7 +869,7 @@ Store::Controller::anchorToCache(StoreEntry &entry) // TODO: Attach entries to both memory and disk // TODO: Reduce code duplication with syncCollapsed() - if (sharedMemStore && entry.mem().memCache.io == MemObject::ioDone) { + if (sharedMemStore && entry.mem().memCache.io == Store::ioDone) { debugs(20, 5, "already handled by memory store: " << entry); return true; } else if (sharedMemStore && entry.hasMemStore()) {