trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [trafficserver] branch master updated: Moving the inline functions to Class Vol
Date Fri, 16 Mar 2018 19:13:39 GMT
This is an automated email from the ASF dual-hosted git repository.

paziz 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 4c9e916  Moving the inline functions to Class Vol
4c9e916 is described below

commit 4c9e916ef235d37158d0874262a18c4462f4483e
Author: Persia Aziz <persia@yahoo-inc.com>
AuthorDate: Thu Mar 15 17:06:39 2018 -0500

    Moving the inline functions to Class Vol
---
 iocore/cache/Cache.cc      | 48 +++++++++++++++++-----------------
 iocore/cache/CacheDir.cc   | 64 +++++++++++++++++++++++-----------------------
 iocore/cache/CacheVol.cc   |  2 +-
 iocore/cache/CacheWrite.cc |  2 +-
 iocore/cache/P_CacheDir.h  |  1 -
 iocore/cache/P_CacheVol.h  | 30 +++++++++++++---------
 6 files changed, 76 insertions(+), 71 deletions(-)

diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index a9f4ccb..c8320f7 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -215,7 +215,7 @@ cache_bytes_used(int volume)
       if (!gvol[i]->header->cycle) {
         used += gvol[i]->header->write_pos - gvol[i]->start;
       } else {
-        used += gvol[i]->len - vol_dirlen(gvol[i]) - EVACUATION_SIZE;
+        used += gvol[i]->len - gvol[i]->dirlen() - EVACUATION_SIZE;
       }
     }
   }
@@ -966,13 +966,13 @@ CacheProcessor::cacheInitialized()
         Debug("cache_init", "CacheProcessor::cacheInitialized - cache_config_ram_cache_size
== AUTO_SIZE_RAM_CACHE");
         for (i = 0; i < gnvol; i++) {
           vol = gvol[i];
-          gvol[i]->ram_cache->init(vol_dirlen(vol) * DEFAULT_RAM_CACHE_MULTIPLIER,
vol);
-          ram_cache_bytes += vol_dirlen(gvol[i]);
+          gvol[i]->ram_cache->init(vol->dirlen() * DEFAULT_RAM_CACHE_MULTIPLIER,
vol);
+          ram_cache_bytes += gvol[i]->dirlen();
           Debug("cache_init", "CacheProcessor::cacheInitialized - ram_cache_bytes = %" PRId64
" = %" PRId64 "Mb", ram_cache_bytes,
                 ram_cache_bytes / (1024 * 1024));
-          CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)vol_dirlen(gvol[i]));
+          CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)gvol[i]->dirlen());
 
-          vol_total_cache_bytes = gvol[i]->len - vol_dirlen(gvol[i]);
+          vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen();
           total_cache_bytes += vol_total_cache_bytes;
           Debug("cache_init", "CacheProcessor::cacheInitialized - total_cache_bytes = %"
PRId64 " = %" PRId64 "Mb",
                 total_cache_bytes, total_cache_bytes / (1024 * 1024));
