mirror of
https://github.com/squid-cache/squid.git
synced 2025-04-18 22:04:07 +03:00
Fix GCC v13 LTO build [-Walloc-size-larger-than=] (#1929)
store/Disks.cc:690: error: argument 1 value 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=] const auto tmp = new SwapDir::Pointer[swap->n_allocated]; pconn.cc:43:53: error: argument 1 value 18446744073709551615 ... theList_ = new Comm::ConnectionPointer[capacity_]; Tested on Ubuntu 24.04 and GCC v13.2.0.
This commit is contained in:
parent
28a2ea0ded
commit
91d1cfb180
@ -288,6 +288,7 @@ Thank you!
|
||||
JPP <jpp1@frws.com>
|
||||
Juan <jdsq12@yahoo.es>
|
||||
Juerg Michel
|
||||
Juju4 <juju4@users.noreply.github.com>
|
||||
Julien Pinon <jpinon@olfeo.com>
|
||||
Karl Benoit <karl.isatwork@gmail.com>
|
||||
Khalid Abdullah <khalidcomilla58@gmail.com>
|
||||
|
@ -113,7 +113,7 @@ void aioRead(int, off_t offset, size_t size, AIOCB *, void *);
|
||||
|
||||
void aioStat(char *, struct stat *, AIOCB *, void *);
|
||||
void aioUnlink(const char *, AIOCB *, void *);
|
||||
int aioQueueSize(void);
|
||||
size_t aioQueueSize(void);
|
||||
|
||||
#include "DiskIO/DiskFile.h"
|
||||
|
||||
|
@ -118,7 +118,7 @@ static Mem::Allocator *squidaio_small_bufs = nullptr; /* 4K */
|
||||
static Mem::Allocator *squidaio_tiny_bufs = nullptr; /* 2K */
|
||||
static Mem::Allocator *squidaio_micro_bufs = nullptr; /* 128K */
|
||||
|
||||
static int request_queue_len = 0;
|
||||
static size_t request_queue_len = 0;
|
||||
static Mem::Allocator *squidaio_request_pool = nullptr;
|
||||
static Mem::Allocator *squidaio_thread_pool = nullptr;
|
||||
static squidaio_request_queue_t request_queue;
|
||||
@ -215,7 +215,6 @@ squidaio_xstrfree(char *str)
|
||||
void
|
||||
squidaio_init(void)
|
||||
{
|
||||
int i;
|
||||
squidaio_thread_t *threadp;
|
||||
|
||||
if (squidaio_initialised)
|
||||
@ -294,7 +293,7 @@ squidaio_init(void)
|
||||
|
||||
assert(NUMTHREADS != 0);
|
||||
|
||||
for (i = 0; i < NUMTHREADS; ++i) {
|
||||
for (size_t i = 0; i < NUMTHREADS; ++i) {
|
||||
threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
|
||||
threadp->status = _THREAD_STARTING;
|
||||
threadp->current_req = nullptr;
|
||||
@ -515,7 +514,7 @@ squidaio_queue_request(squidaio_request_t * request)
|
||||
/* Warn if out of threads */
|
||||
if (request_queue_len > MAGIC1) {
|
||||
static int last_warn = 0;
|
||||
static int queue_high, queue_low;
|
||||
static size_t queue_high, queue_low;
|
||||
|
||||
if (high_start == 0) {
|
||||
high_start = squid_curtime;
|
||||
@ -999,7 +998,6 @@ void
|
||||
squidaio_stats(StoreEntry * sentry)
|
||||
{
|
||||
squidaio_thread_t *threadp;
|
||||
int i;
|
||||
|
||||
if (!squidaio_initialised)
|
||||
return;
|
||||
@ -1010,8 +1008,8 @@ squidaio_stats(StoreEntry * sentry)
|
||||
|
||||
threadp = threads;
|
||||
|
||||
for (i = 0; i < NUMTHREADS; ++i) {
|
||||
storeAppendPrintf(sentry, "%i\t0x%lx\t%ld\n", i + 1, (unsigned long)threadp->thread, threadp->requests);
|
||||
for (size_t i = 0; i < NUMTHREADS; ++i) {
|
||||
storeAppendPrintf(sentry, "%zu\t0x%lx\t%ld\n", i + 1, (unsigned long)threadp->thread, threadp->requests);
|
||||
threadp = threadp->next;
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ aioUnlink(const char *path, AIOCB * callback, void *callback_data)
|
||||
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
|
||||
} /* aioUnlink */
|
||||
|
||||
int
|
||||
size_t
|
||||
aioQueueSize(void)
|
||||
{
|
||||
return squidaio_ctrl_t::UseCount();
|
||||
|
@ -66,8 +66,8 @@ public:
|
||||
~DiskConfig() { delete[] swapDirs; }
|
||||
|
||||
RefCount<SwapDir> *swapDirs = nullptr;
|
||||
int n_allocated = 0;
|
||||
int n_configured = 0;
|
||||
size_t n_allocated = 0;
|
||||
size_t n_configured = 0;
|
||||
/// number of disk processes required to support all cache_dirs
|
||||
int n_strands = 0;
|
||||
};
|
||||
|
@ -81,7 +81,7 @@ Auth::SchemeConfig::registerWithCacheManager(void)
|
||||
{}
|
||||
|
||||
void
|
||||
Auth::SchemeConfig::parse(Auth::SchemeConfig * scheme, int, char *param_str)
|
||||
Auth::SchemeConfig::parse(Auth::SchemeConfig * scheme, size_t, char *param_str)
|
||||
{
|
||||
if (strcmp(param_str, "program") == 0) {
|
||||
if (authenticateProgram)
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
virtual void registerWithCacheManager(void);
|
||||
|
||||
/** parse config options */
|
||||
virtual void parse(SchemeConfig *, int, char *);
|
||||
virtual void parse(SchemeConfig *, size_t, char *);
|
||||
|
||||
/** the http string id */
|
||||
virtual const char * type() const = 0;
|
||||
|
@ -135,7 +135,7 @@ Auth::Basic::Config::Config() :
|
||||
}
|
||||
|
||||
void
|
||||
Auth::Basic::Config::parse(Auth::SchemeConfig * scheme, int n_configured, char *param_str)
|
||||
Auth::Basic::Config::parse(Auth::SchemeConfig * scheme, size_t n_configured, char *param_str)
|
||||
{
|
||||
if (strcmp(param_str, "credentialsttl") == 0) {
|
||||
parse_time_t(&credentialsTTL);
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
bool dump(StoreEntry *, const char *, Auth::SchemeConfig *) const override;
|
||||
void fixHeader(Auth::UserRequest::Pointer, HttpReply *, Http::HdrType, HttpRequest *) override;
|
||||
void init(Auth::SchemeConfig *) override;
|
||||
void parse(Auth::SchemeConfig *, int, char *) override;
|
||||
void parse(Auth::SchemeConfig *, size_t, char *) override;
|
||||
void decode(char const *httpAuthHeader, Auth::UserRequest::Pointer);
|
||||
void registerWithCacheManager(void) override;
|
||||
const char * type() const override;
|
||||
|
@ -577,7 +577,7 @@ Auth::Digest::Config::Config() :
|
||||
{}
|
||||
|
||||
void
|
||||
Auth::Digest::Config::parse(Auth::SchemeConfig * scheme, int n_configured, char *param_str)
|
||||
Auth::Digest::Config::parse(Auth::SchemeConfig * scheme, size_t n_configured, char *param_str)
|
||||
{
|
||||
if (strcmp(param_str, "nonce_garbage_interval") == 0) {
|
||||
parse_time_t(&nonceGCInterval);
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
bool dump(StoreEntry *, const char *, Auth::SchemeConfig *) const override;
|
||||
void fixHeader(Auth::UserRequest::Pointer, HttpReply *, Http::HdrType, HttpRequest *) override;
|
||||
void init(Auth::SchemeConfig *) override;
|
||||
void parse(Auth::SchemeConfig *, int, char *) override;
|
||||
void parse(Auth::SchemeConfig *, size_t, char *) override;
|
||||
void registerWithCacheManager(void) override;
|
||||
const char * type() const override;
|
||||
|
||||
|
@ -1118,7 +1118,7 @@ DefineRunnerRegistratorIn(Rock, SwapDirRr);
|
||||
void Rock::SwapDirRr::create()
|
||||
{
|
||||
Must(mapOwners.empty() && freeSlotsOwners.empty());
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (const Rock::SwapDir *const sd = dynamic_cast<Rock::SwapDir *>(INDEXSD(i))) {
|
||||
rebuildStatsOwners.push_back(Rebuild::Stats::Init(*sd));
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
int Fs::Ufs::UFSSwapDir::NumberOfUFSDirs = 0;
|
||||
size_t Fs::Ufs::UFSSwapDir::NumberOfUFSDirs = 0;
|
||||
int *Fs::Ufs::UFSSwapDir::UFSDirToGlobalDirMapping = nullptr;
|
||||
|
||||
class UFSCleanLog : public SwapDir::CleanLog
|
||||
@ -757,8 +757,8 @@ Fs::Ufs::UFSSwapDir::closeLog()
|
||||
if (swaplog_fd < 0) /* not open */
|
||||
return;
|
||||
|
||||
assert(NumberOfUFSDirs > 0);
|
||||
--NumberOfUFSDirs;
|
||||
assert(NumberOfUFSDirs >= 0);
|
||||
if (!NumberOfUFSDirs)
|
||||
safe_free(UFSDirToGlobalDirMapping);
|
||||
|
||||
@ -1039,9 +1039,8 @@ int
|
||||
Fs::Ufs::UFSSwapDir::HandleCleanEvent()
|
||||
{
|
||||
static int swap_index = 0;
|
||||
int i;
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
size_t n = 0;
|
||||
|
||||
if (!NumberOfUFSDirs)
|
||||
return 0; // probably in the middle of reconfiguration
|
||||
@ -1054,7 +1053,7 @@ Fs::Ufs::UFSSwapDir::HandleCleanEvent()
|
||||
*/
|
||||
UFSDirToGlobalDirMapping = (int *)xcalloc(NumberOfUFSDirs, sizeof(*UFSDirToGlobalDirMapping));
|
||||
|
||||
for (i = 0, n = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
/* This is bogus, the controller should just clean each instance once */
|
||||
sd = dynamic_cast <SwapDir *>(INDEXSD(i));
|
||||
|
||||
@ -1117,7 +1116,8 @@ Fs::Ufs::UFSSwapDir::FilenoBelongsHere(int fn, int F0, int F1, int F2)
|
||||
int D1, D2;
|
||||
int L1, L2;
|
||||
int filn = fn;
|
||||
assert(F0 < Config.cacheSwap.n_configured);
|
||||
assert(F0 >= 0);
|
||||
assert(static_cast<size_t>(F0) < Config.cacheSwap.n_configured);
|
||||
assert (UFSSwapDir::IsUFSDir (dynamic_cast<SwapDir *>(INDEXSD(F0))));
|
||||
UFSSwapDir *sd = dynamic_cast<UFSSwapDir *>(INDEXSD(F0));
|
||||
|
||||
|
@ -123,7 +123,7 @@ protected:
|
||||
|
||||
private:
|
||||
void parseSizeL1L2();
|
||||
static int NumberOfUFSDirs;
|
||||
static size_t NumberOfUFSDirs;
|
||||
static int * UFSDirToGlobalDirMapping;
|
||||
bool pathIsDirectory(const char *path)const;
|
||||
int swaplog_fd;
|
||||
|
24
src/pconn.cc
24
src/pconn.cc
@ -73,7 +73,8 @@ IdleConnList::~IdleConnList()
|
||||
int
|
||||
IdleConnList::findIndexOf(const Comm::ConnectionPointer &conn) const
|
||||
{
|
||||
for (int index = size_ - 1; index >= 0; --index) {
|
||||
for (auto right = size_; right > 0; --right) {
|
||||
const auto index = right - 1;
|
||||
if (conn->fd == theList_[index]->fd) {
|
||||
debugs(48, 3, "found " << conn << " at index " << index);
|
||||
return index;
|
||||
@ -89,10 +90,11 @@ IdleConnList::findIndexOf(const Comm::ConnectionPointer &conn) const
|
||||
* \retval false The index is not an in-use entry.
|
||||
*/
|
||||
bool
|
||||
IdleConnList::removeAt(int index)
|
||||
IdleConnList::removeAt(size_t index)
|
||||
{
|
||||
if (index < 0 || index >= size_)
|
||||
if (index >= size_)
|
||||
return false;
|
||||
assert(size_ > 0);
|
||||
|
||||
// shuffle the remaining entries to fill the new gap.
|
||||
for (; index < size_ - 1; ++index)
|
||||
@ -112,12 +114,12 @@ IdleConnList::removeAt(int index)
|
||||
|
||||
// almost a duplicate of removeFD. But drops multiple entries.
|
||||
void
|
||||
IdleConnList::closeN(size_t n)
|
||||
IdleConnList::closeN(const size_t n)
|
||||
{
|
||||
if (n < 1) {
|
||||
debugs(48, 2, "Nothing to do.");
|
||||
return;
|
||||
} else if (n >= (size_t)size_) {
|
||||
} else if (n >= size_) {
|
||||
debugs(48, 2, "Closing all entries.");
|
||||
while (size_ > 0) {
|
||||
const Comm::ConnectionPointer conn = theList_[--size_];
|
||||
@ -141,11 +143,11 @@ IdleConnList::closeN(size_t n)
|
||||
parent_->noteConnectionRemoved();
|
||||
}
|
||||
// shuffle the list N down.
|
||||
for (index = 0; index < (size_t)size_ - n; ++index) {
|
||||
for (index = 0; index < size_ - n; ++index) {
|
||||
theList_[index] = theList_[index + n];
|
||||
}
|
||||
// ensure the last N entries are unset
|
||||
while (index < ((size_t)size_)) {
|
||||
while (index < size_) {
|
||||
theList_[index] = nullptr;
|
||||
++index;
|
||||
}
|
||||
@ -174,7 +176,7 @@ IdleConnList::push(const Comm::ConnectionPointer &conn)
|
||||
capacity_ <<= 1;
|
||||
const Comm::ConnectionPointer *oldList = theList_;
|
||||
theList_ = new Comm::ConnectionPointer[capacity_];
|
||||
for (int index = 0; index < size_; ++index)
|
||||
for (size_t index = 0; index < size_; ++index)
|
||||
theList_[index] = oldList[index];
|
||||
|
||||
delete[] oldList;
|
||||
@ -214,7 +216,8 @@ IdleConnList::isAvailable(int i) const
|
||||
Comm::ConnectionPointer
|
||||
IdleConnList::pop()
|
||||
{
|
||||
for (int i=size_-1; i>=0; --i) {
|
||||
for (auto right = size_; right > 0; --right) {
|
||||
const auto i = right - 1;
|
||||
|
||||
if (!isAvailable(i))
|
||||
continue;
|
||||
@ -252,7 +255,8 @@ IdleConnList::findUseable(const Comm::ConnectionPointer &aKey)
|
||||
const bool keyCheckAddr = !aKey->local.isAnyAddr();
|
||||
const bool keyCheckPort = aKey->local.port() > 0;
|
||||
|
||||
for (int i=size_-1; i>=0; --i) {
|
||||
for (auto right = size_; right > 0; --right) {
|
||||
const auto i = right - 1;
|
||||
|
||||
if (!isAvailable(i))
|
||||
continue;
|
||||
|
@ -59,14 +59,16 @@ public:
|
||||
|
||||
void clearHandlers(const Comm::ConnectionPointer &conn);
|
||||
|
||||
// TODO: Upgrade to return size_t
|
||||
int count() const { return size_; }
|
||||
|
||||
void closeN(size_t count);
|
||||
|
||||
// IndependentRunner API
|
||||
void endingShutdown() override;
|
||||
private:
|
||||
bool isAvailable(int i) const;
|
||||
bool removeAt(int index);
|
||||
bool removeAt(size_t index);
|
||||
int findIndexOf(const Comm::ConnectionPointer &conn) const;
|
||||
void findAndClose(const Comm::ConnectionPointer &conn);
|
||||
static IOCB Read;
|
||||
@ -81,9 +83,9 @@ private:
|
||||
Comm::ConnectionPointer *theList_;
|
||||
|
||||
/// Number of entries theList can currently hold without re-allocating (capacity).
|
||||
int capacity_;
|
||||
size_t capacity_;
|
||||
///< Number of in-use entries in theList
|
||||
int size_;
|
||||
size_t size_;
|
||||
|
||||
/** The pool containing this sub-list.
|
||||
* The parent performs all stats accounting, and
|
||||
|
@ -1966,7 +1966,7 @@ StoreEntry::checkDisk() const
|
||||
Must(swap_status == SWAPOUT_NONE);
|
||||
} else {
|
||||
Must(swap_filen >= 0);
|
||||
Must(swap_dirn < Config.cacheSwap.n_configured);
|
||||
Must(static_cast<size_t>(swap_dirn) < Config.cacheSwap.n_configured);
|
||||
if (swapoutFailed()) {
|
||||
Must(EBIT_TEST(flags, RELEASE_REQUEST));
|
||||
} else {
|
||||
|
@ -55,9 +55,8 @@ objectSizeForDirSelection(const StoreEntry &entry)
|
||||
|
||||
/// TODO: Remove when cache_dir-iterating functions are converted to Disks methods
|
||||
static SwapDir &
|
||||
SwapDirByIndex(const int i)
|
||||
SwapDirByIndex(const size_t i)
|
||||
{
|
||||
assert(i >= 0);
|
||||
assert(i < Config.cacheSwap.n_allocated);
|
||||
const auto sd = INDEXSD(i);
|
||||
assert(sd);
|
||||
@ -76,12 +75,12 @@ storeDirSelectSwapDirRoundRobin(const StoreEntry * e)
|
||||
|
||||
// Increment the first candidate once per selection (not once per
|
||||
// iteration) to reduce bias when some disk(s) attract more entries.
|
||||
static int firstCandidate = 0;
|
||||
static size_t firstCandidate = 0;
|
||||
if (++firstCandidate >= Config.cacheSwap.n_configured)
|
||||
firstCandidate = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
const int dirn = (firstCandidate + i) % Config.cacheSwap.n_configured;
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
const auto dirn = (firstCandidate + i) % Config.cacheSwap.n_configured;
|
||||
auto &dir = SwapDirByIndex(dirn);
|
||||
|
||||
int load = 0;
|
||||
@ -119,11 +118,10 @@ storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
|
||||
int least_load = INT_MAX;
|
||||
int load;
|
||||
SwapDir *selectedDir = nullptr;
|
||||
int i;
|
||||
|
||||
const int64_t objsize = objectSizeForDirSelection(*e);
|
||||
|
||||
for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
auto &sd = SwapDirByIndex(i);
|
||||
sd.flags.selected = false;
|
||||
|
||||
@ -174,13 +172,13 @@ Store::Disks::Disks():
|
||||
}
|
||||
|
||||
SwapDir *
|
||||
Store::Disks::store(int const x) const
|
||||
Store::Disks::store(const size_t x) const
|
||||
{
|
||||
return &SwapDirByIndex(x);
|
||||
}
|
||||
|
||||
SwapDir &
|
||||
Store::Disks::Dir(const int i)
|
||||
Store::Disks::Dir(const size_t i)
|
||||
{
|
||||
return SwapDirByIndex(i);
|
||||
}
|
||||
@ -190,12 +188,12 @@ Store::Disks::callback()
|
||||
{
|
||||
int result = 0;
|
||||
int j;
|
||||
static int ndir = 0;
|
||||
static size_t ndir = 0;
|
||||
|
||||
do {
|
||||
j = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (ndir >= Config.cacheSwap.n_configured)
|
||||
ndir = ndir % Config.cacheSwap.n_configured;
|
||||
|
||||
@ -224,7 +222,7 @@ Store::Disks::create()
|
||||
debugs(0, DBG_PARSE_NOTE(DBG_CRITICAL), "No cache_dir stores are configured.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (Dir(i).active())
|
||||
store(i)->create();
|
||||
}
|
||||
@ -233,12 +231,12 @@ Store::Disks::create()
|
||||
StoreEntry *
|
||||
Store::Disks::get(const cache_key *key)
|
||||
{
|
||||
if (const int cacheDirs = Config.cacheSwap.n_configured) {
|
||||
if (const auto cacheDirs = Config.cacheSwap.n_configured) {
|
||||
// ask each cache_dir until the entry is found; use static starting
|
||||
// point to avoid asking the same subset of disks more often
|
||||
// TODO: coordinate with put() to be able to guess the right disk often
|
||||
static int idx = 0;
|
||||
for (int n = 0; n < cacheDirs; ++n) {
|
||||
static size_t idx = 0;
|
||||
for (size_t n = 0; n < cacheDirs; ++n) {
|
||||
idx = (idx + 1) % cacheDirs;
|
||||
auto &sd = Dir(idx);
|
||||
if (!sd.active())
|
||||
@ -289,7 +287,7 @@ Store::Disks::init()
|
||||
// level is decremented in each corresponding storeRebuildComplete() call.
|
||||
StoreController::store_dirs_rebuilding += Config.cacheSwap.n_configured;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
/* this starts a search of the store dirs, loading their
|
||||
* index. under the new Store api this should be
|
||||
* driven by the StoreHashIndex, not by each store.
|
||||
@ -324,7 +322,7 @@ Store::Disks::maxSize() const
|
||||
{
|
||||
uint64_t result = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (Dir(i).doReportStat())
|
||||
result += store(i)->maxSize();
|
||||
}
|
||||
@ -337,7 +335,7 @@ Store::Disks::minSize() const
|
||||
{
|
||||
uint64_t result = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (Dir(i).doReportStat())
|
||||
result += store(i)->minSize();
|
||||
}
|
||||
@ -350,7 +348,7 @@ Store::Disks::currentSize() const
|
||||
{
|
||||
uint64_t result = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (Dir(i).doReportStat())
|
||||
result += store(i)->currentSize();
|
||||
}
|
||||
@ -363,7 +361,7 @@ Store::Disks::currentCount() const
|
||||
{
|
||||
uint64_t result = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (Dir(i).doReportStat())
|
||||
result += store(i)->currentCount();
|
||||
}
|
||||
@ -389,7 +387,7 @@ Store::Disks::configure()
|
||||
|
||||
Config.cacheSwap.n_strands = 0;
|
||||
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
auto &disk = Dir(i);
|
||||
if (disk.needsDiskStrand()) {
|
||||
assert(InDaemonMode());
|
||||
@ -433,7 +431,7 @@ Store::Disks::Parse(DiskConfig &swap)
|
||||
|
||||
// check for the existing cache_dir
|
||||
// XXX: This code mistreats duplicated cache_dir entries (that should be fatal).
|
||||
for (int i = 0; i < swap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < swap.n_configured; ++i) {
|
||||
auto &disk = Dir(i);
|
||||
if ((strcasecmp(pathStr, disk.path)) == 0) {
|
||||
/* this is specific to on-fs Stores. The right
|
||||
@ -453,7 +451,7 @@ Store::Disks::Parse(DiskConfig &swap)
|
||||
}
|
||||
}
|
||||
|
||||
const int cacheDirCountLimit = 64; // StoreEntry::swap_dirn is a signed 7-bit integer
|
||||
const size_t cacheDirCountLimit = 64; // StoreEntry::swap_dirn is a signed 7-bit integer
|
||||
if (swap.n_configured >= cacheDirCountLimit)
|
||||
throw TextException(ToSBuf("Squid cannot handle more than ", cacheDirCountLimit, " cache_dir directives"), Here());
|
||||
|
||||
@ -468,7 +466,7 @@ Store::Disks::Parse(DiskConfig &swap)
|
||||
void
|
||||
Store::Disks::Dump(const DiskConfig &swap, StoreEntry &entry, const char *name)
|
||||
{
|
||||
for (int i = 0; i < swap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < swap.n_configured; ++i) {
|
||||
const auto &disk = Dir(i);
|
||||
storeAppendPrintf(&entry, "%s %s %s", name, disk.type(), disk.path);
|
||||
disk.dump(entry);
|
||||
@ -517,7 +515,7 @@ void
|
||||
Store::Disks::getStats(StoreInfoStats &stats) const
|
||||
{
|
||||
// accumulate per-disk cache stats
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
StoreInfoStats dirStats;
|
||||
store(i)->getStats(dirStats);
|
||||
stats += dirStats;
|
||||
@ -532,11 +530,9 @@ Store::Disks::getStats(StoreInfoStats &stats) const
|
||||
void
|
||||
Store::Disks::stat(StoreEntry & output) const
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Now go through each store, calling its stat routine */
|
||||
|
||||
for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
storeAppendPrintf(&output, "\n");
|
||||
store(i)->stat(output);
|
||||
}
|
||||
@ -564,10 +560,9 @@ Store::Disks::updateHeaders(StoreEntry *e)
|
||||
void
|
||||
Store::Disks::maintain()
|
||||
{
|
||||
int i;
|
||||
/* walk each fs */
|
||||
|
||||
for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
/* XXX FixMe: This should be done "in parallel" on the different
|
||||
* cache_dirs, not one at a time.
|
||||
*/
|
||||
@ -579,7 +574,7 @@ Store::Disks::maintain()
|
||||
void
|
||||
Store::Disks::sync()
|
||||
{
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i)
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i)
|
||||
store(i)->sync();
|
||||
}
|
||||
|
||||
@ -603,7 +598,7 @@ Store::Disks::evictCached(StoreEntry &e) {
|
||||
void
|
||||
Store::Disks::evictIfFound(const cache_key *key)
|
||||
{
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (Dir(i).active())
|
||||
Dir(i).evictIfFound(key);
|
||||
}
|
||||
@ -615,12 +610,12 @@ Store::Disks::anchorToCache(StoreEntry &entry)
|
||||
if (entry.hasDisk())
|
||||
return true; // already anchored
|
||||
|
||||
if (const int cacheDirs = Config.cacheSwap.n_configured) {
|
||||
if (const size_t cacheDirs = Config.cacheSwap.n_configured) {
|
||||
// ask each cache_dir until the entry is found; use static starting
|
||||
// point to avoid asking the same subset of disks more often
|
||||
// TODO: coordinate with put() to be able to guess the right disk often
|
||||
static int idx = 0;
|
||||
for (int n = 0; n < cacheDirs; ++n) {
|
||||
static size_t idx = 0;
|
||||
for (size_t n = 0; n < cacheDirs; ++n) {
|
||||
idx = (idx + 1) % cacheDirs;
|
||||
SwapDir &sd = Dir(idx);
|
||||
if (!sd.active())
|
||||
@ -648,7 +643,7 @@ Store::Disks::updateAnchored(StoreEntry &entry)
|
||||
bool
|
||||
Store::Disks::SmpAware()
|
||||
{
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
// A mix is not supported, but we conservatively check every
|
||||
// dir because features like collapsed revalidation should
|
||||
// currently be disabled if any dir is SMP-aware
|
||||
@ -667,7 +662,7 @@ Store::Disks::SelectSwapDir(const StoreEntry *e)
|
||||
bool
|
||||
Store::Disks::hasReadableEntry(const StoreEntry &e) const
|
||||
{
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i)
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i)
|
||||
if (Dir(i).active() && Dir(i).hasReadableEntry(e))
|
||||
return true;
|
||||
return false;
|
||||
@ -676,14 +671,14 @@ Store::Disks::hasReadableEntry(const StoreEntry &e) const
|
||||
void
|
||||
storeDirOpenSwapLogs()
|
||||
{
|
||||
for (int dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
|
||||
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
|
||||
SwapDirByIndex(dirn).openLog();
|
||||
}
|
||||
|
||||
void
|
||||
storeDirCloseSwapLogs()
|
||||
{
|
||||
for (int dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
|
||||
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
|
||||
SwapDirByIndex(dirn).closeLog();
|
||||
}
|
||||
|
||||
@ -704,7 +699,6 @@ storeDirWriteCleanLogs(int reopen)
|
||||
|
||||
struct timeval start;
|
||||
double dt;
|
||||
int dirn;
|
||||
int notdone = 1;
|
||||
|
||||
// Check for store_dirs_rebuilding because fatal() often calls us in early
|
||||
@ -720,7 +714,7 @@ storeDirWriteCleanLogs(int reopen)
|
||||
getCurrentTime();
|
||||
start = current_time;
|
||||
|
||||
for (dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
|
||||
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
|
||||
auto &sd = SwapDirByIndex(dirn);
|
||||
|
||||
if (sd.writeCleanStart() < 0) {
|
||||
@ -737,7 +731,7 @@ storeDirWriteCleanLogs(int reopen)
|
||||
while (notdone) {
|
||||
notdone = 0;
|
||||
|
||||
for (dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
|
||||
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn) {
|
||||
auto &sd = SwapDirByIndex(dirn);
|
||||
|
||||
if (!sd.cleanLog)
|
||||
@ -764,7 +758,7 @@ storeDirWriteCleanLogs(int reopen)
|
||||
}
|
||||
|
||||
/* Flush */
|
||||
for (dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
|
||||
for (size_t dirn = 0; dirn < Config.cacheSwap.n_configured; ++dirn)
|
||||
SwapDirByIndex(dirn).writeCleanDone();
|
||||
|
||||
if (reopen)
|
||||
@ -794,7 +788,7 @@ allocate_new_swapdir(Store::DiskConfig &swap)
|
||||
if (swap.n_allocated == swap.n_configured) {
|
||||
swap.n_allocated <<= 1;
|
||||
const auto tmp = new SwapDir::Pointer[swap.n_allocated];
|
||||
for (int i = 0; i < swap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < swap.n_configured; ++i) {
|
||||
tmp[i] = swap.swapDirs[i];
|
||||
}
|
||||
delete[] swap.swapDirs;
|
||||
|
@ -60,8 +60,8 @@ public:
|
||||
|
||||
private:
|
||||
/* migration logic */
|
||||
SwapDir *store(int const x) const;
|
||||
static SwapDir &Dir(int const idx);
|
||||
SwapDir *store(size_t index) const;
|
||||
static SwapDir &Dir(size_t index);
|
||||
|
||||
int64_t largestMinimumObjectSize; ///< maximum of all Disk::minObjectSize()s
|
||||
int64_t largestMaximumObjectSize; ///< maximum of all Disk::maxObjectSize()s
|
||||
|
@ -211,16 +211,18 @@ storeRebuildStart(void)
|
||||
* progress.
|
||||
*/
|
||||
void
|
||||
storeRebuildProgress(int sd_index, int total, int sofar)
|
||||
storeRebuildProgress(const int sd_index_raw, const int total, const int sofar)
|
||||
{
|
||||
static time_t last_report = 0;
|
||||
// TODO: Switch to int64_t and fix handling of unknown totals.
|
||||
double n = 0.0;
|
||||
double d = 0.0;
|
||||
|
||||
if (sd_index < 0)
|
||||
if (sd_index_raw < 0)
|
||||
return;
|
||||
|
||||
// TODO: Upgrade Disk::index and sd_index_raw to size_t, removing this cast.
|
||||
const auto sd_index = static_cast<size_t>(sd_index_raw);
|
||||
if (sd_index >= Config.cacheSwap.n_configured)
|
||||
return;
|
||||
|
||||
@ -234,9 +236,9 @@ storeRebuildProgress(int sd_index, int total, int sofar)
|
||||
if (squid_curtime - last_report < 15)
|
||||
return;
|
||||
|
||||
for (sd_index = 0; sd_index < Config.cacheSwap.n_configured; ++sd_index) {
|
||||
n += (double) RebuildProgress[sd_index].scanned;
|
||||
d += (double) RebuildProgress[sd_index].total;
|
||||
for (size_t diskIndex = 0; diskIndex < Config.cacheSwap.n_configured; ++diskIndex) {
|
||||
n += (double) RebuildProgress[diskIndex].scanned;
|
||||
d += (double) RebuildProgress[diskIndex].total;
|
||||
}
|
||||
|
||||
debugs(20, Important(57), "Indexing cache entries: " << Progress(n, d));
|
||||
|
@ -111,7 +111,7 @@ addedEntry(Store::Disk *aStore,
|
||||
e->swap_filen = 0; /* garh - lower level*/
|
||||
e->swap_dirn = -1;
|
||||
|
||||
for (int i=0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (INDEXSD(i) == aStore)
|
||||
e->swap_dirn = i;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ addedEntry(Store::Disk *aStore,
|
||||
e->swap_filen = 0; /* garh - lower level*/
|
||||
e->swap_dirn = -1;
|
||||
|
||||
for (int i=0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
if (INDEXSD(i) == aStore)
|
||||
e->swap_dirn = i;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ bool
|
||||
unlinkdNeeded(void)
|
||||
{
|
||||
// we should start unlinkd if there are any cache_dirs using it
|
||||
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
for (size_t i = 0; i < Config.cacheSwap.n_configured; ++i) {
|
||||
const RefCount<SwapDir> sd = Config.cacheSwap.swapDirs[i];
|
||||
if (sd->unlinkdUseful())
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user