]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Maintenance: Remove change-minimizing MemObject::Io hack (#1957)
authorShailesh <shavashishth@gmail.com>
Fri, 13 Dec 2024 09:35:27 +0000 (09:35 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 13 Dec 2024 13:54:50 +0000 (13:54 +0000)
Added in 2018 commit 4310f8b0.

src/MemObject.h
src/MemStore.cc
src/store/Controller.cc

index 4479e4029951afdf39877559e5415102f7ada106..5a6caadb64e0ebc2219b2b1f392673c84b8dce7c 100644 (file)
@@ -168,19 +168,12 @@ public:
 
     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 @@ public:
         }
 
         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 @@ public:
         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
 
index 3cbb8bc2d479b595985e322eb9da449b137c4dde..0ed1bf61bb5b4dd5ace152b408927c0778622dc6 100644 (file)
@@ -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;
         }
     }
 }
index b9dac9bad6d1c1547cb350419b2c24f7ef7faedb..c18fdf0a8fb1c06230f050329ab1c157e71c5ce9 100644 (file)
@@ -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()) {