You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by pa...@apache.org on 2018/04/26 14:25:25 UTC
[trafficserver] branch master updated: Move inline functions into
class
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 34f31c1 Move inline functions into class
34f31c1 is described below
commit 34f31c1e96ce3f1292b10b07c4b1e2b00273dbdb
Author: Persia Aziz <pe...@yahoo-inc.com>
AuthorDate: Wed Apr 25 16:52:21 2018 -0500
Move inline functions into class
---
iocore/cache/Cache.cc | 8 +++---
iocore/cache/CacheDir.cc | 4 +--
iocore/cache/CachePagesInternal.cc | 2 +-
iocore/cache/CacheRead.cc | 4 +--
iocore/cache/CacheVol.cc | 14 +++++-----
iocore/cache/CacheWrite.cc | 24 ++++++++--------
iocore/cache/P_CacheDir.h | 6 ++--
iocore/cache/P_CacheVol.h | 57 +++++++++++++++++++++++---------------
8 files changed, 65 insertions(+), 54 deletions(-)
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 0e941c3..6acb1e7 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -1673,8 +1673,8 @@ Ldone : {
next_sync_serial++;
}
// clear effected portion of the cache
- off_t clear_start = offset_to_vol_offset(this, header->write_pos);
- off_t clear_end = offset_to_vol_offset(this, recover_pos);
+ off_t clear_start = this->offset_to_vol_offset(header->write_pos);
+ off_t clear_end = this->offset_to_vol_offset(recover_pos);
if (clear_start <= clear_end) {
dir_clear_range(clear_start, clear_end, this);
} else {
@@ -2459,7 +2459,7 @@ CacheVC::handleRead(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
}
// see if its in the aggregation buffer
if (dir_agg_buf_valid(vol, &dir)) {
- int agg_offset = vol_offset(vol, &dir) - vol->header->write_pos;
+ int agg_offset = vol->vol_offset(&dir) - vol->header->write_pos;
buf = new_IOBufferData(iobuffer_size_to_index(io.aiocb.aio_nbytes, MAX_BUFFER_SIZE_INDEX), MEMALIGNED);
ink_assert((agg_offset + io.aiocb.aio_nbytes) <= (unsigned)vol->agg_buf_pos);
char *doc = buf->data();
@@ -2471,7 +2471,7 @@ CacheVC::handleRead(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
}
io.aiocb.aio_fildes = vol->fd;
- io.aiocb.aio_offset = vol_offset(vol, &dir);
+ io.aiocb.aio_offset = vol->vol_offset(&dir);
if ((off_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes) > (off_t)(vol->skip + vol->len)) {
io.aiocb.aio_nbytes = vol->skip + vol->len - io.aiocb.aio_offset;
}
diff --git a/iocore/cache/CacheDir.cc b/iocore/cache/CacheDir.cc
index 4ddccbf..fb045f2 100644
--- a/iocore/cache/CacheDir.cc
+++ b/iocore/cache/CacheDir.cc
@@ -644,7 +644,7 @@ Llink:
Lfill:
dir_assign_data(e, to_part);
dir_set_tag(e, key->slice32(2));
- ink_assert(vol_offset(d, e) < (d->skip + d->len));
+ ink_assert(d->vol_offset(e) < (d->skip + d->len));
DDebug("dir_insert", "insert %p %X into vol %d bucket %d at %p tag %X %X boffset %" PRId64 "", e, key->slice32(0), d->fd, bi, e,
key->slice32(1), dir_tag(e), dir_offset(e));
CHECK_DIR(d);
@@ -721,7 +721,7 @@ Llink:
Lfill:
dir_assign_data(e, dir);
dir_set_tag(e, t);
- ink_assert(vol_offset(d, e) < d->skip + d->len);
+ ink_assert(d->vol_offset(e) < d->skip + d->len);
DDebug("dir_overwrite", "overwrite %p %X into vol %d bucket %d at %p tag %X %X boffset %" PRId64 "", e, key->slice32(0), d->fd,
bi, e, t, dir_tag(e), dir_offset(e));
CHECK_DIR(d);
diff --git a/iocore/cache/CachePagesInternal.cc b/iocore/cache/CachePagesInternal.cc
index 10945af..3799621 100644
--- a/iocore/cache/CachePagesInternal.cc
+++ b/iocore/cache/CachePagesInternal.cc
@@ -206,7 +206,7 @@ ShowCacheInternal::showVolEvacuations(int event, Event *e)
for (int i = 0; i < last; i++) {
for (b = p->evacuate[i].head; b; b = b->link.next) {
char offset[60];
- sprintf(offset, "%" PRIu64 "", (uint64_t)vol_offset(p, &b->dir));
+ sprintf(offset, "%" PRIu64 "", (uint64_t)p->vol_offset(&b->dir));
CHECK_SHOW(show("<tr>"
"<td>%s</td>" // offset
"<td>%d</td>" // estimated size
diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc
index feb568c..662a102 100644
--- a/iocore/cache/CacheRead.cc
+++ b/iocore/cache/CacheRead.cc
@@ -875,7 +875,7 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS
if (vol->within_hit_evacuate_window(&earliest_dir) &&
(!cache_config_hit_evacuate_size_limit || doc_len <= (uint64_t)cache_config_hit_evacuate_size_limit)) {
DDebug("cache_hit_evac", "dir: %" PRId64 ", write: %" PRId64 ", phase: %d", dir_offset(&earliest_dir),
- offset_to_vol_offset(vol, vol->header->write_pos), vol->header->phase);
+ vol->offset_to_vol_offset(vol->header->write_pos), vol->header->phase);
f.hit_evacuate = 1;
}
goto Lsuccess;
@@ -1159,7 +1159,7 @@ CacheVC::openReadStartHead(int event, Event *e)
if (vol->within_hit_evacuate_window(&dir) &&
(!cache_config_hit_evacuate_size_limit || doc_len <= (uint64_t)cache_config_hit_evacuate_size_limit)) {
DDebug("cache_hit_evac", "dir: %" PRId64 ", write: %" PRId64 ", phase: %d", dir_offset(&dir),
- offset_to_vol_offset(vol, vol->header->write_pos), vol->header->phase);
+ vol->offset_to_vol_offset(vol->header->write_pos), vol->header->phase);
f.hit_evacuate = 1;
}
diff --git a/iocore/cache/CacheVol.cc b/iocore/cache/CacheVol.cc
index a9b4853..98009a4 100644
--- a/iocore/cache/CacheVol.cc
+++ b/iocore/cache/CacheVol.cc
@@ -98,9 +98,9 @@ Ldone:
static off_t
next_in_map(Vol *d, char *vol_map, off_t offset)
{
- off_t start_offset = vol_offset_to_offset(d, 0);
+ off_t start_offset = d->vol_offset_to_offset(0);
off_t new_off = (offset - start_offset);
- off_t vol_len = vol_relative_length(d, start_offset);
+ off_t vol_len = d->vol_relative_length(start_offset);
while (new_off < vol_len && !vol_map[new_off / SCAN_BUF_SIZE]) {
new_off += SCAN_BUF_SIZE;
@@ -124,8 +124,8 @@ static char *
make_vol_map(Vol *d)
{
// Map will be one byte for each SCAN_BUF_SIZE bytes.
- off_t start_offset = vol_offset_to_offset(d, 0);
- off_t vol_len = vol_relative_length(d, start_offset);
+ off_t start_offset = d->vol_offset_to_offset(0);
+ off_t vol_len = d->vol_relative_length(start_offset);
size_t map_len = (vol_len + (SCAN_BUF_SIZE - 1)) / SCAN_BUF_SIZE;
char *vol_map = (char *)ats_malloc(map_len);
@@ -142,7 +142,7 @@ make_vol_map(Vol *d)
}
while (e) {
if (dir_offset(e) && dir_valid(d, e) && dir_agg_valid(d, e) && dir_head(e)) {
- off_t offset = vol_offset(d, e) - start_offset;
+ off_t offset = d->vol_offset(e) - start_offset;
if (offset <= vol_len) {
vol_map[offset / SCAN_BUF_SIZE] = 1;
}
@@ -186,7 +186,7 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
if (!fragment) { // initialize for first read
fragment = 1;
scan_vol_map = make_vol_map(vol);
- io.aiocb.aio_offset = next_in_map(vol, scan_vol_map, vol_offset_to_offset(vol, 0));
+ io.aiocb.aio_offset = next_in_map(vol, scan_vol_map, vol->vol_offset_to_offset(0));
if (io.aiocb.aio_offset >= (off_t)(vol->skip + vol->len)) {
goto Lnext_vol;
}
@@ -236,7 +236,7 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
goto Lskip;
}
if (!dir_agg_valid(vol, &dir) || !dir_head(&dir) ||
- (vol_offset(vol, &dir) != io.aiocb.aio_offset + ((char *)doc - buf->data()))) {
+ (vol->vol_offset(&dir) != io.aiocb.aio_offset + ((char *)doc - buf->data()))) {
continue;
}
break;
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index df1e8af..ff8d66e 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -280,9 +280,9 @@ Vol::scan_for_pinned_documents()
if (cache_config_permit_pinning) {
// we can't evacuate anything between header->write_pos and
// header->write_pos + AGG_SIZE.
- int ps = offset_to_vol_offset(this, header->write_pos + AGG_SIZE);
- int pe = offset_to_vol_offset(this, header->write_pos + 2 * EVACUATION_SIZE + (len / PIN_SCAN_EVERY));
- int vol_end_offset = offset_to_vol_offset(this, len + skip);
+ int ps = this->offset_to_vol_offset(header->write_pos + AGG_SIZE);
+ int pe = this->offset_to_vol_offset(header->write_pos + 2 * EVACUATION_SIZE + (len / PIN_SCAN_EVERY));
+ int vol_end_offset = this->offset_to_vol_offset(len + skip);
int before_end_of_vol = pe < vol_end_offset;
DDebug("cache_evac", "scan %d %d", ps, pe);
for (int i = 0; i < this->direntries(); i++) {
@@ -695,8 +695,8 @@ Ldone:
int
Vol::evac_range(off_t low, off_t high, int evac_phase)
{
- off_t s = offset_to_vol_offset(this, low);
- off_t e = offset_to_vol_offset(this, high);
+ off_t s = this->offset_to_vol_offset(low);
+ off_t e = this->offset_to_vol_offset(high);
int si = dir_offset_evac_bucket(s);
int ei = dir_offset_evac_bucket(e);
@@ -718,7 +718,7 @@ Vol::evac_range(off_t low, off_t high, int evac_phase)
first->f.done = 1;
io.aiocb.aio_fildes = fd;
io.aiocb.aio_nbytes = dir_approx_size(&first->dir);
- io.aiocb.aio_offset = vol_offset(this, &first->dir);
+ io.aiocb.aio_offset = this->vol_offset(&first->dir);
if ((off_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes) > (off_t)(skip + len)) {
io.aiocb.aio_nbytes = skip + len - io.aiocb.aio_offset;
}
@@ -752,8 +752,8 @@ agg_copy(char *p, CacheVC *vc)
ink_assert(vol->round_to_approx_size(len) == vc->agg_len);
// update copy of directory entry for this document
dir_set_approx_size(&vc->dir, vc->agg_len);
- dir_set_offset(&vc->dir, offset_to_vol_offset(vol, o));
- ink_assert(vol_offset(vol, &vc->dir) < (vol->skip + vol->len));
+ dir_set_offset(&vc->dir, vol->offset_to_vol_offset(o));
+ ink_assert(vol->vol_offset(&vc->dir) < (vol->skip + vol->len));
dir_set_phase(&vc->dir, vol->header->phase);
// fill in document header
@@ -877,7 +877,7 @@ agg_copy(char *p, CacheVC *vc)
memcpy(p, doc, doc->len);
vc->dir = vc->overwrite_dir;
- dir_set_offset(&vc->dir, offset_to_vol_offset(vc->vol, o));
+ dir_set_offset(&vc->dir, vc->vol->offset_to_vol_offset(o));
dir_set_phase(&vc->dir, vc->vol->header->phase);
return l;
}
@@ -888,8 +888,8 @@ Vol::evacuate_cleanup_blocks(int i)
{
EvacuationBlock *b = evacuate[i].head;
while (b) {
- if (b->f.done && ((header->phase != dir_phase(&b->dir) && header->write_pos > vol_offset(this, &b->dir)) ||
- (header->phase == dir_phase(&b->dir) && header->write_pos <= vol_offset(this, &b->dir)))) {
+ if (b->f.done && ((header->phase != dir_phase(&b->dir) && header->write_pos > this->vol_offset(&b->dir)) ||
+ (header->phase == dir_phase(&b->dir) && header->write_pos <= this->vol_offset(&b->dir)))) {
EvacuationBlock *x = b;
DDebug("cache_evac", "evacuate cleanup free %X offset %d", (int)b->evac_frags.key.slice32(0), (int)dir_offset(&b->dir));
b = b->link.next;
@@ -1532,7 +1532,7 @@ CacheVC::openWriteStartDone(int event, Event *e)
*/
if (!dir_valid(vol, &dir)) {
DDebug("cache_write", "OpenReadStartDone: Dir not valid: Write Head: %" PRId64 ", Dir: %" PRId64,
- (int64_t)offset_to_vol_offset(vol, vol->header->write_pos), dir_offset(&dir));
+ (int64_t)vol->offset_to_vol_offset(vol->header->write_pos), dir_offset(&dir));
last_collision = nullptr;
goto Lcollision;
}
diff --git a/iocore/cache/P_CacheDir.h b/iocore/cache/P_CacheDir.h
index 4c0f73c..27a31b4 100644
--- a/iocore/cache/P_CacheDir.h
+++ b/iocore/cache/P_CacheDir.h
@@ -85,13 +85,13 @@ struct CacheVC;
dir_set_next(_e, next); \
} while (0)
// entry is valid
-#define dir_valid(_d, _e) (_d->header->phase == dir_phase(_e) ? vol_in_phase_valid(_d, _e) : vol_out_of_phase_valid(_d, _e))
+#define dir_valid(_d, _e) (_d->header->phase == dir_phase(_e) ? _d->vol_in_phase_valid(_e) : _d->vol_out_of_phase_valid(_e))
// entry is valid and outside of write aggregation region
-#define dir_agg_valid(_d, _e) (_d->header->phase == dir_phase(_e) ? vol_in_phase_valid(_d, _e) : vol_out_of_phase_agg_valid(_d, _e))
+#define dir_agg_valid(_d, _e) (_d->header->phase == dir_phase(_e) ? _d->vol_in_phase_valid(_e) : _d->vol_out_of_phase_agg_valid(_e))
// entry may be valid or overwritten in the last aggregated write
#define dir_write_valid(_d, _e) \
(_d->header->phase == dir_phase(_e) ? vol_in_phase_valid(_d, _e) : vol_out_of_phase_write_valid(_d, _e))
-#define dir_agg_buf_valid(_d, _e) (_d->header->phase == dir_phase(_e) && vol_in_phase_agg_buf_valid(_d, _e))
+#define dir_agg_buf_valid(_d, _e) (_d->header->phase == dir_phase(_e) && _d->vol_in_phase_agg_buf_valid(_e))
#define dir_is_empty(_e) (!dir_offset(_e))
#define dir_clear(_e) \
do { \
diff --git a/iocore/cache/P_CacheVol.h b/iocore/cache/P_CacheVol.h
index b86ee64..d8c334c 100644
--- a/iocore/cache/P_CacheVol.h
+++ b/iocore/cache/P_CacheVol.h
@@ -57,7 +57,7 @@
#define dir_offset_evac_bucket(_o) (_o / (EVACUATION_BUCKET_SIZE / CACHE_BLOCK_SIZE))
#define dir_evac_bucket(_e) dir_offset_evac_bucket(dir_offset(_e))
#define offset_evac_bucket(_d, _o) \
- dir_offset_evac_bucket((offset_to_vol_offset(_d, _o)
+ dir_offset_evac_bucket((_d->offset_to_vol_offset(_o)
// Documents
@@ -243,10 +243,21 @@ struct Vol : public Continuation {
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
+ int headerlen(); // calculates the total length of the vol header and the freelist
+ int direntries(); // total number of dir entries
+ Dir *dir_segment(int s); // returns the first dir in the segment s
+ size_t dirlen(); // calculates the total length of header, directories and footer
+ int vol_out_of_phase_valid(Dir *e);
+
+ int vol_out_of_phase_agg_valid(Dir *e);
+ int vol_out_of_phase_write_valid(Dir *e);
+ int vol_in_phase_valid(Dir *e);
+ int vol_in_phase_agg_buf_valid(Dir *e);
+
+ off_t vol_offset(Dir *e);
+ off_t offset_to_vol_offset(off_t pos);
+ off_t vol_offset_to_offset(off_t pos);
+ off_t vol_relative_length(off_t start_offset);
Vol() : Continuation(new_ProxyMutex())
{
@@ -351,57 +362,57 @@ Vol::direntries()
}
TS_INLINE int
-vol_out_of_phase_valid(Vol *d, Dir *e)
+Vol::vol_out_of_phase_valid(Dir *e)
{
- return (dir_offset(e) - 1 >= ((d->header->agg_pos - d->start) / CACHE_BLOCK_SIZE));
+ return (dir_offset(e) - 1 >= ((this->header->agg_pos - this->start) / CACHE_BLOCK_SIZE));
}
TS_INLINE int
-vol_out_of_phase_agg_valid(Vol *d, Dir *e)
+Vol::vol_out_of_phase_agg_valid(Dir *e)
{
- return (dir_offset(e) - 1 >= ((d->header->agg_pos - d->start + AGG_SIZE) / CACHE_BLOCK_SIZE));
+ return (dir_offset(e) - 1 >= ((this->header->agg_pos - this->start + AGG_SIZE) / CACHE_BLOCK_SIZE));
}
TS_INLINE int
-vol_out_of_phase_write_valid(Vol *d, Dir *e)
+Vol::vol_out_of_phase_write_valid(Dir *e)
{
- return (dir_offset(e) - 1 >= ((d->header->write_pos - d->start) / CACHE_BLOCK_SIZE));
+ return (dir_offset(e) - 1 >= ((this->header->write_pos - this->start) / CACHE_BLOCK_SIZE));
}
TS_INLINE int
-vol_in_phase_valid(Vol *d, Dir *e)
+Vol::vol_in_phase_valid(Dir *e)
{
- return (dir_offset(e) - 1 < ((d->header->write_pos + d->agg_buf_pos - d->start) / CACHE_BLOCK_SIZE));
+ return (dir_offset(e) - 1 < ((this->header->write_pos + this->agg_buf_pos - this->start) / CACHE_BLOCK_SIZE));
}
TS_INLINE off_t
-vol_offset(Vol *d, Dir *e)
+Vol::vol_offset(Dir *e)
{
- return d->start + (off_t)dir_offset(e) * CACHE_BLOCK_SIZE - CACHE_BLOCK_SIZE;
+ return this->start + (off_t)dir_offset(e) * CACHE_BLOCK_SIZE - CACHE_BLOCK_SIZE;
}
TS_INLINE off_t
-offset_to_vol_offset(Vol *d, off_t pos)
+Vol::offset_to_vol_offset(off_t pos)
{
- return ((pos - d->start + CACHE_BLOCK_SIZE) / CACHE_BLOCK_SIZE);
+ return ((pos - this->start + CACHE_BLOCK_SIZE) / CACHE_BLOCK_SIZE);
}
TS_INLINE off_t
-vol_offset_to_offset(Vol *d, off_t pos)
+Vol::vol_offset_to_offset(off_t pos)
{
- return d->start + pos * CACHE_BLOCK_SIZE - CACHE_BLOCK_SIZE;
+ return this->start + pos * CACHE_BLOCK_SIZE - CACHE_BLOCK_SIZE;
}
TS_INLINE int
-vol_in_phase_agg_buf_valid(Vol *d, Dir *e)
+Vol::vol_in_phase_agg_buf_valid(Dir *e)
{
- return (vol_offset(d, e) >= d->header->write_pos && vol_offset(d, e) < (d->header->write_pos + d->agg_buf_pos));
+ return (this->vol_offset(e) >= this->header->write_pos && this->vol_offset(e) < (this->header->write_pos + this->agg_buf_pos));
}
// length of the partition not including the offset of location 0.
TS_INLINE off_t
-vol_relative_length(Vol *v, off_t start_offset)
+Vol::vol_relative_length(off_t start_offset)
{
- return (v->len + v->skip) - start_offset;
+ return (this->len + this->skip) - start_offset;
}
TS_INLINE uint32_t
--
To stop receiving notification emails like this one, please contact
paziz@apache.org.