From: Alex Date: Tue, 5 Dec 2023 05:56:12 +0000 (+0000) Subject: Remove unnecessary checks for nil Store::Controller::swapDir (#1606) X-Git-Tag: SQUID_7_0_1~267 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e305d7716a2170d0a304e27715209fb00d60a70e;p=thirdparty%2Fsquid.git Remove unnecessary checks for nil Store::Controller::swapDir (#1606) ... and renamed that data member. No functionality changes expected. --- diff --git a/src/store/Controller.cc b/src/store/Controller.cc index 66147a63e0..9507a6d11a 100644 --- a/src/store/Controller.cc +++ b/src/store/Controller.cc @@ -33,7 +33,7 @@ int Store::Controller::store_dirs_rebuilding = 1; Store::Controller::Controller() : - swapDir(new Disks), + disks(new Disks), sharedMemStore(nullptr), localMemStore(false), transients(nullptr) @@ -45,7 +45,7 @@ Store::Controller::~Controller() { delete sharedMemStore; delete transients; - delete swapDir; + delete disks; if (store_table) { hashFreeItems(store_table, destroyStoreEntry); @@ -66,7 +66,7 @@ Store::Controller::init() } } - swapDir->init(); + disks->init(); if (Transients::Enabled() && IamWorkerProcess()) { transients = new Transients; @@ -77,7 +77,7 @@ Store::Controller::init() void Store::Controller::create() { - swapDir->create(); + disks->create(); #if !_SQUID_WINDOWS_ pid_t pid; @@ -93,7 +93,7 @@ Store::Controller::maintain() { static time_t last_warn_time = 0; - swapDir->maintain(); + disks->maintain(); /* this should be emitted by the oversize dir, not globally */ @@ -126,7 +126,7 @@ Store::Controller::getStats(StoreInfoStats &stats) const } } - swapDir->getStats(stats); + disks->getStats(stats); // low-level info not specific to memory or disk cache stats.store_entry_count = StoreEntry::inUseCount(); @@ -150,8 +150,7 @@ Store::Controller::stat(StoreEntry &output) const if (sharedMemStore) sharedMemStore->stat(output); - /* now the swapDir */ - swapDir->stat(output); + disks->stat(output); } /* if needed, this could be taught to cache the result */ @@ -159,41 +158,41 @@ uint64_t Store::Controller::maxSize() const { /* TODO: include memory cache ? */ - return swapDir->maxSize(); + return disks->maxSize(); } uint64_t Store::Controller::minSize() const { /* TODO: include memory cache ? */ - return swapDir->minSize(); + return disks->minSize(); } uint64_t Store::Controller::currentSize() const { /* TODO: include memory cache ? */ - return swapDir->currentSize(); + return disks->currentSize(); } uint64_t Store::Controller::currentCount() const { /* TODO: include memory cache ? */ - return swapDir->currentCount(); + return disks->currentCount(); } int64_t Store::Controller::maxObjectSize() const { /* TODO: include memory cache ? */ - return swapDir->maxObjectSize(); + return disks->maxObjectSize(); } void Store::Controller::configure() { - swapDir->configure(); + disks->configure(); store_swap_high = (long) (((float) maxSize() * (float) Config.Swap.highWaterMark) / (float) 100); @@ -203,7 +202,7 @@ Store::Controller::configure() // TODO: move this into a memory cache class when we have one const int64_t memMax = static_cast(min(Config.Store.maxInMemObjSize, Config.memMaxSize)); - const int64_t disksMax = swapDir ? swapDir->maxObjectSize() : 0; + const int64_t disksMax = disks->maxObjectSize(); store_maxobjsize = std::max(disksMax, memMax); } @@ -219,7 +218,7 @@ Store::Controller::sync(void) { if (sharedMemStore) sharedMemStore->sync(); - swapDir->sync(); + disks->sync(); } /* @@ -229,7 +228,7 @@ int Store::Controller::callback() { /* mem cache callbacks ? */ - return swapDir->callback(); + return disks->callback(); } /// update reference counters of the recently touched entry @@ -243,7 +242,7 @@ Store::Controller::referenceBusy(StoreEntry &e) /* Notify the fs that we're referencing this object again */ if (e.hasDisk()) - swapDir->reference(e); + disks->reference(e); // Notify the memory cache that we're referencing this object again if (sharedMemStore && e.mem_status == IN_MEMORY) @@ -275,7 +274,7 @@ Store::Controller::dereferenceIdle(StoreEntry &e, bool wantsLocalMemory) // should be done even if we overwrite keepInStoreTable afterwards. if (e.hasDisk()) - keepInStoreTable = swapDir->dereference(e) || keepInStoreTable; + keepInStoreTable = disks->dereference(e) || keepInStoreTable; // Notify the memory cache that we're not referencing this object any more if (sharedMemStore && e.mem_status == IN_MEMORY) @@ -320,7 +319,7 @@ Store::Controller::markedForDeletionAndAbandoned(const StoreEntry &e) const bool Store::Controller::hasReadableDiskEntry(const StoreEntry &e) const { - return swapDir->hasReadableEntry(e); + return disks->hasReadableEntry(e); } /// flags problematic entries before find() commits to finalizing/returning them @@ -453,11 +452,9 @@ Store::Controller::peek(const cache_key *key) } } - if (swapDir) { - if (StoreEntry *e = swapDir->get(key)) { - debugs(20, 3, "got disk-cached entry: " << *e); - return e; - } + if (const auto e = disks->get(key)) { + debugs(20, 3, "got disk-cached entry: " << *e); + return e; } debugs(20, 4, "cannot locate " << storeKeyText(key)); @@ -479,7 +476,7 @@ Store::Controller::transientsWriter(const StoreEntry &e) const int64_t Store::Controller::accumulateMore(StoreEntry &entry) const { - return swapDir ? swapDir->accumulateMore(entry) : 0; + return disks->accumulateMore(entry); // The memory cache should not influence for-swapout accumulation decision. } @@ -493,8 +490,7 @@ Store::Controller::evictCached(StoreEntry &e) if (transients) transients->evictCached(e); memoryEvictCached(e); - if (swapDir) - swapDir->evictCached(e); + disks->evictCached(e); } void @@ -510,8 +506,9 @@ Store::Controller::evictIfFound(const cache_key *key) if (sharedMemStore) sharedMemStore->evictIfFound(key); - if (swapDir) - swapDir->evictIfFound(key); + + disks->evictIfFound(key); + if (transients) transients->evictIfFound(key); } @@ -726,7 +723,7 @@ Store::Controller::updateOnNotModified(StoreEntry *old, StoreEntry &e304) sharedMemStore->updateHeaders(old); if (old->swap_dirn > -1) - swapDir->updateHeaders(old); + disks->updateHeaders(old); return true; } @@ -818,9 +815,9 @@ Store::Controller::syncCollapsed(const sfileno xitIndex) found = true; inSync = sharedMemStore->updateAnchored(*collapsed); // TODO: handle entries attached to both memory and disk - } else if (swapDir && collapsed->hasDisk()) { + } else if (collapsed->hasDisk()) { found = true; - inSync = swapDir->updateAnchored(*collapsed); + inSync = disks->updateAnchored(*collapsed); } else { try { found = anchorToCache(*collapsed); @@ -883,7 +880,7 @@ Store::Controller::anchorToCache(StoreEntry &entry) } else if (sharedMemStore && entry.hasMemStore()) { debugs(20, 5, "already anchored to memory store: " << entry); return true; - } else if (swapDir && entry.hasDisk()) { + } else if (entry.hasDisk()) { debugs(20, 5, "already anchored to disk: " << entry); return true; } @@ -896,8 +893,8 @@ Store::Controller::anchorToCache(StoreEntry &entry) bool found = false; if (sharedMemStore) found = sharedMemStore->anchorToCache(entry); - if (!found && swapDir) - found = swapDir->anchorToCache(entry); + if (!found) + found = disks->anchorToCache(entry); if (found) { debugs(20, 7, "anchored " << entry); diff --git a/src/store/Controller.h b/src/store/Controller.h index dbac1ced61..8f46fd323f 100644 --- a/src/store/Controller.h +++ b/src/store/Controller.h @@ -149,7 +149,7 @@ private: void checkTransients(const StoreEntry &) const; void checkFoundCandidate(const StoreEntry &) const; - Disks *swapDir; ///< summary view of all disk caches + Disks *disks; ///< summary view of all disk caches (including none); never nil Memory *sharedMemStore; ///< memory cache that multiple workers can use bool localMemStore; ///< whether local (non-shared) memory cache is enabled