@@ -1024,7 +1024,7 @@ CacheProcessor::cacheInitialized()
           }
           Debug("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 - vol_dirlen(gvol[i]);
+          vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen();
           total_cache_bytes += vol_total_cache_bytes;
           CACHE_VOL_SUM_DYN_STAT(cache_bytes_total_stat, vol_total_cache_bytes);
           Debug("cache_init", "CacheProcessor::cacheInitialized - total_cache_bytes = %"
PRId64 " = %" PRId64 "Mb",
@@ -1196,7 +1196,7 @@ vol_init_data_internal(Vol *d)
   // step4: divide total_buckets into segments on average.
   d->buckets = (total_buckets + d->segments - 1) / d->segments;
   // step5: set the start pointer.
-  d->start = d->skip + 2 * vol_dirlen(d);
+  d->start = d->skip + 2 * d->dirlen();
 }
 
 static void
@@ -1215,7 +1215,7 @@ vol_init_dir(Vol *d)
 
   for (s = 0; s < d->segments; s++) {
     d->header->freelist[s] = 0;
-    Dir *seg               = dir_segment(s, d);
+    Dir *seg               = d->dir_segment(s);
     for (l = 1; l < DIR_DEPTH; l++) {
       for (b = 0; b < d->buckets; b++) {
         Dir *bucket = dir_bucket(b, seg);
@@ -1228,7 +1228,7 @@ vol_init_dir(Vol *d)
 void
 vol_clear_init(Vol *d)
 {
-  size_t dir_len = vol_dirlen(d);
+  size_t dir_len = d->dirlen();
   memset(d->raw_dir, 0, dir_len);
   vol_init_dir(d);
   d->header->magic             = VOL_MAGIC;
@@ -1247,7 +1247,7 @@ vol_clear_init(Vol *d)
 int
 vol_dir_clear(Vol *d)
 {
-  size_t dir_len = vol_dirlen(d);
+  size_t dir_len = d->dirlen();
   vol_clear_init(d);
 
   if (pwrite(d->fd, d->raw_dir, dir_len, d->skip) < 0) {
@@ -1260,7 +1260,7 @@ vol_dir_clear(Vol *d)
 int
 Vol::clear_dir()
 {
-  size_t dir_len = vol_dirlen(this);
+  size_t dir_len = this->dirlen();
   vol_clear_init(this);
 
   SET_HANDLER(&Vol::handle_dir_clear);
@@ -1307,20 +1307,20 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear)
   evacuate      = (DLL<EvacuationBlock> *)ats_malloc(evac_len);
   memset(evacuate, 0, evac_len);
 
-  Debug("cache_init", "Vol %s: allocating %zu directory bytes for a %lld byte volume (%lf%%)",
hash_text.get(), vol_dirlen(this),
-        (long long)this->len, (double)vol_dirlen(this) / (double)this->len * 100.0);
+  Debug("cache_init", "Vol %s: allocating %zu directory bytes for a %lld byte volume (%lf%%)",
hash_text.get(), dirlen(),
+        (long long)this->len, (double)dirlen() / (double)this->len * 100.0);
 
   raw_dir = nullptr;
   if (ats_hugepage_enabled()) {
-    raw_dir = (char *)ats_alloc_hugepage(vol_dirlen(this));
+    raw_dir = (char *)ats_alloc_hugepage(this->dirlen());
   }
   if (raw_dir == nullptr) {
-    raw_dir = (char *)ats_memalign(ats_pagesize(), vol_dirlen(this));
+    raw_dir = (char *)ats_memalign(ats_pagesize(), this->dirlen());
   }
 
-  dir    = (Dir *)(raw_dir + vol_headerlen(this));
+  dir    = (Dir *)(raw_dir + this->headerlen());
   header = (VolHeaderFooter *)raw_dir;
-  footer = (VolHeaderFooter *)(raw_dir + vol_dirlen(this) - ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter)));
+  footer = (VolHeaderFooter *)(raw_dir + this->dirlen() - ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter)));
 
   if (clear) {
     Note("clearing cache directory '%s'", hash_text.get());
@@ -1329,7 +1329,7 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear)
 
   init_info           = new VolInitInfo();
   int footerlen       = ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
-  off_t footer_offset = vol_dirlen(this) - footerlen;
+  off_t footer_offset = this->dirlen() - footerlen;
   // try A
   off_t as = skip;
 
@@ -1337,7 +1337,7 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear)
   SET_HANDLER(&Vol::handle_header_read);
   init_info->vol_aio[0].aiocb.aio_offset = as;
   init_info->vol_aio[1].aiocb.aio_offset = as + footer_offset;
-  off_t bs                               = skip + vol_dirlen(this);
+  off_t bs                               = skip + this->dirlen();
   init_info->vol_aio[2].aiocb.aio_offset = bs;
   init_info->vol_aio[3].aiocb.aio_offset = bs + footer_offset;
 
@@ -1361,7 +1361,7 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear)
 int
 Vol::handle_dir_clear(int event, void *data)
 {
-  size_t dir_len = vol_dirlen(this);
+  size_t dir_len = this->dirlen();
   AIOCallback *op;
 
   if (event == AIO_EVENT_DONE) {
@@ -1694,7 +1694,7 @@ Ldone : {
     aio->then             = (i < 2) ? &(init_info->vol_aio[i + 1]) : nullptr;
   }
   int footerlen = ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
-  size_t dirlen = vol_dirlen(this);
+  size_t dirlen = this->dirlen();
   int B         = header->sync_serial & 1;
   off_t ss      = skip + (B ? dirlen : 0);
 
@@ -1759,7 +1759,7 @@ Vol::handle_header_read(int event, void *data)
     }
 
     io.aiocb.aio_fildes = fd;
-    io.aiocb.aio_nbytes = vol_dirlen(this);
+    io.aiocb.aio_nbytes = this->dirlen();
     io.aiocb.aio_buf    = raw_dir;
     io.action           = this;
     io.thread           = AIO_CALLBACK_THREAD_ANY;
@@ -1780,7 +1780,7 @@ Vol::handle_header_read(int event, void *data)
       if (is_debug_tag_set("cache_init")) {
         Note("using directory B for '%s'", hash_text.get());
       }
-      io.aiocb.aio_offset = skip + vol_dirlen(this);
+      io.aiocb.aio_offset = skip + this->dirlen();
       ink_assert(ink_aio_read(&io));
     } else {
       Note("no good directory, clearing '%s' since sync_serials on both A and B copies are
invalid", hash_text.get());
@@ -1985,7 +1985,7 @@ CacheProcessor::mark_storage_offline(CacheDisk *d, ///< Target disk
     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 - vol_dirlen(gvol[p]);
+      total_bytes_delete += gvol[p]->len - gvol[p]->dirlen();
     }
   }
 
diff --git a/iocore/cache/CacheDir.cc b/iocore/cache/CacheDir.cc
index 441ae7e..188d43b 100644
--- a/iocore/cache/CacheDir.cc
+++ b/iocore/cache/CacheDir.cc
@@ -215,7 +215,7 @@ void
 dir_init_segment(int s, Vol *d)
 {
   d->header->freelist[s] = 0;
-  Dir *seg               = dir_segment(s, d);
+  Dir *seg               = d->dir_segment(s);
   int l, b;
   memset(seg, 0, SIZEOF_DIR * DIR_DEPTH * d->buckets);
   for (l = 1; l < DIR_DEPTH; l++) {
@@ -231,7 +231,7 @@ dir_init_segment(int s, Vol *d)
 int
 dir_bucket_loop_fix(Dir *start_dir, int s, Vol *d)
 {
-  if (!dir_bucket_loop_check(start_dir, dir_segment(s, d))) {
+  if (!dir_bucket_loop_check(start_dir, d->dir_segment(s))) {
     Warning("Dir loop exists, clearing segment %d", s);
     dir_init_segment(s, d);
     return 1;
@@ -243,7 +243,7 @@ int
 dir_freelist_length(Vol *d, int s)
 {
   int free = 0;
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   Dir *e   = dir_from_offset(d->header->freelist[s], seg);
   if (dir_bucket_loop_fix(e, s, d)) {
     return (DIR_DEPTH - 1) * d->buckets;
@@ -260,7 +260,7 @@ dir_bucket_length(Dir *b, int s, Vol *d)
 {
   Dir *e   = b;
   int i    = 0;
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
 #ifdef LOOP_CHECK_MODE
   if (dir_bucket_loop_fix(b, s, d))
     return 1;
@@ -281,7 +281,7 @@ check_dir(Vol *d)
   int i, s;
   Debug("cache_check_dir", "inside check dir");
   for (s = 0; s < d->segments; s++) {
-    Dir *seg = dir_segment(s, d);
+    Dir *seg = d->dir_segment(s);
     for (i = 0; i < d->buckets; i++) {
       Dir *b = dir_bucket(i, seg);
       if (!(dir_bucket_length(b, s, d) >= 0)) {
@@ -301,7 +301,7 @@ check_dir(Vol *d)
 inline void
 unlink_from_freelist(Dir *e, int s, Vol *d)
 {
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   Dir *p   = dir_from_offset(dir_prev(e), seg);
   if (p) {
     dir_set_next(p, dir_next(e));
@@ -317,7 +317,7 @@ unlink_from_freelist(Dir *e, int s, Vol *d)
 inline Dir *
 dir_delete_entry(Dir *e, Dir *p, int s, Vol *d)
 {
-  Dir *seg         = dir_segment(s, d);
+  Dir *seg         = d->dir_segment(s);
   int no           = dir_next(e);
   d->header->dirty = 1;
   if (p) {
@@ -348,7 +348,7 @@ inline void
 dir_clean_bucket(Dir *b, int s, Vol *vol)
 {
   Dir *e = b, *p = nullptr;
-  Dir *seg = dir_segment(s, vol);
+  Dir *seg = vol->dir_segment(s);
 #ifdef LOOP_CHECK_MODE
   int loop_count = 0;
 #endif
@@ -379,7 +379,7 @@ dir_clean_bucket(Dir *b, int s, Vol *vol)
 void
 dir_clean_segment(int s, Vol *d)
 {
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   for (int64_t i = 0; i < d->buckets; i++) {
     dir_clean_bucket(dir_bucket(i, seg), s, d);
     ink_assert(!dir_next(dir_bucket(i, seg)) || dir_offset(dir_bucket(i, seg)));
@@ -430,7 +430,7 @@ freelist_clean(int s, Vol *vol)
   }
   Warning("cache directory overflow on '%s' segment %d, purging...", vol->path, s);
   int n    = 0;
-  Dir *seg = dir_segment(s, vol);
+  Dir *seg = vol->dir_segment(s);
   for (int bi = 0; bi < vol->buckets; bi++) {
     Dir *b = dir_bucket(bi, seg);
     for (int l = 0; l < DIR_DEPTH; l++) {
@@ -447,7 +447,7 @@ freelist_clean(int s, Vol *vol)
 inline Dir *
 freelist_pop(int s, Vol *d)
 {
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   Dir *e   = dir_from_offset(d->header->freelist[s], seg);
   if (!e) {
     freelist_clean(s, d);
@@ -473,7 +473,7 @@ dir_segment_accounted(int s, Vol *d, int offby, int *f, int *u, int *et,
int *v,
   int used = 0, empty = 0;
   int valid = 0, agg_valid = 0;
   int64_t agg_size = 0;
-  Dir *seg         = dir_segment(s, d);
+  Dir *seg         = d->dir_segment(s);
   for (int bi = 0; bi < d->buckets; bi++) {
     Dir *b = dir_bucket(bi, seg);
     Dir *e = b;
@@ -522,7 +522,7 @@ dir_segment_accounted(int s, Vol *d, int offby, int *f, int *u, int *et,
int *v,
 void
 dir_free_entry(Dir *e, int s, Vol *d)
 {
-  Dir *seg        = dir_segment(s, d);
+  Dir *seg        = d->dir_segment(s);
   unsigned int fo = d->header->freelist[s];
   unsigned int eo = dir_to_offset(e, seg);
   dir_set_next(e, fo);
@@ -538,7 +538,7 @@ dir_probe(const CacheKey *key, Vol *d, Dir *result, Dir **last_collision)
   ink_assert(d->mutex->thread_holding == this_ethread());
   int s    = key->slice32(0) % d->segments;
   int b    = key->slice32(1) % d->buckets;
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   Dir *e = nullptr, *p = nullptr, *collision = *last_collision;
   Vol *vol = d;
   CHECK_DIR(d);
@@ -606,7 +606,7 @@ dir_insert(const CacheKey *key, Vol *d, Dir *to_part)
   int s  = key->slice32(0) % d->segments, l;
   int bi = key->slice32(1) % d->buckets;
   ink_assert(dir_approx_size(to_part) <= MAX_FRAG_SIZE + sizeof(Doc));
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   Dir *e   = nullptr;
   Dir *b   = dir_bucket(bi, seg);
   Vol *vol = d;
@@ -659,7 +659,7 @@ dir_overwrite(const CacheKey *key, Vol *d, Dir *dir, Dir *overwrite, bool
must_o
   ink_assert(d->mutex->thread_holding == this_ethread());
   int s          = key->slice32(0) % d->segments, l;
   int bi         = key->slice32(1) % d->buckets;
-  Dir *seg       = dir_segment(s, d);
+  Dir *seg       = d->dir_segment(s);
   Dir *e         = nullptr;
   Dir *b         = dir_bucket(bi, seg);
   unsigned int t = DIR_MASK_TAG(key->slice32(2));
@@ -735,7 +735,7 @@ dir_delete(const CacheKey *key, Vol *d, Dir *del)
   ink_assert(d->mutex->thread_holding == this_ethread());
   int s    = key->slice32(0) % d->segments;
   int b    = key->slice32(1) % d->buckets;
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   Dir *e = nullptr, *p = nullptr;
 #ifdef LOOP_CHECK_MODE
   int loop_count = 0;
@@ -905,7 +905,7 @@ dir_entries_used(Vol *d)
   uint64_t full  = 0;
   uint64_t sfull = 0;
   for (int s = 0; s < d->segments; full += sfull, s++) {
-    Dir *seg = dir_segment(s, d);
+    Dir *seg = d->dir_segment(s);
     sfull    = 0;
     for (int b = 0; b < d->buckets; b++) {
       Dir *e = dir_bucket(b, seg);
@@ -953,7 +953,7 @@ sync_cache_dir_on_shutdown()
       Debug("cache_dir_sync", "Dir %s: ignoring -- bad disk", d->hash_text.get());
       continue;
     }
-    size_t dirlen = vol_dirlen(d);
+    size_t dirlen = d->dirlen();
     ink_assert(dirlen > 0); // make clang happy - if not > 0 the vol is seriously messed
up
     if (!d->header->dirty && !d->dir_sync_in_progress) {
       Debug("cache_dir_sync", "Dir %s: ignoring -- not dirty", d->hash_text.get());
@@ -1092,7 +1092,7 @@ Lrestart:
     }
 
     int headerlen = ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
-    size_t dirlen = vol_dirlen(vol);
+    size_t dirlen = vol->dirlen();
     if (!writepos) {
       // start
       Debug("cache_dir_sync", "sync started");
@@ -1216,7 +1216,7 @@ int Vol::dir_check(bool /* fix ATS_UNUSED */) // TODO: we should eliminate
this
   printf("  Entries:   %" PRIu64 "\n", total_entries);
 
   for (int s = 0; s < segments; s++) {
-    Dir *seg               = dir_segment(s, this);
+    Dir *seg               = this->dir_segment(s);
     int seg_chain_max      = 0;
     int seg_empty          = 0;
     int seg_in_use         = 0;
@@ -1406,7 +1406,7 @@ dir_corrupt_bucket(Dir *b, int s, Vol *d)
   // coverity[dont_call]
   int l    = ((int)(dir_bucket_length(b, s, d) * drand48()));
   Dir *e   = b;
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
   for (int i = 0; i < l; i++) {
     ink_release_assert(e);
     e = next_dir(e, seg);
@@ -1445,7 +1445,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
   rand_CacheKey(&key, thread->mutex);
 
   int s    = key.slice32(0) % d->segments, i, j;
-  Dir *seg = dir_segment(s, d);
+  Dir *seg = d->dir_segment(s);
 
   // test insert
   rprintf(t, "insert test\n", free);
@@ -1508,7 +1508,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     rprintf(t, "probe rate = %d / second\n", (int)((newfree * (uint64_t)1000000) / us));
   }
 
-  for (int c = 0; c < vol_direntries(d) * 0.75; c++) {
+  for (int c = 0; c < d->direntries() * 0.75; c++) {
     regress_rand_CacheKey(&key);
     dir_insert(&key, d, &dir);
   }
@@ -1524,7 +1524,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     rand_CacheKey(&key, thread->mutex);
     s1 = key.slice32(0) % d->segments;
     b1 = key.slice32(1) % d->buckets;
-    dir_corrupt_bucket(dir_bucket(b1, dir_segment(s1, d)), s1, d);
+    dir_corrupt_bucket(dir_bucket(b1, d->dir_segment(s1)), s1, d);
     dir_insert(&key, d, &dir);
     Dir *last_collision = 0;
     dir_probe(&key, d, &dir, &last_collision);
@@ -1532,7 +1532,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     rand_CacheKey(&key, thread->mutex);
     s1 = key.slice32(0) % d->segments;
     b1 = key.slice32(1) % d->buckets;
-    dir_corrupt_bucket(dir_bucket(b1, dir_segment(s1, d)), s1, d);
+    dir_corrupt_bucket(dir_bucket(b1, d->dir_segment(s1)), s1, d);
 
     last_collision = 0;
     dir_probe(&key, d, &dir, &last_collision);
@@ -1549,7 +1549,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     dir_insert(&key, d, &dir);
     key1.b[1] = 80;
     dir_insert(&key1, d, &dir1);
-    dir_corrupt_bucket(dir_bucket(b1, dir_segment(s1, d)), s1, d);
+    dir_corrupt_bucket(dir_bucket(b1, d->dir_segment(s1)), s1, d);
     dir_overwrite(&key, d, &dir, &dir, 1);
 
     rand_CacheKey(&key, thread->mutex);
@@ -1557,12 +1557,12 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     b1       = key.slice32(1) % d->buckets;
     key.b[1] = 23;
     dir_insert(&key, d, &dir1);
-    dir_corrupt_bucket(dir_bucket(b1, dir_segment(s1, d)), s1, d);
+    dir_corrupt_bucket(dir_bucket(b1, d->dir_segment(s1)), s1, d);
     dir_overwrite(&key, d, &dir, &dir, 0);
 
     rand_CacheKey(&key, thread->mutex);
     s1        = key.slice32(0) % d->segments;
-    Dir *seg1 = dir_segment(s1, d);
+    Dir *seg1 = d->dir_segment(s1);
     // dir_freelist_length in freelist with loop
     dir_corrupt_bucket(dir_from_offset(d->header->freelist[s], seg1), s1, d);
     dir_freelist_length(d, s1);
@@ -1571,8 +1571,8 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     s1 = key.slice32(0) % d->segments;
     b1 = key.slice32(1) % d->buckets;
     // dir_bucket_length in bucket with loop
-    dir_corrupt_bucket(dir_bucket(b1, dir_segment(s1, d)), s1, d);
-    dir_bucket_length(dir_bucket(b1, dir_segment(s1, d)), s1, d);
+    dir_corrupt_bucket(dir_bucket(b1, d->dir_segment(s1)), s1, d);
+    dir_bucket_length(dir_bucket(b1, d->dir_segment(s1)), s1, d);
     if (!check_dir(d))
       ret = REGRESSION_TEST_FAILED;
 #else
@@ -1586,7 +1586,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, int /* atype
ATS_UNUSED
     dir_insert(&key, d, &dir1);
     dir_insert(&key, d, &dir1);
     dir_insert(&key, d, &dir1);
-    dir_corrupt_bucket(dir_bucket(b1, dir_segment(s1, d)), s1, d);
+    dir_corrupt_bucket(dir_bucket(b1, d->dir_segment(s1)), s1, d);
     if (check_dir(d)) {
       ret = REGRESSION_TEST_FAILED;
     }
diff --git a/iocore/cache/CacheVol.cc b/iocore/cache/CacheVol.cc
index 45c8598..a9b4853 100644
--- a/iocore/cache/CacheVol.cc
+++ b/iocore/cache/CacheVol.cc
@@ -134,7 +134,7 @@ make_vol_map(Vol *d)
   // Scan directories.
   // Copied from dir_entries_used() and modified to fill in the map instead.
   for (int s = 0; s < d->segments; s++) {
-    Dir *seg = dir_segment(s, d);
+    Dir *seg = d->dir_segment(s);
     for (int b = 0; b < d->buckets; b++) {
       Dir *e = dir_bucket(b, seg);
       if (dir_bucket_loop_fix(e, s, d)) {
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index d633799..c120e62 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -285,7 +285,7 @@ Vol::scan_for_pinned_documents()
     int vol_end_offset    = offset_to_vol_offset(this, len + skip);
     int before_end_of_vol = pe < vol_end_offset;
     DDebug("cache_evac", "scan %d %d", ps, pe);
-    for (int i = 0; i < vol_direntries(this); i++) {
+    for (int i = 0; i < this->direntries(); i++) {
       // is it a valid pinned object?
       if (!dir_is_empty(&dir[i]) && dir_pinned(&dir[i]) && dir_head(&dir[i]))
{
         // select objects only within this PIN_SCAN region
diff --git a/iocore/cache/P_CacheDir.h b/iocore/cache/P_CacheDir.h
index ac3fee3..24213ae 100644
--- a/iocore/cache/P_CacheDir.h
+++ b/iocore/cache/P_CacheDir.h
@@ -103,7 +103,6 @@ struct CacheVC;
     (_e)->w[4] = 0;   \
   } while (0)
 #define dir_clean(_e) dir_set_offset(_e, 0)
-#define dir_segment(_s, _d) vol_dir_segment(_d, _s)
 
 // OpenDir
 
diff --git a/iocore/cache/P_CacheVol.h b/iocore/cache/P_CacheVol.h
index 082e195..6ffb63b 100644
--- a/iocore/cache/P_CacheVol.h
+++ b/iocore/cache/P_CacheVol.h
@@ -243,6 +243,12 @@ struct Vol : public Continuation {
   int within_hit_evacuate_window(Dir *dir);
   uint32_t round_to_approx_size(uint32_t l);
 
+  // inline functions
+  TS_INLINE int headerlen();         // calculates the total length of the vol header and
the freelist
+  TS_INLINE int direntries();        // total number of dir entries
+  TS_INLINE Dir *dir_segment(int s); // returns the first dir in the segment s
+  TS_INLINE size_t dirlen();         // calculates the total length of header, directories
and footer
+
   Vol() : Continuation(new_ProxyMutex())
   {
     open_dir.mutex = mutex;
@@ -321,22 +327,28 @@ extern unsigned short *vol_hash_table;
 // inline Functions
 
 TS_INLINE int
-vol_headerlen(Vol *d)
+Vol::headerlen()
+{
+  return ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter) + sizeof(uint16_t) * (this->segments
- 1));
+}
+
+TS_INLINE Dir *
+Vol::dir_segment(int s)
 {
-  return ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter) + sizeof(uint16_t) * (d->segments
- 1));
+  return (Dir *)(((char *)this->dir) + (s * this->buckets) * DIR_DEPTH * SIZEOF_DIR);
 }
 
 TS_INLINE size_t
-vol_dirlen(Vol *d)
+Vol::dirlen()
 {
-  return vol_headerlen(d) + ROUND_TO_STORE_BLOCK(((size_t)d->buckets) * DIR_DEPTH * d->segments
* SIZEOF_DIR) +
+  return this->headerlen() + ROUND_TO_STORE_BLOCK(((size_t)this->buckets) * DIR_DEPTH
* this->segments * SIZEOF_DIR) +
          ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
 }
 
 TS_INLINE int
-vol_direntries(Vol *d)
+Vol::direntries()
 {
-  return d->buckets * DIR_DEPTH * d->segments;
+  return this->buckets * DIR_DEPTH * this->segments;
 }
 
 TS_INLINE int
@@ -381,12 +393,6 @@ vol_offset_to_offset(Vol *d, off_t pos)
   return d->start + pos * CACHE_BLOCK_SIZE - CACHE_BLOCK_SIZE;
 }
 
-TS_INLINE Dir *
-vol_dir_segment(Vol *d, int s)
-{
-  return (Dir *)(((char *)d->dir) + (s * d->buckets) * DIR_DEPTH * SIZEOF_DIR);
-}
-
 TS_INLINE int
 vol_in_phase_agg_buf_valid(Vol *d, Dir *e)
 {

-- 
To stop receiving notification emails like this one, please contact
paziz@apache.org.

Mime
View raw message