This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new cc34a3ba59 Cleanup: Rename gvol to gstripes (#10953)
cc34a3ba59 is described below
commit cc34a3ba599b0275b7af191232d46a59ca99caea
Author: Masaori Koshiba <[email protected]>
AuthorDate: Fri Dec 22 08:34:48 2023 +0900
Cleanup: Rename gvol to gstripes (#10953)
---
src/iocore/cache/Cache.cc | 116 +++++++++++++--------------
src/iocore/cache/CacheDir.cc | 18 ++---
src/iocore/cache/P_CacheDir.h | 10 +--
src/iocore/cache/P_CacheVol.h | 4 +-
src/iocore/cache/Stripe.cc | 6 +-
src/iocore/cache/unit_tests/test_CacheDir.cc | 4 +-
src/iocore/cache/unit_tests/test_CacheVol.cc | 8 +-
7 files changed, 83 insertions(+), 83 deletions(-)
diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc
index d61ecec748..7d14385e3d 100644
--- a/src/iocore/cache/Cache.cc
+++ b/src/iocore/cache/Cache.cc
@@ -87,8 +87,8 @@ bool CacheProcessor::check = false;
int CacheProcessor::start_internal_flags = 0;
int CacheProcessor::auto_clear_flag = 0;
CacheProcessor cacheProcessor;
-Stripe **gvol = nullptr;
-std::atomic<int> gnvol = 0;
+Stripe **gstripes = nullptr;
+std::atomic<int> gnstripes = 0;
ClassAllocator<CacheVC> cacheVConnectionAllocator("cacheVConnection");
ClassAllocator<CacheEvacuateDocVC>
cacheEvacuateDocVConnectionAllocator("cacheEvacuateDocVC");
ClassAllocator<EvacuationBlock> evacuationBlockAllocator("evacuationBlock");
@@ -193,13 +193,13 @@ register_cache_stats(CacheStatsBlock *rsb, const
std::string prefix)
// ToDo: This gets called as part of librecords collection continuation,
probably change this later.
inline int64_t
-cache_bytes_used(int vol_ix)
+cache_bytes_used(int index)
{
- if (!DISK_BAD(gvol[vol_ix]->disk)) {
- if (!gvol[vol_ix]->header->cycle) {
- return gvol[vol_ix]->header->write_pos - gvol[vol_ix]->start;
+ if (!DISK_BAD(gstripes[index]->disk)) {
+ if (!gstripes[index]->header->cycle) {
+ return gstripes[index]->header->write_pos - gstripes[index]->start;
} else {
- return gvol[vol_ix]->len - gvol[vol_ix]->dirlen() - EVACUATION_SIZE;
+ return gstripes[index]->len - gstripes[index]->dirlen() -
EVACUATION_SIZE;
}
}
@@ -214,14 +214,14 @@ CachePeriodicMetricsUpdate()
// Make sure the bytes_used per volume is always reset to zero, this can
update the
// volume metric more than once (once per disk). This happens once every sync
// period (5s), and nothing else modifies these metrics.
- for (int vol_ix = 0; vol_ix < gnvol; ++vol_ix) {
- Metrics::Gauge::store(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0);
+ for (int i = 0; i < gnstripes; ++i) {
+ Metrics::Gauge::store(gstripes[i]->cache_vol->vol_rsb.bytes_used, 0);
}
if (cacheProcessor.initialized == CACHE_INITIALIZED) {
- for (int vol_ix = 0; vol_ix < gnvol; ++vol_ix) {
- Stripe *v = gvol[vol_ix];
- int64_t used = cache_bytes_used(vol_ix);
+ for (int i = 0; i < gnstripes; ++i) {
+ Stripe *v = gstripes[i];
+ int64_t used = cache_bytes_used(i);
Metrics::Gauge::increment(v->cache_vol->vol_rsb.bytes_used, used); //
This assumes they start at zero
total_sum += used;
@@ -526,7 +526,7 @@ CacheProcessor::diskInitialized()
if (res == -1) {
/* problems initializing the volume.config. Punt */
- gnvol = 0;
+ gnstripes = 0;
cacheInitialized();
return;
} else {
@@ -539,9 +539,9 @@ CacheProcessor::diskInitialized()
}
}
- gvol = static_cast<Stripe **>(ats_malloc(gnvol * sizeof(Stripe *)));
- memset(gvol, 0, gnvol * sizeof(Stripe *));
- gnvol = 0;
+ gstripes = static_cast<Stripe **>(ats_malloc(gnstripes * sizeof(Stripe *)));
+ memset(gstripes, 0, gnstripes * sizeof(Stripe *));
+ gnstripes = 0;
for (i = 0; i < gndisks; i++) {
CacheDisk *d = gdisks[i];
if (dbg_ctl_cache_hosting.on()) {
@@ -612,12 +612,12 @@ CacheProcessor::cacheInitialized()
}
// Update stripe version data.
- if (gnvol) { // start with whatever the first stripe is.
- cacheProcessor.min_stripe_version = cacheProcessor.max_stripe_version =
gvol[0]->header->version;
+ if (gnstripes) { // start with whatever the first stripe is.
+ cacheProcessor.min_stripe_version = cacheProcessor.max_stripe_version =
gstripes[0]->header->version;
}
// scan the rest of the stripes.
- for (i = 1; i < gnvol; i++) {
- Stripe *v = gvol[i];
+ for (i = 1; i < gnstripes; i++) {
+ Stripe *v = gstripes[i];
if (v->header->version < cacheProcessor.min_stripe_version) {
cacheProcessor.min_stripe_version = v->header->version;
}
@@ -628,48 +628,48 @@ CacheProcessor::cacheInitialized()
if (caches_ready) {
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized -
caches_ready=0x%0X, gnvol=%d", (unsigned int)caches_ready,
- gnvol.load());
+ gnstripes.load());
int64_t ram_cache_bytes = 0;
- if (gnvol) {
+ if (gnstripes) {
// new ram_caches, with algorithm from the config
- for (i = 0; i < gnvol; i++) {
+ for (i = 0; i < gnstripes; i++) {
switch (cache_config_ram_cache_algorithm) {
default:
case RAM_CACHE_ALGORITHM_CLFUS:
- gvol[i]->ram_cache = new_RamCacheCLFUS();
+ gstripes[i]->ram_cache = new_RamCacheCLFUS();
break;
case RAM_CACHE_ALGORITHM_LRU:
- gvol[i]->ram_cache = new_RamCacheLRU();
+ gstripes[i]->ram_cache = new_RamCacheLRU();
break;
}
}
// let us calculate the Size
if (cache_config_ram_cache_size == AUTO_SIZE_RAM_CACHE) {
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized -
cache_config_ram_cache_size == AUTO_SIZE_RAM_CACHE");
- for (i = 0; i < gnvol; i++) {
- stripe = gvol[i];
+ for (i = 0; i < gnstripes; i++) {
+ stripe = gstripes[i];
- if (gvol[i]->cache_vol->ramcache_enabled) {
- gvol[i]->ram_cache->init(stripe->dirlen() *
DEFAULT_RAM_CACHE_MULTIPLIER, stripe);
- ram_cache_bytes += gvol[i]->dirlen();
+ if (gstripes[i]->cache_vol->ramcache_enabled) {
+ gstripes[i]->ram_cache->init(stripe->dirlen() *
DEFAULT_RAM_CACHE_MULTIPLIER, stripe);
+ ram_cache_bytes += gstripes[i]->dirlen();
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized -
ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb",
ram_cache_bytes, ram_cache_bytes / (1024 * 1024));
-
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.ram_cache_bytes_total,
gvol[i]->dirlen());
+
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.ram_cache_bytes_total,
gstripes[i]->dirlen());
}
- vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen();
+ vol_total_cache_bytes = gstripes[i]->len - gstripes[i]->dirlen();
total_cache_bytes += vol_total_cache_bytes;
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized -
total_cache_bytes = %" PRId64 " = %" PRId64 "Mb",
total_cache_bytes, total_cache_bytes / (1024 * 1024));
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.bytes_total,
vol_total_cache_bytes);
- vol_total_direntries = gvol[i]->buckets * gvol[i]->segments *
DIR_DEPTH;
+ vol_total_direntries = gstripes[i]->buckets * gstripes[i]->segments
* DIR_DEPTH;
total_direntries += vol_total_direntries;
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.direntries_total,
vol_total_direntries);
- vol_used_direntries = dir_entries_used(gvol[i]);
+ vol_used_direntries = dir_entries_used(gstripes[i]);
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.direntries_used,
vol_used_direntries);
used_direntries += vol_used_direntries;
}
@@ -694,35 +694,35 @@ CacheProcessor::cacheInitialized()
Dbg(dbg_ctl_ram_cache, "config: size = %" PRId64 ", cutoff = %" PRId64
"", cache_config_ram_cache_size,
cache_config_ram_cache_cutoff);
- for (i = 0; i < gnvol; i++) {
- stripe = gvol[i];
+ for (i = 0; i < gnstripes; i++) {
+ stripe = gstripes[i];
double factor;
- if (gvol[i]->cache == theCache &&
gvol[i]->cache_vol->ramcache_enabled) {
- ink_assert(gvol[i]->cache != nullptr);
- factor = static_cast<double>(static_cast<int64_t>(gvol[i]->len >>
STORE_BLOCK_SHIFT)) / theCache->cache_size;
+ if (gstripes[i]->cache == theCache &&
gstripes[i]->cache_vol->ramcache_enabled) {
+ ink_assert(gstripes[i]->cache != nullptr);
+ factor = static_cast<double>(static_cast<int64_t>(gstripes[i]->len
>> STORE_BLOCK_SHIFT)) / theCache->cache_size;
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - factor
= %f", factor);
- gvol[i]->ram_cache->init(static_cast<int64_t>(http_ram_cache_size
* factor), stripe);
+
gstripes[i]->ram_cache->init(static_cast<int64_t>(http_ram_cache_size *
factor), stripe);
ram_cache_bytes += static_cast<int64_t>(http_ram_cache_size *
factor);
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.ram_cache_bytes_total,
static_cast<int64_t>(http_ram_cache_size
* factor));
- } else if (gvol[i]->cache_vol->ramcache_enabled) {
+ } else if (gstripes[i]->cache_vol->ramcache_enabled) {
ink_release_assert(!"Unexpected non-HTTP cache volume");
}
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized[%d] -
ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", i,
ram_cache_bytes, ram_cache_bytes / (1024 * 1024));
- vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen();
+ vol_total_cache_bytes = gstripes[i]->len - gstripes[i]->dirlen();
total_cache_bytes += vol_total_cache_bytes;
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.bytes_total,
vol_total_cache_bytes);
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.stripes);
Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized -
total_cache_bytes = %" PRId64 " = %" PRId64 "Mb",
total_cache_bytes, total_cache_bytes / (1024 * 1024));
- vol_total_direntries = gvol[i]->buckets * gvol[i]->segments *
DIR_DEPTH;
+ vol_total_direntries = gstripes[i]->buckets * gstripes[i]->segments
* DIR_DEPTH;
total_direntries += vol_total_direntries;
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.direntries_total,
vol_total_direntries);
- vol_used_direntries = dir_entries_used(gvol[i]);
+ vol_used_direntries = dir_entries_used(gstripes[i]);
Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.direntries_used,
vol_used_direntries);
used_direntries += vol_used_direntries;
}
@@ -784,8 +784,8 @@ CacheProcessor::stop()
int
CacheProcessor::dir_check(bool afix)
{
- for (int i = 0; i < gnvol; i++) {
- gvol[i]->dir_check(afix);
+ for (int i = 0; i < gnstripes; i++) {
+ gstripes[i]->dir_check(afix);
}
return 0;
}
@@ -1007,11 +1007,11 @@ CacheProcessor::mark_storage_offline(CacheDisk *d, ///<
Target disk
SET_DISK_BAD(d);
}
- for (p = 0; p < gnvol; p++) {
- if (d->fd == gvol[p]->fd) {
- total_dir_delete += gvol[p]->buckets * gvol[p]->segments * DIR_DEPTH;
- used_dir_delete += dir_entries_used(gvol[p]);
- total_bytes_delete += gvol[p]->len - gvol[p]->dirlen();
+ for (p = 0; p < gnstripes; p++) {
+ if (d->fd == gstripes[p]->fd) {
+ total_dir_delete += gstripes[p]->buckets * gstripes[p]->segments *
DIR_DEPTH;
+ used_dir_delete += dir_entries_used(gstripes[p]);
+ total_bytes_delete += gstripes[p]->len - gstripes[p]->dirlen();
}
}
@@ -1461,7 +1461,7 @@ cplist_reconfigure()
ConfigVol *config_vol;
int assignedVol = 0; // Number of assigned volumes
- gnvol = 0;
+ gnstripes = 0;
if (config_volumes.num_volumes == 0) {
/* only the http cache */
CacheVol *cp = new CacheVol();
@@ -1492,7 +1492,7 @@ cplist_reconfigure()
ink_assert(gdisks[i]->header->num_volumes == 1);
DiskStripe **dp = gdisks[i]->disk_stripes;
- gnvol += dp[0]->num_volblocks;
+ gnstripes += dp[0]->num_volblocks;
cp->size += dp[0]->size;
cp->num_vols += dp[0]->num_volblocks;
cp->disk_stripes[i] = dp[0];
@@ -1582,7 +1582,7 @@ cplist_reconfigure()
size_in_blocks = (static_cast<off_t>(size) * 1024 * 1024) /
STORE_BLOCK_SIZE;
if (config_vol->cachep && config_vol->cachep->num_vols > 0) {
- gnvol += config_vol->cachep->num_vols;
+ gnstripes += config_vol->cachep->num_vols;
continue;
}
@@ -1601,14 +1601,14 @@ cplist_reconfigure()
cp_list.enqueue(new_cp);
cp_list_len++;
config_vol->cachep = new_cp;
- gnvol += new_cp->num_vols;
+ gnstripes += new_cp->num_vols;
continue;
}
// else
CacheVol *cp = config_vol->cachep;
ink_assert(cp->size <= size_in_blocks);
if (cp->size == size_in_blocks) {
- gnvol += cp->num_vols;
+ gnstripes += cp->num_vols;
continue;
}
// else the size is greater...
@@ -1684,11 +1684,11 @@ cplist_reconfigure()
return -1;
}
}
- gnvol += cp->num_vols;
+ gnstripes += cp->num_vols;
}
}
- Metrics::Gauge::store(cache_rsb.stripes, gnvol + assignedVol);
+ Metrics::Gauge::store(cache_rsb.stripes, gnstripes + assignedVol);
return 0;
}
diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc
index 192e632c88..63556cb7bf 100644
--- a/src/iocore/cache/CacheDir.cc
+++ b/src/iocore/cache/CacheDir.cc
@@ -973,12 +973,12 @@ sync_cache_dir_on_shutdown()
bool buf_huge = false;
EThread *t = (EThread *)0xdeadbeef;
- for (int i = 0; i < gnvol; i++) {
+ for (int i = 0; i < gnstripes; i++) {
// the process is going down, do a blocking call
// dont release the volume's lock, there could
// be another aggWrite in progress
- MUTEX_TAKE_LOCK(gvol[i]->mutex, t);
- Stripe *stripe = gvol[i];
+ MUTEX_TAKE_LOCK(gstripes[i]->mutex, t);
+ Stripe *stripe = gstripes[i];
if (DISK_BAD(stripe->disk)) {
Dbg(dbg_ctl_cache_dir_sync, "Dir %s: ignoring -- bad disk",
stripe->hash_text.get());
@@ -1056,8 +1056,8 @@ CacheSync::mainEvent(int event, Event *e)
}
Lrestart:
- if (vol_idx >= gnvol) {
- vol_idx = 0;
+ if (stripe_index >= gnstripes) {
+ stripe_index = 0;
if (buf) {
if (buf_huge) {
ats_free_hugepage(buf, buflen);
@@ -1077,12 +1077,12 @@ Lrestart:
return EVENT_CONT;
}
- Stripe *stripe = gvol[vol_idx]; // must be named "vol" to make STAT macros
work.
+ Stripe *stripe = gstripes[stripe_index]; // must be named "vol" to make STAT
macros work.
if (event == AIO_EVENT_DONE) {
// AIO Thread
if (!io.ok()) {
- Warning("vol write error during directory sync '%s'",
gvol[vol_idx]->hash_text.get());
+ Warning("vol write error during directory sync '%s'",
gstripes[stripe_index]->hash_text.get());
event = EVENT_NONE;
goto Ldone;
}
@@ -1092,7 +1092,7 @@ Lrestart:
return EVENT_CONT;
}
{
- CACHE_TRY_LOCK(lock, gvol[vol_idx]->mutex, mutex->thread_holding);
+ CACHE_TRY_LOCK(lock, gstripes[stripe_index]->mutex, mutex->thread_holding);
if (!lock.is_locked()) {
trigger = eventProcessor.schedule_in(this,
HRTIME_MSECONDS(cache_config_mutex_retry_delay));
return EVENT_CONT;
@@ -1193,7 +1193,7 @@ Lrestart:
Ldone:
// done
writepos = 0;
- ++vol_idx;
+ ++stripe_index;
goto Lrestart;
}
diff --git a/src/iocore/cache/P_CacheDir.h b/src/iocore/cache/P_CacheDir.h
index 2983d8d420..ddf3ad27a8 100644
--- a/src/iocore/cache/P_CacheDir.h
+++ b/src/iocore/cache/P_CacheDir.h
@@ -248,11 +248,11 @@ struct OpenDir : public Continuation {
};
struct CacheSync : public Continuation {
- int vol_idx = 0;
- char *buf = nullptr;
- size_t buflen = 0;
- bool buf_huge = false;
- off_t writepos = 0;
+ int stripe_index = 0;
+ char *buf = nullptr;
+ size_t buflen = 0;
+ bool buf_huge = false;
+ off_t writepos = 0;
AIOCallbackInternal io;
Event *trigger = nullptr;
ink_hrtime start_time = 0;
diff --git a/src/iocore/cache/P_CacheVol.h b/src/iocore/cache/P_CacheVol.h
index 37cc00fa4d..2f1210464b 100644
--- a/src/iocore/cache/P_CacheVol.h
+++ b/src/iocore/cache/P_CacheVol.h
@@ -350,8 +350,8 @@ struct Doc {
// Global Data
-extern Stripe **gvol;
-extern std::atomic<int> gnvol;
+extern Stripe **gstripes;
+extern std::atomic<int> gnstripes;
extern ClassAllocator<OpenDirEntry> openDirEntryAllocator;
extern ClassAllocator<EvacuationBlock> evacuationBlockAllocator;
extern ClassAllocator<EvacuationKey> evacuationKeyAllocator;
diff --git a/src/iocore/cache/Stripe.cc b/src/iocore/cache/Stripe.cc
index 631f8c13c1..d445e64965 100644
--- a/src/iocore/cache/Stripe.cc
+++ b/src/iocore/cache/Stripe.cc
@@ -693,9 +693,9 @@ Stripe::dir_init_done(int /* event ATS_UNUSED */, void * /*
data ATS_UNUSED */)
eventProcessor.schedule_in(this, HRTIME_MSECONDS(5), ET_CALL);
return EVENT_CONT;
} else {
- int vol_no = gnvol++;
- ink_assert(!gvol[vol_no]);
- gvol[vol_no] = this;
+ int i = gnstripes++;
+ ink_assert(!gstripes[i]);
+ gstripes[i] = this;
SET_HANDLER(&Stripe::aggWrite);
cache->vol_initialized(fd != -1);
return EVENT_DONE;
diff --git a/src/iocore/cache/unit_tests/test_CacheDir.cc
b/src/iocore/cache/unit_tests/test_CacheDir.cc
index 44950ffdb9..9b988edce3 100644
--- a/src/iocore/cache/unit_tests/test_CacheDir.cc
+++ b/src/iocore/cache/unit_tests/test_CacheDir.cc
@@ -78,9 +78,9 @@ public:
ink_hrtime ttime;
REQUIRE(CacheProcessor::IsCacheEnabled() == CACHE_INITIALIZED);
- REQUIRE(gnvol >= 1);
+ REQUIRE(gnstripes >= 1);
- Stripe *stripe = gvol[0];
+ Stripe *stripe = gstripes[0];
EThread *thread = this_ethread();
MUTEX_TRY_LOCK(lock, stripe->mutex, thread);
if (!lock.is_locked()) {
diff --git a/src/iocore/cache/unit_tests/test_CacheVol.cc
b/src/iocore/cache/unit_tests/test_CacheVol.cc
index a139dec018..3bed1afada 100644
--- a/src/iocore/cache/unit_tests/test_CacheVol.cc
+++ b/src/iocore/cache/unit_tests/test_CacheVol.cc
@@ -58,7 +58,7 @@ static int configs = 4;
Queue<CacheVol> saved_cp_list;
int saved_cp_list_len;
ConfigVolumes saved_config_volumes;
-int saved_gnvol;
+int saved_gnstripes;
int ClearConfigVol(ConfigVolumes *configp);
int ClearCacheVolList(Queue<CacheVol> *cpl, int len);
@@ -342,10 +342,10 @@ save_state()
saved_cp_list = cp_list;
saved_cp_list_len = cp_list_len;
memcpy(&saved_config_volumes, &config_volumes, sizeof(ConfigVolumes));
- saved_gnvol = gnvol;
+ saved_gnstripes = gnstripes;
memset(static_cast<void *>(&cp_list), 0, sizeof(Queue<CacheVol>));
memset(static_cast<void *>(&config_volumes), 0, sizeof(ConfigVolumes));
- gnvol = 0;
+ gnstripes = 0;
}
void
@@ -354,7 +354,7 @@ restore_state()
cp_list = saved_cp_list;
cp_list_len = saved_cp_list_len;
memcpy(&config_volumes, &saved_config_volumes, sizeof(ConfigVolumes));
- gnvol = saved_gnvol;
+ gnstripes = saved_gnstripes;
}
} // end anonymous namespace