Skip to content

Commit

Permalink
Maintenance: Remove change-minimizing MemObject::Io hack (#1957)
Browse files Browse the repository at this point in the history
Added in 2018 commit 4310f8b.
  • Loading branch information
vshailesh authored and squid-anubis committed Dec 13, 2024
1 parent b615353 commit a48f1be
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
13 changes: 3 additions & 10 deletions src/MemObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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

Expand Down
27 changes: 14 additions & 13 deletions src/MemStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "sbuf/Stream.h"
#include "SquidConfig.h"
#include "SquidMath.h"
#include "store/forward.h"
#include "StoreStats.h"
#include "tools.h"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/store/Controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit a48f1be

Please sign in to comment.