http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/CacheTest.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheTest.cc b/iocore/cache/CacheTest.cc
index 734f7a7..219eb97 100644
--- a/iocore/cache/CacheTest.cc
+++ b/iocore/cache/CacheTest.cc
@@ -29,26 +29,15 @@
 
 using namespace std;
 
-CacheTestSM::CacheTestSM(RegressionTest *t) :
-  RegressionSM(t),
-  timeout(0),
-  cache_action(0),
-  start_time(0),
-  cache_vc(0),
-  cvio(0),
-  buffer(0),
-  buffer_reader(0),
-  nbytes(-1),
-  repeat_count(0),
-  expect_event(EVENT_NONE),
-  expect_initial_event(EVENT_NONE),
-  initial_event(EVENT_NONE),
-  content_salt(0)
+CacheTestSM::CacheTestSM(RegressionTest *t)
+  : RegressionSM(t), timeout(0), cache_action(0), start_time(0), cache_vc(0), 
cvio(0), buffer(0), buffer_reader(0), nbytes(-1),
+    repeat_count(0), expect_event(EVENT_NONE), 
expect_initial_event(EVENT_NONE), initial_event(EVENT_NONE), content_salt(0)
 {
   SET_HANDLER(&CacheTestSM::event_handler);
 }
 
-CacheTestSM::~CacheTestSM() {
+CacheTestSM::~CacheTestSM()
+{
   ink_assert(!cache_action);
   ink_assert(!cache_vc);
   if (buffer_reader)
@@ -57,125 +46,129 @@ CacheTestSM::~CacheTestSM() {
     free_MIOBuffer(buffer);
 }
 
-int CacheTestSM::open_read_callout() {
+int
+CacheTestSM::open_read_callout()
+{
   cvio = cache_vc->do_io_read(this, nbytes, buffer);
   return 1;
 }
 
-int CacheTestSM::open_write_callout() {
+int
+CacheTestSM::open_write_callout()
+{
   cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
   return 1;
 }
 
-int CacheTestSM::event_handler(int event, void *data) {
-
+int
+CacheTestSM::event_handler(int event, void *data)
+{
   switch (event) {
-
-    case EVENT_INTERVAL:
-    case EVENT_IMMEDIATE:
-      cancel_timeout();
-      if (cache_action) {
-        cache_action->cancel();
-        cache_action = 0;
-      }
-      if (cache_vc) {
-        cache_vc->do_io_close();
-        cache_vc = 0;
-      }
-      cvio = 0;
-      make_request();
-      return EVENT_DONE;
-
-    case CACHE_EVENT_LOOKUP_FAILED:
-    case CACHE_EVENT_LOOKUP:
-      goto Lcancel_next;
-
-    case CACHE_EVENT_OPEN_READ:
-      initial_event = event;
-      cancel_timeout();
+  case EVENT_INTERVAL:
+  case EVENT_IMMEDIATE:
+    cancel_timeout();
+    if (cache_action) {
+      cache_action->cancel();
       cache_action = 0;
-      cache_vc = (CacheVConnection*)data;
-      buffer = new_empty_MIOBuffer();
-      buffer_reader = buffer->alloc_reader();
-      if (open_read_callout() < 0)
-        goto Lclose_error_next;
-      else
-        return EVENT_DONE;
-
-    case CACHE_EVENT_OPEN_READ_FAILED:
-      goto Lcancel_next;
+    }
+    if (cache_vc) {
+      cache_vc->do_io_close();
+      cache_vc = 0;
+    }
+    cvio = 0;
+    make_request();
+    return EVENT_DONE;
 
-    case VC_EVENT_READ_READY:
-      if (!check_buffer())
-        goto Lclose_error_next;
-      buffer_reader->consume(buffer_reader->read_avail());
-      ((VIO*)data)->reenable();
-      return EVENT_CONT;
+  case CACHE_EVENT_LOOKUP_FAILED:
+  case CACHE_EVENT_LOOKUP:
+    goto Lcancel_next;
+
+  case CACHE_EVENT_OPEN_READ:
+    initial_event = event;
+    cancel_timeout();
+    cache_action = 0;
+    cache_vc = (CacheVConnection *)data;
+    buffer = new_empty_MIOBuffer();
+    buffer_reader = buffer->alloc_reader();
+    if (open_read_callout() < 0)
+      goto Lclose_error_next;
+    else
+      return EVENT_DONE;
 
-    case VC_EVENT_READ_COMPLETE:
-      if (!check_buffer())
-        goto Lclose_error_next;
-      goto Lclose_next;
+  case CACHE_EVENT_OPEN_READ_FAILED:
+    goto Lcancel_next;
 
-    case VC_EVENT_ERROR:
-    case VC_EVENT_EOS:
+  case VC_EVENT_READ_READY:
+    if (!check_buffer())
       goto Lclose_error_next;
+    buffer_reader->consume(buffer_reader->read_avail());
+    ((VIO *)data)->reenable();
+    return EVENT_CONT;
 
-    case CACHE_EVENT_OPEN_WRITE:
-      initial_event = event;
-      cancel_timeout();
-      cache_action = 0;
-      cache_vc = (CacheVConnection*)data;
-      buffer = new_empty_MIOBuffer();
-      buffer_reader = buffer->alloc_reader();
-      if (open_write_callout() < 0)
-        goto Lclose_error_next;
-      else
-        return EVENT_DONE;
+  case VC_EVENT_READ_COMPLETE:
+    if (!check_buffer())
+      goto Lclose_error_next;
+    goto Lclose_next;
+
+  case VC_EVENT_ERROR:
+  case VC_EVENT_EOS:
+    goto Lclose_error_next;
+
+  case CACHE_EVENT_OPEN_WRITE:
+    initial_event = event;
+    cancel_timeout();
+    cache_action = 0;
+    cache_vc = (CacheVConnection *)data;
+    buffer = new_empty_MIOBuffer();
+    buffer_reader = buffer->alloc_reader();
+    if (open_write_callout() < 0)
+      goto Lclose_error_next;
+    else
+      return EVENT_DONE;
 
-    case CACHE_EVENT_OPEN_WRITE_FAILED:
-      goto Lcancel_next;
+  case CACHE_EVENT_OPEN_WRITE_FAILED:
+    goto Lcancel_next;
 
-    case VC_EVENT_WRITE_READY:
-      fill_buffer();
-      cvio->reenable();
-      return EVENT_CONT;
+  case VC_EVENT_WRITE_READY:
+    fill_buffer();
+    cvio->reenable();
+    return EVENT_CONT;
 
-    case VC_EVENT_WRITE_COMPLETE:
-      if (nbytes != cvio->ndone)
-        goto Lclose_error_next;
-      goto Lclose_next;
+  case VC_EVENT_WRITE_COMPLETE:
+    if (nbytes != cvio->ndone)
+      goto Lclose_error_next;
+    goto Lclose_next;
 
-    case CACHE_EVENT_REMOVE:
-    case CACHE_EVENT_REMOVE_FAILED:
-      goto Lcancel_next;
+  case CACHE_EVENT_REMOVE:
+  case CACHE_EVENT_REMOVE_FAILED:
+    goto Lcancel_next;
 
-    case CACHE_EVENT_SCAN:
-      initial_event = event;
-      cache_vc = (CacheVConnection*)data;
-      return EVENT_CONT;
+  case CACHE_EVENT_SCAN:
+    initial_event = event;
+    cache_vc = (CacheVConnection *)data;
+    return EVENT_CONT;
 
-    case CACHE_EVENT_SCAN_OBJECT:
-      return CACHE_SCAN_RESULT_CONTINUE;
+  case CACHE_EVENT_SCAN_OBJECT:
+    return CACHE_SCAN_RESULT_CONTINUE;
 
-    case CACHE_EVENT_SCAN_OPERATION_FAILED:
-      return CACHE_SCAN_RESULT_CONTINUE;
+  case CACHE_EVENT_SCAN_OPERATION_FAILED:
+    return CACHE_SCAN_RESULT_CONTINUE;
 
-    case CACHE_EVENT_SCAN_OPERATION_BLOCKED:
-      return CACHE_SCAN_RESULT_CONTINUE;
+  case CACHE_EVENT_SCAN_OPERATION_BLOCKED:
+    return CACHE_SCAN_RESULT_CONTINUE;
 
-    case CACHE_EVENT_SCAN_DONE:
-      return EVENT_CONT;
+  case CACHE_EVENT_SCAN_DONE:
+    return EVENT_CONT;
 
-    case CACHE_EVENT_SCAN_FAILED:
-      return EVENT_CONT;
+  case CACHE_EVENT_SCAN_FAILED:
+    return EVENT_CONT;
 
-    case AIO_EVENT_DONE:
-      goto Lnext;
+  case AIO_EVENT_DONE:
+    goto Lnext;
 
-    default:
-      ink_assert(!"case");
-      break;
+  default:
+    ink_assert(!"case");
+    break;
   }
   return EVENT_DONE;
 
@@ -207,7 +200,9 @@ Lnext:
     return complete(event);
 }
 
-void CacheTestSM::fill_buffer() {
+void
+CacheTestSM::fill_buffer()
+{
   int64_t avail = buffer->write_avail();
   CacheKey k = key;
   k.b[1] += content_salt;
@@ -217,26 +212,28 @@ void CacheTestSM::fill_buffer() {
     if (l > sk)
       l = sk;
 
-    int64_t pos = cvio->ndone +  buffer_reader->read_avail();
+    int64_t pos = cvio->ndone + buffer_reader->read_avail();
     int64_t o = pos % sk;
 
     if (l > sk - o)
       l = sk - o;
     k.b[0] = pos / sk;
-    char *x = ((char*)&k) + o;
+    char *x = ((char *)&k) + o;
     buffer->write(x, l);
     buffer->fill(l);
     avail -= l;
   }
 }
 
-int CacheTestSM::check_buffer() {
+int
+CacheTestSM::check_buffer()
+{
   int64_t avail = buffer_reader->read_avail();
   CacheKey k = key;
   k.b[1] += content_salt;
   char b[sizeof(key)];
   int64_t sk = (int64_t)sizeof(key);
-  int64_t pos = cvio->ndone -  buffer_reader->read_avail();
+  int64_t pos = cvio->ndone - buffer_reader->read_avail();
   while (avail > 0) {
     int64_t l = avail;
     if (l > sk)
@@ -245,7 +242,7 @@ int CacheTestSM::check_buffer() {
     if (l > sk - o)
       l = sk - o;
     k.b[0] = pos / sk;
-    char *x = ((char*)&k) + o;
+    char *x = ((char *)&k) + o;
     buffer_reader->read(&b[0], l);
     if (::memcmp(b, x, l))
       return 0;
@@ -256,13 +253,15 @@ int CacheTestSM::check_buffer() {
   return 1;
 }
 
-int CacheTestSM::check_result(int event) {
-  return
-    initial_event == expect_initial_event &&
-    event == expect_event;
+int
+CacheTestSM::check_result(int event)
+{
+  return initial_event == expect_initial_event && event == expect_event;
 }
 
-int CacheTestSM::complete(int event) {
+int
+CacheTestSM::complete(int event)
+{
   if (!check_result(event))
     done(REGRESSION_TEST_FAILED);
   else
@@ -271,14 +270,16 @@ int CacheTestSM::complete(int event) {
   return EVENT_DONE;
 }
 
-CacheTestSM::CacheTestSM(const CacheTestSM &ao) : RegressionSM(ao) {
-  int o = (int)(((char*)&start_memcpy_on_clone) - ((char*)this));
-  int s = (int)(((char*)&end_memcpy_on_clone) - 
((char*)&start_memcpy_on_clone));
-  memcpy(((char*)this)+o, ((char*)&ao)+o, s);
+CacheTestSM::CacheTestSM(const CacheTestSM &ao) : RegressionSM(ao)
+{
+  int o = (int)(((char *)&start_memcpy_on_clone) - ((char *)this));
+  int s = (int)(((char *)&end_memcpy_on_clone) - ((char 
*)&start_memcpy_on_clone));
+  memcpy(((char *)this) + o, ((char *)&ao) + o, s);
   SET_HANDLER(&CacheTestSM::event_handler);
 }
 
-EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int /* atype ATS_UNUSED 
*/, int *pstatus) {
+EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int /* atype ATS_UNUSED 
*/, int *pstatus)
+{
   if (cacheProcessor.IsCacheEnabled() != CACHE_INITIALIZED) {
     rprintf(t, "cache not initialized");
     *pstatus = REGRESSION_TEST_FAILED;
@@ -287,45 +288,41 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int 
/* atype ATS_UNUSED */,
 
   EThread *thread = this_ethread();
 
-  CACHE_SM(t, write_test, { cacheProcessor.open_write(
-        this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
-        CACHE_WRITE_OPT_SYNC); } );
+  CACHE_SM(t, write_test, { cacheProcessor.open_write(this, &key, false, 
CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_SYNC); });
   write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
   write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
   write_test.nbytes = 100;
   rand_CacheKey(&write_test.key, thread->mutex);
 
-  CACHE_SM(t, lookup_test, { cacheProcessor.lookup(this, &key, false); } );
+  CACHE_SM(t, lookup_test, { cacheProcessor.lookup(this, &key, false); });
   lookup_test.expect_event = CACHE_EVENT_LOOKUP;
   lookup_test.key = write_test.key;
 
-  CACHE_SM(t, read_test, { cacheProcessor.open_read(this, &key, false); } );
+  CACHE_SM(t, read_test, { cacheProcessor.open_read(this, &key, false); });
   read_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
   read_test.expect_event = VC_EVENT_READ_COMPLETE;
   read_test.nbytes = 100;
   read_test.key = write_test.key;
 
-  CACHE_SM(t, remove_test, { cacheProcessor.remove(this, &key, false); } );
+  CACHE_SM(t, remove_test, { cacheProcessor.remove(this, &key, false); });
   remove_test.expect_event = CACHE_EVENT_REMOVE;
   remove_test.key = write_test.key;
 
-  CACHE_SM(t, lookup_fail_test, { cacheProcessor.lookup(this, &key, false); } 
);
+  CACHE_SM(t, lookup_fail_test, { cacheProcessor.lookup(this, &key, false); });
   lookup_fail_test.expect_event = CACHE_EVENT_LOOKUP_FAILED;
   lookup_fail_test.key = write_test.key;
 
-  CACHE_SM(t, read_fail_test, { cacheProcessor.open_read(this, &key, false); } 
);
+  CACHE_SM(t, read_fail_test, { cacheProcessor.open_read(this, &key, false); 
});
   read_fail_test.expect_event = CACHE_EVENT_OPEN_READ_FAILED;
   read_fail_test.key = write_test.key;
 
-  CACHE_SM(t, remove_fail_test, { cacheProcessor.remove(this, &key, false); } 
);
+  CACHE_SM(t, remove_fail_test, { cacheProcessor.remove(this, &key, false); });
   remove_fail_test.expect_event = CACHE_EVENT_REMOVE_FAILED;
   rand_CacheKey(&remove_fail_test.key, thread->mutex);
 
-  CACHE_SM(t, replace_write_test, {
-      cacheProcessor.open_write(this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
-                                CACHE_WRITE_OPT_SYNC);
-    }
-    int open_write_callout() {
+  CACHE_SM(
+    t, replace_write_test,
+    { cacheProcessor.open_write(this, &key, false, CACHE_FRAG_TYPE_NONE, 100, 
CACHE_WRITE_OPT_SYNC); } int open_write_callout() {
       header.serial = 10;
       cache_vc->set_header(&header, sizeof(header));
       cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
@@ -336,101 +333,83 @@ EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int 
/* atype ATS_UNUSED */,
   replace_write_test.nbytes = 100;
   rand_CacheKey(&replace_write_test.key, thread->mutex);
 
-  CACHE_SM(t, replace_test, {
-      cacheProcessor.open_write(this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
-                                CACHE_WRITE_OPT_OVERWRITE_SYNC);
-    }
-    int open_write_callout() {
-      CacheTestHeader *h = 0;
-      int hlen = 0;
-      if (cache_vc->get_header((void**)&h, &hlen) < 0)
-        return -1;
-      if (h->serial != 10)
-        return -1;
-      header.serial = 11;
-      cache_vc->set_header(&header, sizeof(header));
-      cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
-      return 1;
-    });
+  CACHE_SM(t, replace_test,
+           {
+             cacheProcessor.open_write(this, &key, false, 
CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_OVERWRITE_SYNC);
+           } int open_write_callout() {
+             CacheTestHeader *h = 0;
+             int hlen = 0;
+             if (cache_vc->get_header((void **)&h, &hlen) < 0)
+               return -1;
+             if (h->serial != 10)
+               return -1;
+             header.serial = 11;
+             cache_vc->set_header(&header, sizeof(header));
+             cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
+             return 1;
+           });
   replace_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
   replace_test.expect_event = VC_EVENT_WRITE_COMPLETE;
   replace_test.nbytes = 100;
   replace_test.key = replace_write_test.key;
   replace_test.content_salt = 1;
 
-  CACHE_SM(t, replace_read_test, {
-      cacheProcessor.open_read(this, &key, false);
-    }
-    int open_read_callout() {
-      CacheTestHeader *h = 0;
-      int hlen = 0;
-      if (cache_vc->get_header((void**)&h, &hlen) < 0)
-        return -1;
-      if (h->serial != 11)
-        return -1;
-      cvio = cache_vc->do_io_read(this, nbytes, buffer);
-      return 1;
-    });
+  CACHE_SM(t, replace_read_test, { cacheProcessor.open_read(this, &key, 
false); } int open_read_callout() {
+    CacheTestHeader *h = 0;
+    int hlen = 0;
+    if (cache_vc->get_header((void **)&h, &hlen) < 0)
+      return -1;
+    if (h->serial != 11)
+      return -1;
+    cvio = cache_vc->do_io_read(this, nbytes, buffer);
+    return 1;
+  });
   replace_read_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
   replace_read_test.expect_event = VC_EVENT_READ_COMPLETE;
   replace_read_test.nbytes = 100;
   replace_read_test.key = replace_test.key;
   replace_read_test.content_salt = 1;
 
-  CACHE_SM(t, large_write_test, { cacheProcessor.open_write(
-        this, &key, false, CACHE_FRAG_TYPE_NONE, 100,
-        CACHE_WRITE_OPT_SYNC); } );
+  CACHE_SM(t, large_write_test, { cacheProcessor.open_write(this, &key, false, 
CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_SYNC); });
   large_write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
   large_write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
   large_write_test.nbytes = 10000000;
   rand_CacheKey(&large_write_test.key, thread->mutex);
 
-  CACHE_SM(t, pread_test, {
-      cacheProcessor.open_read(this, &key, false);
-    }
-    int open_read_callout() {
-      cvio = cache_vc->do_io_pread(this, nbytes, buffer, 7000000);
-      return 1;
-    });
+  CACHE_SM(t, pread_test, { cacheProcessor.open_read(this, &key, false); } int 
open_read_callout() {
+    cvio = cache_vc->do_io_pread(this, nbytes, buffer, 7000000);
+    return 1;
+  });
   pread_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
   pread_test.expect_event = VC_EVENT_READ_COMPLETE;
   pread_test.nbytes = 100;
   pread_test.key = large_write_test.key;
 
-  r_sequential(
-    t,
-    write_test.clone(),
-    lookup_test.clone(),
-    r_sequential(t, 10, read_test.clone()),
-    remove_test.clone(),
-    lookup_fail_test.clone(),
-    read_fail_test.clone(),
-    remove_fail_test.clone(),
-    replace_write_test.clone(),
-    replace_test.clone(),
-    replace_read_test.clone(),
-    large_write_test.clone(),
-    pread_test.clone(),
-    NULL_PTR
-    )->run(pstatus);
+  r_sequential(t, write_test.clone(), lookup_test.clone(), r_sequential(t, 10, 
read_test.clone()), remove_test.clone(),
+               lookup_fail_test.clone(), read_fail_test.clone(), 
remove_fail_test.clone(), replace_write_test.clone(),
+               replace_test.clone(), replace_read_test.clone(), 
large_write_test.clone(), pread_test.clone(),
+               NULL_PTR)->run(pstatus);
   return;
 }
 
-void force_link_CacheTest() {
+void
+force_link_CacheTest()
+{
 }
 
 // run -R 3 -r cache_disk_replacement_stability
 
-REGRESSION_TEST(cache_disk_replacement_stability)(RegressionTest *t, int 
level, int *pstatus) {
+REGRESSION_TEST(cache_disk_replacement_stability)(RegressionTest *t, int 
level, int *pstatus)
+{
   static int const MAX_VOLS = 26; // maximum values used in any test.
   static uint64_t DEFAULT_SKIP = 8192;
   static uint64_t DEFAULT_STRIPE_SIZE = 1024ULL * 1024 * 1024 * 911; // 911G
-  CacheDisk disk; // Only need one because it's just checked for failure.
+  CacheDisk disk;                                                    // Only 
need one because it's just checked for failure.
   CacheHostRecord hr1, hr2;
-  Vol* sample;
+  Vol *sample;
   static int const sample_idx = 16;
   Vol vols[MAX_VOLS];
-  Vol* vol_ptrs[MAX_VOLS]; // array of pointers.
+  Vol *vol_ptrs[MAX_VOLS]; // array of pointers.
   char buff[2048];
 
   // Only run at the highest levels.
@@ -443,12 +422,11 @@ 
REGRESSION_TEST(cache_disk_replacement_stability)(RegressionTest *t, int level,
 
   disk.num_errors = 0;
 
-  for ( int i = 0 ; i < MAX_VOLS ; ++i ) {
+  for (int i = 0; i < MAX_VOLS; ++i) {
     vol_ptrs[i] = vols + i;
     vols[i].disk = &disk;
     vols[i].len = DEFAULT_STRIPE_SIZE;
-    snprintf(buff, sizeof(buff), "/dev/sd%c %" PRIu64 ":%" PRIu64,
-             'a' + i, DEFAULT_SKIP, vols[i].len);
+    snprintf(buff, sizeof(buff), "/dev/sd%c %" PRIu64 ":%" PRIu64, 'a' + i, 
DEFAULT_SKIP, vols[i].len);
     MD5Context().hash_immediate(vols[i].hash_id, buff, strlen(buff));
   }
 
@@ -462,18 +440,19 @@ 
REGRESSION_TEST(cache_disk_replacement_stability)(RegressionTest *t, int level,
   hr2.num_vols = MAX_VOLS;
 
   sample = vols + sample_idx;
-  sample->len = 1024ULL * 1024 * 1024 * (1024+128); // 1.1 TB
-  snprintf(buff, sizeof(buff), "/dev/sd%c %" PRIu64 ":%" PRIu64,
-           'a' + sample_idx, DEFAULT_SKIP, sample->len);
+  sample->len = 1024ULL * 1024 * 1024 * (1024 + 128); // 1.1 TB
+  snprintf(buff, sizeof(buff), "/dev/sd%c %" PRIu64 ":%" PRIu64, 'a' + 
sample_idx, DEFAULT_SKIP, sample->len);
   MD5Context().hash_immediate(sample->hash_id, buff, strlen(buff));
   build_vol_hash_table(&hr2);
 
   // See what the difference is
   int to = 0, from = 0;
   int then = 0, now = 0;
-  for ( int i = 0 ; i < VOL_HASH_TABLE_SIZE ; ++i ) {
-    if (hr1.vol_hash_table[i] == sample_idx) ++then;
-    if (hr2.vol_hash_table[i] == sample_idx) ++now;
+  for (int i = 0; i < VOL_HASH_TABLE_SIZE; ++i) {
+    if (hr1.vol_hash_table[i] == sample_idx)
+      ++then;
+    if (hr2.vol_hash_table[i] == sample_idx)
+      ++now;
     if (hr1.vol_hash_table[i] != hr2.vol_hash_table[i]) {
       if (hr1.vol_hash_table[i] == sample_idx)
         ++from;
@@ -482,9 +461,8 @@ 
REGRESSION_TEST(cache_disk_replacement_stability)(RegressionTest *t, int level,
     }
   }
   rprintf(t, "Cache stability difference - "
-          "delta = %d of %d : %d to, %d from, originally %d slots, now %d 
slots (net gain = %d/%d)\n"
-          , to+from, VOL_HASH_TABLE_SIZE, to, from, then, now, now-then, 
to-from
-    );
+             "delta = %d of %d : %d to, %d from, originally %d slots, now %d 
slots (net gain = %d/%d)\n",
+          to + from, VOL_HASH_TABLE_SIZE, to, from, then, now, now - then, to 
- from);
   *pstatus = REGRESSION_TEST_PASSED;
 
   hr1.vols = 0;
@@ -496,8 +474,8 @@ test_RamCache(RegressionTest *t, RamCache *cache)
 {
   bool pass = true;
   CacheKey key;
-  Vol *vol = theCache->key_to_vol(&key, "example.com", 
sizeof("example.com")-1);
-  vector< Ptr<IOBufferData> > data;
+  Vol *vol = theCache->key_to_vol(&key, "example.com", sizeof("example.com") - 
1);
+  vector<Ptr<IOBufferData> > data;
 
   cache->init(1 << 20, vol);
 
@@ -544,8 +522,7 @@ REGRESSION_TEST(ram_cache)(RegressionTest *t, int /* level 
ATS_UNUSED */, int *p
     *pstatus = REGRESSION_TEST_FAILED;
     return;
   }
-  if (!test_RamCache(t, new_RamCacheLRU()) ||
-      !test_RamCache(t, new_RamCacheCLFUS()))
+  if (!test_RamCache(t, new_RamCacheLRU()) || !test_RamCache(t, 
new_RamCacheCLFUS()))
     *pstatus = REGRESSION_TEST_FAILED;
   else
     *pstatus = REGRESSION_TEST_PASSED;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/CacheVol.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheVol.cc b/iocore/cache/CacheVol.cc
index 9428774..47f5775 100644
--- a/iocore/cache/CacheVol.cc
+++ b/iocore/cache/CacheVol.cc
@@ -22,14 +22,13 @@
  */
 
 
-
 #include "P_Cache.h"
 
-#define SCAN_BUF_SIZE      RECOVERY_SIZE
+#define SCAN_BUF_SIZE RECOVERY_SIZE
 #define SCAN_WRITER_LOCK_MAX_RETRY 5
 
 Action *
-Cache::scan(Continuation * cont, char *hostname, int host_len, int 
KB_per_second)
+Cache::scan(Continuation *cont, char *hostname, int host_len, int 
KB_per_second)
 {
   Debug("cache_scan_truss", "inside scan");
   if (!CacheProcessor::IsCacheReady(CACHE_FRAG_TYPE_HTTP)) {
@@ -93,20 +92,22 @@ Ldone:
  * d - Vol
  * vol_map - precalculated map
  * offset - offset to start looking at (and data at this location has not been 
read yet). */
-static off_t next_in_map(Vol *d, char *vol_map, off_t offset)
+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 new_off = (offset - start_offset);
   off_t vol_len = vol_relative_length(d, start_offset);
 
-  while (new_off < vol_len && !vol_map[new_off / SCAN_BUF_SIZE]) new_off += 
SCAN_BUF_SIZE;
-  if (new_off >= vol_len) return vol_len + start_offset;
+  while (new_off < vol_len && !vol_map[new_off / SCAN_BUF_SIZE])
+    new_off += SCAN_BUF_SIZE;
+  if (new_off >= vol_len)
+    return vol_len + start_offset;
   return new_off + start_offset;
 }
 
 // Function in CacheDir.cc that we need for make_vol_map().
-int
-dir_bucket_loop_fix(Dir *start_dir, int s, Vol *d);
+int dir_bucket_loop_fix(Dir *start_dir, int s, Vol *d);
 
 // TODO: If we used a bit vector, we could make a smaller map structure.
 // TODO: If we saved a high water mark we could have a smaller buf, and avoid 
searching it
@@ -114,7 +115,8 @@ dir_bucket_loop_fix(Dir *start_dir, int s, Vol *d);
 /* Make map of what blocks in partition are used.
  *
  * d - Vol to make a map of. */
-static char *make_vol_map(Vol *d)
+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);
@@ -135,8 +137,9 @@ static char *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;
-            if (offset <= vol_len) vol_map[offset / SCAN_BUF_SIZE] = 1;
+          off_t offset = vol_offset(d, e) - start_offset;
+          if (offset <= vol_len)
+            vol_map[offset / SCAN_BUF_SIZE] = 1;
         }
         e = next_dir(e, seg);
         if (!e)
@@ -174,7 +177,7 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* 
e ATS_UNUSED */)
     return EVENT_CONT;
   }
 
-  if (!fragment) {               // initialize for first read
+  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));
@@ -188,12 +191,12 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
     goto Lread;
   }
 
-  if ((size_t)io.aio_result != (size_t) io.aiocb.aio_nbytes) {
-    result = (void *) -ECACHE_READ_FAIL;
+  if ((size_t)io.aio_result != (size_t)io.aiocb.aio_nbytes) {
+    result = (void *)-ECACHE_READ_FAIL;
     goto Ldone;
   }
 
-  doc = (Doc *) (buf->data() + offset);
+  doc = (Doc *)(buf->data() + offset);
   // If there is data in the buffer before the start that is from a partial 
object read previously
   // Fix things as if we read it this time.
   if (scan_fix_buffer_offset) {
@@ -203,9 +206,9 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* 
e ATS_UNUSED */)
     io.aiocb.aio_buf = (char *)io.aiocb.aio_buf - scan_fix_buffer_offset;
     scan_fix_buffer_offset = 0;
   }
-  while ((off_t)((char *) doc - buf->data()) + next_object_len < 
(off_t)io.aiocb.aio_nbytes) {
+  while ((off_t)((char *)doc - buf->data()) + next_object_len < 
(off_t)io.aiocb.aio_nbytes) {
     might_need_overlap_read = false;
-    doc = (Doc *) ((char *) doc + next_object_len);
+    doc = (Doc *)((char *)doc + next_object_len);
     next_object_len = vol->round_to_approx_size(doc->len);
 #ifdef HTTP_CACHE
     int i;
@@ -225,11 +228,11 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
       if (!dir_probe(&doc->first_key, vol, &dir, &last_collision))
         goto Lskip;
       if (!dir_agg_valid(vol, &dir) || !dir_head(&dir) ||
-          (vol_offset(vol, &dir) != io.aiocb.aio_offset + ((char *) doc - 
buf->data())))
+          (vol_offset(vol, &dir) != io.aiocb.aio_offset + ((char *)doc - 
buf->data())))
         continue;
       break;
     }
-    if (doc->data() - buf->data() > (int) io.aiocb.aio_nbytes) {
+    if (doc->data() - buf->data() > (int)io.aiocb.aio_nbytes) {
       might_need_overlap_read = true;
       goto Lskip;
     }
@@ -301,10 +304,10 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
         ink_assert(hostinfo_copied);
         SET_HANDLER(&CacheVC::scanRemoveDone);
         // force remove even if there is a writer
-        cacheProcessor.remove(this, &doc->first_key, true, 
CACHE_FRAG_TYPE_HTTP, true, false, (char *) hname, hlen);
+        cacheProcessor.remove(this, &doc->first_key, true, 
CACHE_FRAG_TYPE_HTTP, true, false, (char *)hname, hlen);
         return EVENT_CONT;
       } else {
-        offset = (char *) doc - buf->data();
+        offset = (char *)doc - buf->data();
         write_len = 0;
         frag_type = CACHE_FRAG_TYPE_HTTP;
         f.use_first_key = 1;
@@ -318,16 +321,16 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
       }
     }
     continue;
-  Lskip:;
+  Lskip:
+    ;
 #endif
   }
 #ifdef HTTP_CACHE
   vector.clear();
 #endif
-    // If we had an object that went past the end of the buffer, and it is 
small enough to fix,
-    // fix it.
-  if (might_need_overlap_read &&
-      ((off_t)((char *) doc - buf->data()) + next_object_len > 
(off_t)io.aiocb.aio_nbytes) &&
+  // If we had an object that went past the end of the buffer, and it is small 
enough to fix,
+  // fix it.
+  if (might_need_overlap_read && ((off_t)((char *)doc - buf->data()) + 
next_object_len > (off_t)io.aiocb.aio_nbytes) &&
       next_object_len > 0) {
     off_t partial_object_len = io.aiocb.aio_nbytes - ((char *)doc - 
buf->data());
     // Copy partial object to beginning of the buffer.
@@ -347,7 +350,7 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* 
e ATS_UNUSED */)
   }
 
   if (io.aiocb.aio_offset >= vol->skip + vol->len) {
-Lnext_vol:
+  Lnext_vol:
     SET_HANDLER(&CacheVC::scanVol);
     eventProcessor.schedule_in(this, HRTIME_MSECONDS(scan_msec_delay));
     return EVENT_CONT;
@@ -359,12 +362,11 @@ Lread:
     io.aiocb.aio_nbytes = vol->skip + vol->len - io.aiocb.aio_offset;
   offset = 0;
   ink_assert(ink_aio_read(&io) >= 0);
-  Debug("cache_scan_truss", "read %p:scanObject %" PRId64 " %zu", this,
-        (int64_t)io.aiocb.aio_offset, (size_t)io.aiocb.aio_nbytes);
+  Debug("cache_scan_truss", "read %p:scanObject %" PRId64 " %zu", this, 
(int64_t)io.aiocb.aio_offset, (size_t)io.aiocb.aio_nbytes);
   return EVENT_CONT;
 
 Ldone:
-   Debug("cache_scan_truss", "done %p:scanObject", this);
+  Debug("cache_scan_truss", "done %p:scanObject", this);
   _action.continuation->handleEvent(CACHE_EVENT_SCAN_DONE, result);
 #ifdef HTTP_CACHE
 Lcancel:
@@ -431,8 +433,8 @@ CacheVC::scanOpenWrite(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
     Debug("cache_scan", "got writer lock");
     Dir *l = NULL;
     Dir d;
-    Doc *doc = (Doc *) (buf->data() + offset);
-    offset = (char *) doc - buf->data() + vol->round_to_approx_size(doc->len);
+    Doc *doc = (Doc *)(buf->data() + offset);
+    offset = (char *)doc - buf->data() + vol->round_to_approx_size(doc->len);
     // if the doc contains some data, then we need to create
     // a new directory entry for this fragment. Remember the
     // offset and the key in earliest_key
@@ -494,4 +496,3 @@ CacheVC::scanUpdateDone(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
     return EVENT_CONT;
   }
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/CacheWrite.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index 3861776..4e6319e 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -24,10 +24,10 @@
 
 #include "P_Cache.h"
 
-#define IS_POWER_2(_x) (!((_x)&((_x)-1)))
-#define UINT_WRAP_LTE(_x, _y) (((_y)-(_x)) < INT_MAX) // exploit overflow
-#define UINT_WRAP_GTE(_x, _y) (((_x)-(_y)) < INT_MAX) // exploit overflow
-#define UINT_WRAP_LT(_x, _y) (((_x)-(_y)) >= INT_MAX) // exploit overflow
+#define IS_POWER_2(_x) (!((_x) & ((_x)-1)))
+#define UINT_WRAP_LTE(_x, _y) (((_y) - (_x)) < INT_MAX) // exploit overflow
+#define UINT_WRAP_GTE(_x, _y) (((_x) - (_y)) < INT_MAX) // exploit overflow
+#define UINT_WRAP_LT(_x, _y) (((_x) - (_y)) >= INT_MAX) // exploit overflow
 
 // Given a key, finds the index of the alternate which matches
 // used to get the alternate which is actually present in the document
@@ -56,7 +56,7 @@ get_alternate_index(CacheHTTPInfoVector *cache_vector, 
CacheKey key)
 // of writing the vector even if the http state machine aborts.  This
 // makes it easier to handle situations where writers abort.
 int
-CacheVC::updateVector(int /* event ATS_UNUSED */, Event */* e ATS_UNUSED */)
+CacheVC::updateVector(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
 {
   cancel_trigger();
   if (od->reading_vec || od->writing_vec)
@@ -71,7 +71,8 @@ CacheVC::updateVector(int /* event ATS_UNUSED */, Event */* e 
ATS_UNUSED */)
     if (f.update) {
       // all Update cases. Need to get the alternate index.
       alternate_index = get_alternate_index(write_vector, update_key);
-      Debug("cache_update", "updating alternate index %d frags %d", 
alternate_index, alternate_index >=0 ? 
write_vector->get(alternate_index)->get_frag_offset_count() : -1);
+      Debug("cache_update", "updating alternate index %d frags %d", 
alternate_index,
+            alternate_index >= 0 ? 
write_vector->get(alternate_index)->get_frag_offset_count() : -1);
       // if its an alternate delete
       if (!vec) {
         ink_assert(!total_len);
@@ -107,7 +108,7 @@ CacheVC::updateVector(int /* event ATS_UNUSED */, Event */* 
e ATS_UNUSED */)
     }
 
     if (od->move_resident_alt && first_buf._ptr() && 
!od->has_multiple_writers()) {
-      Doc *doc = (Doc *) first_buf->data();
+      Doc *doc = (Doc *)first_buf->data();
       int small_doc = (int64_t)doc->data_len() < 
(int64_t)cache_config_alt_rewrite_max_size;
       int have_res_alt = doc->key == od->single_doc_key;
       // if the new alternate is not written with the vector
@@ -125,8 +126,8 @@ CacheVC::updateVector(int /* event ATS_UNUSED */, Event */* 
e ATS_UNUSED */)
         od->move_resident_alt = 0;
         f.rewrite_resident_alt = 1;
         write_len = doc->data_len();
-        Debug("cache_update_alt",
-              "rewriting resident alt size: %d key: %X, first_key: %X", 
write_len, doc->key.slice32(0), first_key.slice32(0));
+        Debug("cache_update_alt", "rewriting resident alt size: %d key: %X, 
first_key: %X", write_len, doc->key.slice32(0),
+              first_key.slice32(0));
       }
     }
     header_len = write_vector->marshal_length();
@@ -176,7 +177,7 @@ CacheVC::updateVector(int /* event ATS_UNUSED */, Event */* 
e ATS_UNUSED */)
    */
 
 int
-CacheVC::handleWrite(int event, Event */* e ATS_UNUSED */)
+CacheVC::handleWrite(int event, Event * /* e ATS_UNUSED */)
 {
   // plain write case
   ink_assert(!trigger);
@@ -186,16 +187,13 @@ CacheVC::handleWrite(int event, Event */* e ATS_UNUSED */)
   POP_HANDLER;
   agg_len = vol->round_to_approx_size(write_len + header_len + frag_len + 
sizeofDoc);
   vol->agg_todo_size += agg_len;
-  bool agg_error =
-    (agg_len > AGG_SIZE || header_len + sizeofDoc > MAX_FRAG_SIZE ||
-     (!f.readers && (vol->agg_todo_size > cache_config_agg_write_backlog + 
AGG_SIZE) && write_len));
+  bool agg_error = (agg_len > AGG_SIZE || header_len + sizeofDoc > 
MAX_FRAG_SIZE ||
+                    (!f.readers && (vol->agg_todo_size > 
cache_config_agg_write_backlog + AGG_SIZE) && write_len));
 #ifdef CACHE_AGG_FAIL_RATE
-  agg_error = agg_error || ((uint32_t) 
mutex->thread_holding->generator.random() <
-                            (uint32_t) (UINT_MAX * CACHE_AGG_FAIL_RATE));
+  agg_error = agg_error || 
((uint32_t)mutex->thread_holding->generator.random() < (uint32_t)(UINT_MAX * 
CACHE_AGG_FAIL_RATE));
 #endif
-  bool max_doc_error = (cache_config_max_doc_size &&
-                        (cache_config_max_doc_size < vio.ndone ||
-                         (vio.nbytes != INT64_MAX && 
(cache_config_max_doc_size < vio.nbytes))));
+  bool max_doc_error = (cache_config_max_doc_size && 
(cache_config_max_doc_size < vio.ndone ||
+                                                      (vio.nbytes != INT64_MAX 
&& (cache_config_max_doc_size < vio.nbytes))));
 
   if (agg_error || max_doc_error) {
     CACHE_INCREMENT_DYN_STAT(cache_write_backlog_failure_stat);
@@ -255,14 +253,14 @@ Vol::force_evacuate_head(Dir *evac_dir, int pinned)
   if (!b) {
     b = new_EvacuationBlock(mutex->thread_holding);
     b->dir = *evac_dir;
-    DDebug("cache_evac", "force: %d, %d", (int) dir_offset(evac_dir), (int) 
dir_phase(evac_dir));
+    DDebug("cache_evac", "force: %d, %d", (int)dir_offset(evac_dir), 
(int)dir_phase(evac_dir));
     evacuate[dir_evac_bucket(evac_dir)].push(b);
   }
   b->f.pinned = pinned;
   b->f.evacuate_head = 1;
-  b->evac_frags.key = zero_key;  // ensure that the block gets
+  b->evac_frags.key = zero_key; // ensure that the block gets
   // evacuated no matter what
-  b->readers = 0;             // ensure that the block does not disappear
+  b->readers = 0; // ensure that the block does not disappear
   return b;
 }
 
@@ -286,7 +284,7 @@ Vol::scan_for_pinned_documents()
           if (before_end_of_vol || o >= (pe - vol_end_offset))
             continue;
         } else {
-          if (o<ps || o>= pe)
+          if (o < ps || o >= pe)
             continue;
         }
         force_evacuate_head(&dir[i], 1);
@@ -318,8 +316,8 @@ Vol::aggWriteDone(int event, Event *e)
     header->last_write_pos = header->write_pos;
     header->write_pos += io.aiocb.aio_nbytes;
     ink_assert(header->write_pos >= start);
-    DDebug("cache_agg", "Dir %s, Write: %" PRIu64 ", last Write: %" PRIu64 
"\n",
-          hash_text.get(), header->write_pos, header->last_write_pos);
+    DDebug("cache_agg", "Dir %s, Write: %" PRIu64 ", last Write: %" PRIu64 
"\n", hash_text.get(), header->write_pos,
+           header->last_write_pos);
     ink_assert(header->write_pos == header->agg_pos);
     if (header->write_pos + EVACUATION_SIZE > scan_pos)
       periodic_scan();
@@ -330,14 +328,13 @@ Vol::aggWriteDone(int event, Event *e)
     // for fragments is this aggregation buffer
     Debug("cache_disk_error", "Write error on disk %s\n \
               write range : [%" PRIu64 " - %" PRIu64 " bytes]  [%" PRIu64 " - 
%" PRIu64 " blocks] \n",
-          hash_text.get(), (uint64_t)io.aiocb.aio_offset,
-          (uint64_t)io.aiocb.aio_offset + io.aiocb.aio_nbytes,
+          hash_text.get(), (uint64_t)io.aiocb.aio_offset, 
(uint64_t)io.aiocb.aio_offset + io.aiocb.aio_nbytes,
           (uint64_t)io.aiocb.aio_offset / CACHE_BLOCK_SIZE,
           (uint64_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes) / 
CACHE_BLOCK_SIZE);
     Dir del_dir;
     dir_clear(&del_dir);
     for (int done = 0; done < agg_buf_pos;) {
-      Doc *doc = (Doc *) (agg_buffer + done);
+      Doc *doc = (Doc *)(agg_buffer + done);
       dir_set_offset(&del_dir, header->write_pos + done);
       dir_delete(&doc->key, this, &del_dir);
       done += round_to_approx_size(doc->len);
@@ -385,7 +382,7 @@ CacheVC::evacuateReadHead(int /* event ATS_UNUSED */, Event 
* /* e ATS_UNUSED */
   // The evacuator vc shares the lock with the volition mutex
   ink_assert(vol->mutex->thread_holding == this_ethread());
   cancel_trigger();
-  Doc *doc = (Doc *) buf->data();
+  Doc *doc = (Doc *)buf->data();
 #ifdef HTTP_CACHE
   CacheHTTPInfo *alternate_tmp = 0;
 #endif
@@ -411,8 +408,8 @@ CacheVC::evacuateReadHead(int /* event ATS_UNUSED */, Event 
* /* e ATS_UNUSED */
       goto Ldone;
     alternate_tmp = vector.get(alternate_index);
     doc_len = alternate_tmp->object_size_get();
-    Debug("cache_evac", "evacuateReadHead http earliest %X first: %X len: %" 
PRId64,
-          first_key.slice32(0), earliest_key.slice32(0), doc_len);
+    Debug("cache_evac", "evacuateReadHead http earliest %X first: %X len: %" 
PRId64, first_key.slice32(0), earliest_key.slice32(0),
+          doc_len);
   } else
 #endif
   {
@@ -422,8 +419,8 @@ CacheVC::evacuateReadHead(int /* event ATS_UNUSED */, Event 
* /* e ATS_UNUSED */
     if (!(next_key == earliest_key))
       goto Ldone;
     doc_len = doc->total_len;
-    DDebug("cache_evac",
-          "evacuateReadHead non-http earliest %X first: %X len: %" PRId64, 
first_key.slice32(0), earliest_key.slice32(0), doc_len);
+    DDebug("cache_evac", "evacuateReadHead non-http earliest %X first: %X len: 
%" PRId64, first_key.slice32(0),
+           earliest_key.slice32(0), doc_len);
   }
   if (doc_len == total_len) {
     // the whole document has been evacuated. Insert the directory
@@ -445,19 +442,17 @@ Ldone:
 }
 
 int
-CacheVC::evacuateDocDone(int /* event ATS_UNUSED */, Event */* e ATS_UNUSED */)
+CacheVC::evacuateDocDone(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED 
*/)
 {
   ink_assert(vol->mutex->thread_holding == this_ethread());
-  Doc *doc = (Doc *) buf->data();
-  DDebug("cache_evac", "evacuateDocDone %X o %d p %d new_o %d new_p %d",
-        (int) key.slice32(0), (int) dir_offset(&overwrite_dir),
-        (int) dir_phase(&overwrite_dir), (int) dir_offset(&dir), (int) 
dir_phase(&dir));
+  Doc *doc = (Doc *)buf->data();
+  DDebug("cache_evac", "evacuateDocDone %X o %d p %d new_o %d new_p %d", 
(int)key.slice32(0), (int)dir_offset(&overwrite_dir),
+         (int)dir_phase(&overwrite_dir), (int)dir_offset(&dir), 
(int)dir_phase(&dir));
   int i = dir_evac_bucket(&overwrite_dir);
   // nasty beeping race condition, need to have the EvacuationBlock here
   EvacuationBlock *b = vol->evacuate[i].head;
   for (; b; b = b->link.next) {
     if (dir_offset(&b->dir) == dir_offset(&overwrite_dir)) {
-
       // If the document is single fragment (although not tied to the vector),
       // then we don't have to put the directory entry in the lookaside
       // buffer. But, we have no way of finding out if the document is
@@ -468,13 +463,13 @@ CacheVC::evacuateDocDone(int /* event ATS_UNUSED */, 
Event */* e ATS_UNUSED */)
       if (!dir_head(&overwrite_dir)) {
         // find the earliest key
         EvacuationKey *evac = &b->evac_frags;
-        for (; evac && !(evac->key == doc->key); evac = evac->link.next);
+        for (; evac && !(evac->key == doc->key); evac = evac->link.next)
+          ;
         ink_assert(evac);
         if (!evac)
           break;
         if (evac->earliest_key.fold()) {
-          DDebug("cache_evac", "evacdocdone: evacuating key %X earliest %X",
-                evac->key.slice32(0), evac->earliest_key.slice32(0));
+          DDebug("cache_evac", "evacdocdone: evacuating key %X earliest %X", 
evac->key.slice32(0), evac->earliest_key.slice32(0));
           EvacuationBlock *eblock = 0;
           Dir dir_tmp;
           dir_lookaside_probe(&evac->earliest_key, vol, &dir_tmp, &eblock);
@@ -495,27 +490,24 @@ CacheVC::evacuateDocDone(int /* event ATS_UNUSED */, 
Event */* e ATS_UNUSED */)
       // Cache::open_write). Once we know its the vector, we can
       // safely overwrite the first_key in the directory.
       if (dir_head(&overwrite_dir) && b->f.evacuate_head) {
-        DDebug("cache_evac",
-              "evacuateDocDone evacuate_head %X %X hlen %d offset %d",
-              (int) key.slice32(0), (int) doc->key.slice32(0), doc->hlen, 
(int) dir_offset(&overwrite_dir));
+        DDebug("cache_evac", "evacuateDocDone evacuate_head %X %X hlen %d 
offset %d", (int)key.slice32(0), (int)doc->key.slice32(0),
+               doc->hlen, (int)dir_offset(&overwrite_dir));
 
         if (dir_compare_tag(&overwrite_dir, &doc->first_key)) {
           OpenDirEntry *cod;
-          DDebug("cache_evac", "evacuating vector: %X %d",
-                (int) doc->first_key.slice32(0), (int) 
dir_offset(&overwrite_dir));
+          DDebug("cache_evac", "evacuating vector: %X %d", 
(int)doc->first_key.slice32(0), (int)dir_offset(&overwrite_dir));
           if ((cod = vol->open_read(&doc->first_key))) {
             // writer  exists
-            DDebug("cache_evac", "overwriting the open directory %X %d %d",
-                  (int) doc->first_key.slice32(0), (int) 
dir_offset(&cod->first_dir), (int) dir_offset(&dir));
+            DDebug("cache_evac", "overwriting the open directory %X %d %d", 
(int)doc->first_key.slice32(0),
+                   (int)dir_offset(&cod->first_dir), (int)dir_offset(&dir));
             cod->first_dir = dir;
-
           }
           if (dir_overwrite(&doc->first_key, vol, &dir, &overwrite_dir)) {
             int64_t o = dir_offset(&overwrite_dir), n = dir_offset(&dir);
             vol->ram_cache->fixup(&doc->first_key, (uint32_t)(o >> 32), 
(uint32_t)o, (uint32_t)(n >> 32), (uint32_t)n);
           }
         } else {
-          DDebug("cache_evac", "evacuating earliest: %X %d", (int) 
doc->key.slice32(0), (int) dir_offset(&overwrite_dir));
+          DDebug("cache_evac", "evacuating earliest: %X %d", 
(int)doc->key.slice32(0), (int)dir_offset(&overwrite_dir));
           ink_assert(dir_compare_tag(&overwrite_dir, &doc->key));
           ink_assert(b->earliest_evacuator == this);
           total_len += doc->data_len();
@@ -550,7 +542,7 @@ evacuate_fragments(CacheKey *key, CacheKey *earliest_key, 
int force, Vol *vol)
 #if TS_USE_INTERIM_CACHE == 1
         || dir_ininterim(&dir)
 #endif
-        )
+          )
       continue;
     EvacuationBlock *b = evacuation_block_exists(&dir, vol);
     if (!b) {
@@ -571,9 +563,8 @@ evacuate_fragments(CacheKey *key, CacheKey *earliest_key, 
int force, Vol *vol)
     }
     if (force)
       b->readers = 0;
-    DDebug("cache_evac",
-          "next fragment %X Earliest: %X offset %d phase %d force %d",
-          (int) key->slice32(0), (int) earliest_key->slice32(0), (int) 
dir_offset(&dir), (int) dir_phase(&dir), force);
+    DDebug("cache_evac", "next fragment %X Earliest: %X offset %d phase %d 
force %d", (int)key->slice32(0),
+           (int)earliest_key->slice32(0), (int)dir_offset(&dir), 
(int)dir_phase(&dir), force);
   }
   return i;
 }
@@ -586,9 +577,9 @@ Vol::evacuateWrite(CacheVC *evacuator, int event, Event *e)
   evacuator->agg_len = round_to_approx_size(((Doc 
*)evacuator->buf->data())->len);
   agg_todo_size += evacuator->agg_len;
   /* insert the evacuator after all the other evacuators */
-  CacheVC *cur = (CacheVC *) agg.head;
+  CacheVC *cur = (CacheVC *)agg.head;
   CacheVC *after = NULL;
-  for (; cur && cur->f.evacuator; cur = (CacheVC *) cur->link.next)
+  for (; cur && cur->f.evacuator; cur = (CacheVC *)cur->link.next)
     after = cur;
   ink_assert(evacuator->agg_len <= AGG_SIZE);
   agg.insert(evacuator, after);
@@ -604,17 +595,17 @@ Vol::evacuateDocReadDone(int event, Event *e)
   ink_assert(is_io_in_progress());
   set_io_not_in_progress();
   ink_assert(mutex->thread_holding == this_ethread());
-  Doc *doc = (Doc *) doc_evacuator->buf->data();
+  Doc *doc = (Doc *)doc_evacuator->buf->data();
   CacheKey next_key;
   EvacuationBlock *b = NULL;
   if (doc->magic != DOC_MAGIC) {
-    Debug("cache_evac", "DOC magic: %X %d",
-          (int) dir_tag(&doc_evacuator->overwrite_dir), (int) 
dir_offset(&doc_evacuator->overwrite_dir));
+    Debug("cache_evac", "DOC magic: %X %d", 
(int)dir_tag(&doc_evacuator->overwrite_dir),
+          (int)dir_offset(&doc_evacuator->overwrite_dir));
     ink_assert(doc->magic == DOC_MAGIC);
     goto Ldone;
   }
-  DDebug("cache_evac", "evacuateDocReadDone %X offset %d",
-        (int) doc->key.slice32(0), (int) 
dir_offset(&doc_evacuator->overwrite_dir));
+  DDebug("cache_evac", "evacuateDocReadDone %X offset %d", 
(int)doc->key.slice32(0),
+         (int)dir_offset(&doc_evacuator->overwrite_dir));
 
   b = evacuate[dir_evac_bucket(&doc_evacuator->overwrite_dir)].head;
   while (b) {
@@ -624,7 +615,7 @@ Vol::evacuateDocReadDone(int event, Event *e)
   }
   if (!b)
     goto Ldone;
-  if ((b->f.pinned && !b->readers) && doc->pinned < (uint32_t) 
(ink_get_based_hrtime() / HRTIME_SECOND))
+  if ((b->f.pinned && !b->readers) && doc->pinned < 
(uint32_t)(ink_get_based_hrtime() / HRTIME_SECOND))
     goto Ldone;
 
   if (dir_head(&b->dir) && b->f.evacuate_head) {
@@ -634,8 +625,8 @@ Vol::evacuateDocReadDone(int event, Event *e)
     if (dir_compare_tag(&b->dir, &doc->first_key)) {
       doc_evacuator->key = doc->first_key;
       b->evac_frags.key = doc->first_key;
-      DDebug("cache_evac", "evacuating vector %X offset %d",
-            (int) doc->first_key.slice32(0), (int) 
dir_offset(&doc_evacuator->overwrite_dir));
+      DDebug("cache_evac", "evacuating vector %X offset %d", 
(int)doc->first_key.slice32(0),
+             (int)dir_offset(&doc_evacuator->overwrite_dir));
       b->f.unused = 57;
     } else {
       // if its an earliest fragment (alternate) evacuation, things get
@@ -647,23 +638,22 @@ Vol::evacuateDocReadDone(int event, Event *e)
       b->evac_frags.key = doc->key;
       b->evac_frags.earliest_key = doc->key;
       b->earliest_evacuator = doc_evacuator;
-      DDebug("cache_evac", "evacuating earliest %X %X evac: %p offset: %d",
-            (int) b->evac_frags.key.slice32(0), (int) doc->key.slice32(0),
-            doc_evacuator, (int) dir_offset(&doc_evacuator->overwrite_dir));
+      DDebug("cache_evac", "evacuating earliest %X %X evac: %p offset: %d", 
(int)b->evac_frags.key.slice32(0),
+             (int)doc->key.slice32(0), doc_evacuator, 
(int)dir_offset(&doc_evacuator->overwrite_dir));
       b->f.unused = 67;
     }
   } else {
     // find which key matches the document
     EvacuationKey *ek = &b->evac_frags;
-    for (; ek && !(ek->key == doc->key); ek = ek->link.next);
+    for (; ek && !(ek->key == doc->key); ek = ek->link.next)
+      ;
     if (!ek) {
       b->f.unused = 77;
       goto Ldone;
     }
     doc_evacuator->key = ek->key;
     doc_evacuator->earliest_key = ek->earliest_key;
-    DDebug("cache_evac", "evacuateDocReadDone key: %X earliest: %X",
-          (int) ek->key.slice32(0), (int) ek->earliest_key.slice32(0));
+    DDebug("cache_evac", "evacuateDocReadDone key: %X earliest: %X", 
(int)ek->key.slice32(0), (int)ek->earliest_key.slice32(0));
     b->f.unused = 87;
   }
   // if the tag in the c->dir does match the first_key in the
@@ -732,7 +722,7 @@ agg_copy(char *p, CacheVC *vc)
   off_t o = vol->header->write_pos + vol->agg_buf_pos;
 
   if (!vc->f.evacuator) {
-    Doc *doc = (Doc *) p;
+    Doc *doc = (Doc *)p;
     IOBufferBlock *res_alt_blk = 0;
 
     uint32_t len = vc->write_len + vc->header_len + vc->frag_len + sizeofDoc;
@@ -762,7 +752,7 @@ agg_copy(char *p, CacheVC *vc)
     doc->checksum = DOC_NO_CHECKSUM;
     if (vc->pin_in_cache) {
       dir_set_pinned(&vc->dir, 1);
-      doc->pinned = (uint32_t) (ink_get_based_hrtime() / HRTIME_SECOND) + 
vc->pin_in_cache;
+      doc->pinned = (uint32_t)(ink_get_based_hrtime() / HRTIME_SECOND) + 
vc->pin_in_cache;
     } else {
       dir_set_pinned(&vc->dir, 0);
       doc->pinned = 0;
@@ -771,9 +761,9 @@ agg_copy(char *p, CacheVC *vc)
     if (vc->f.use_first_key) {
       if (doc->data_len()
 #ifdef HTTP_CACHE
-                  || vc->f.allow_empty_doc
+          || vc->f.allow_empty_doc
 #endif
-                  )
+          )
         doc->key = vc->earliest_key;
       else // the vector is being written by itself
         prev_CacheKey(&doc->key, &vc->earliest_key);
@@ -786,7 +776,7 @@ agg_copy(char *p, CacheVC *vc)
 #ifdef HTTP_CACHE
     if (vc->f.rewrite_resident_alt) {
       ink_assert(vc->f.use_first_key);
-      Doc *res_doc = (Doc *) vc->first_buf->data();
+      Doc *res_doc = (Doc *)vc->first_buf->data();
       res_alt_blk = new_IOBufferBlock(vc->first_buf, res_doc->data_len(), 
sizeofDoc + res_doc->hlen);
       doc->key = res_doc->key;
       doc->total_len = res_doc->data_len();
@@ -809,7 +799,7 @@ agg_copy(char *p, CacheVC *vc)
           CacheHTTPInfo *http_info = 
vc->write_vector->get(vc->alternate_index);
           http_info->object_size_set(vc->total_len);
         }
-        ink_assert(!(((uintptr_t) &doc->hdr()[0]) & HDR_PTR_ALIGNMENT_MASK));
+        ink_assert(!(((uintptr_t)&doc->hdr()[0]) & HDR_PTR_ALIGNMENT_MASK));
         ink_assert(vc->header_len == vc->write_vector->marshal(doc->hdr(), 
vc->header_len));
       } else
 #endif
@@ -842,11 +832,10 @@ agg_copy(char *p, CacheVC *vc)
         ink_assert(!memcmp(doc->hdr(), x, ib - (x - xx)));
       }
 #endif
-
     }
     if (cache_config_enable_checksum) {
       doc->checksum = 0;
-      for (char *b = doc->hdr(); b < (char *) doc + doc->len; b++)
+      for (char *b = doc->hdr(); b < (char *)doc + doc->len; b++)
         doc->checksum += *b;
     }
     if (vc->frag_type == CACHE_FRAG_TYPE_HTTP && vc->f.single_fragment)
@@ -858,7 +847,7 @@ agg_copy(char *p, CacheVC *vc)
     return vc->agg_len;
   } else {
     // for evacuated documents, copy the data, and update directory
-    Doc *doc = (Doc *) vc->buf->data();
+    Doc *doc = (Doc *)vc->buf->data();
     int l = vc->vol->round_to_approx_size(doc->len);
     {
       ProxyMutex *mutex ATS_UNUSED = vc->vol->mutex;
@@ -887,13 +876,10 @@ 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 > vol_offset(this, &b->dir)) ||
+                      (header->phase == dir_phase(&b->dir) && 
header->write_pos <= vol_offset(this, &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));
+      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;
       evacuate[i].remove(x);
       free_EvacuationBlock(x, mutex->thread_holding);
@@ -950,7 +936,7 @@ Vol::agg_wrap()
   dir_lookaside_cleanup(this);
   dir_clean_vol(this);
   {
-    Vol* vol = this;
+    Vol *vol = this;
     CACHE_INCREMENT_DYN_STAT(cache_directory_wrap_stat);
   }
   periodic_scan();
@@ -964,7 +950,7 @@ Vol::agg_wrap()
    the eventProcessor to schedule events
 */
 int
-Vol::aggWrite(int event, void */* e ATS_UNUSED */)
+Vol::aggWrite(int event, void * /* e ATS_UNUSED */)
 {
   ink_assert(!is_io_in_progress());
 
@@ -975,15 +961,13 @@ Vol::aggWrite(int event, void */* e ATS_UNUSED */)
 
 Lagain:
   // calculate length of aggregated write
-  for (c = (CacheVC *) agg.head; c;) {
+  for (c = (CacheVC *)agg.head; c;) {
     int writelen = c->agg_len;
     // [amc] this is checked multiple places, on here was it strictly less.
     ink_assert(writelen <= AGG_SIZE);
-    if (agg_buf_pos + writelen > AGG_SIZE ||
-        header->write_pos + agg_buf_pos + writelen > (skip + len))
+    if (agg_buf_pos + writelen > AGG_SIZE || header->write_pos + agg_buf_pos + 
writelen > (skip + len))
       break;
-    DDebug("agg_read", "copying: %d, %" PRIu64 ", key: %d",
-          agg_buf_pos, header->write_pos + agg_buf_pos, 
c->first_key.slice32(0));
+    DDebug("agg_read", "copying: %d, %" PRIu64 ", key: %d", agg_buf_pos, 
header->write_pos + agg_buf_pos, c->first_key.slice32(0));
     int wrotelen = agg_copy(agg_buffer + agg_buf_pos, c);
     ink_assert(writelen == wrotelen);
     agg_todo_size -= writelen;
@@ -993,7 +977,7 @@ Lagain:
     if (c->f.sync && c->f.use_first_key) {
       CacheVC *last = sync.tail;
       while (last && UINT_WRAP_LT(c->write_serial, last->write_serial))
-        last = (CacheVC*)last->link.prev;
+        last = (CacheVC *)last->link.prev;
       sync.insert(c, last);
     } else if (c->f.evacuator)
       c->handleEvent(AIO_EVENT_DONE, 0);
@@ -1045,7 +1029,7 @@ Lagain:
     ink_assert(sync.head);
     int l = round_to_approx_size(sizeof(Doc));
     agg_buf_pos = l;
-    Doc *d = (Doc*)agg_buffer;
+    Doc *d = (Doc *)agg_buffer;
     memset(d, 0, sizeof(Doc));
     d->magic = DOC_MAGIC;
     d->len = l;
@@ -1084,7 +1068,7 @@ Lwait:
 }
 
 int
-CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, Event */* e ATS_UNUSED 
*/)
+CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED 
*/)
 {
   cancel_trigger();
   {
@@ -1101,15 +1085,15 @@ CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, 
Event */* e ATS_UNUSED */
   if (is_debug_tag_set("cache_update")) {
     if (f.update && closed > 0) {
       if (!total_len && alternate_index != CACHE_ALT_REMOVED) {
-        Debug("cache_update", "header only %d (%" PRIu64 ", %" PRIu64 ")\n",
-              DIR_MASK_TAG(first_key.slice32(2)), update_key.b[0], 
update_key.b[1]);
+        Debug("cache_update", "header only %d (%" PRIu64 ", %" PRIu64 ")\n", 
DIR_MASK_TAG(first_key.slice32(2)), update_key.b[0],
+              update_key.b[1]);
 
       } else if (total_len && alternate_index != CACHE_ALT_REMOVED) {
         Debug("cache_update", "header body, %d, (%" PRIu64 ", %" PRIu64 "), 
(%" PRIu64 ", %" PRIu64 ")\n",
               DIR_MASK_TAG(first_key.slice32(2)), update_key.b[0], 
update_key.b[1], earliest_key.b[0], earliest_key.b[1]);
       } else if (!total_len && alternate_index == CACHE_ALT_REMOVED) {
-        Debug("cache_update", "alt delete, %d, (%" PRIu64 ", %" PRIu64 ")\n",
-              DIR_MASK_TAG(first_key.slice32(2)), update_key.b[0], 
update_key.b[1]);
+        Debug("cache_update", "alt delete, %d, (%" PRIu64 ", %" PRIu64 ")\n", 
DIR_MASK_TAG(first_key.slice32(2)), update_key.b[0],
+              update_key.b[1]);
       }
     }
   }
@@ -1120,20 +1104,26 @@ CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, 
Event */* e ATS_UNUSED */
   // size of the document
   if ((closed == 1) && (total_len > 0
 #ifdef HTTP_CACHE
-                  || f.allow_empty_doc
+                        || f.allow_empty_doc
 #endif
-                  )) {
+                        )) {
     DDebug("cache_stats", "Fragment = %d", fragment);
     switch (fragment) {
-      case 0: 
CACHE_INCREMENT_DYN_STAT(cache_single_fragment_document_count_stat); break;
-      case 1: 
CACHE_INCREMENT_DYN_STAT(cache_two_fragment_document_count_stat); break;
-      default: 
CACHE_INCREMENT_DYN_STAT(cache_three_plus_plus_fragment_document_count_stat); 
break;
+    case 0:
+      CACHE_INCREMENT_DYN_STAT(cache_single_fragment_document_count_stat);
+      break;
+    case 1:
+      CACHE_INCREMENT_DYN_STAT(cache_two_fragment_document_count_stat);
+      break;
+    default:
+      
CACHE_INCREMENT_DYN_STAT(cache_three_plus_plus_fragment_document_count_stat);
+      break;
     }
   }
   if (f.close_complete) {
     recursive++;
     ink_assert(!vol || this_ethread() != vol->mutex->thread_holding);
-    vio._cont->handleEvent(VC_EVENT_WRITE_COMPLETE, (void *) &vio);
+    vio._cont->handleEvent(VC_EVENT_WRITE_COMPLETE, (void *)&vio);
     recursive--;
   }
   return free_CacheVC(this);
@@ -1270,9 +1260,9 @@ CacheVC::openWriteClose(int event, Event *e)
   }
   if (closed > 0
 #ifdef HTTP_CACHE
-                  || f.allow_empty_doc
+      || f.allow_empty_doc
 #endif
-                  ) {
+      ) {
     if (total_len == 0) {
 #ifdef HTTP_CACHE
       if (f.update || f.allow_empty_doc) {
@@ -1305,9 +1295,8 @@ CacheVC::openWriteWriteDone(int event, Event *e)
   cancel_trigger();
   if (event == AIO_EVENT_DONE)
     set_io_not_in_progress();
-  else
-    if (is_io_in_progress())
-      return EVENT_CONT;
+  else if (is_io_in_progress())
+    return EVENT_CONT;
   // In the event of VC_EVENT_ERROR, the cont must do an io_close
   if (!io.ok()) {
     if (closed) {
@@ -1347,12 +1336,14 @@ CacheVC::openWriteWriteDone(int event, Event *e)
   return openWriteMain(event, e);
 }
 
-static inline int target_fragment_size() {
+static inline int
+target_fragment_size()
+{
   return cache_config_target_fragment_size - sizeofDoc;
 }
 
 int
-CacheVC::openWriteMain(int /* event ATS_UNUSED */, Event */* e ATS_UNUSED */)
+CacheVC::openWriteMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
 {
   cancel_trigger();
   int called_user = 0;
@@ -1394,8 +1385,7 @@ Lagain:
     total_len += avail;
   }
   length = (uint64_t)towrite;
-  if (length > target_fragment_size() &&
-      (length < target_fragment_size() + target_fragment_size() / 4))
+  if (length > target_fragment_size() && (length < target_fragment_size() + 
target_fragment_size() / 4))
     write_len = target_fragment_size();
   else
     write_len = length;
@@ -1435,25 +1425,24 @@ CacheVC::openWriteOverwrite(int event, Event *e)
       return openWriteCloseDir(event, e);
     if (!io.ok())
       goto Ldone;
-    doc = (Doc *) buf->data();
+    doc = (Doc *)buf->data();
     if (!(doc->first_key == first_key))
       goto Lcollision;
     od->first_dir = dir;
     first_buf = buf;
     goto Ldone;
   }
-Lcollision:
-  {
-    CACHE_TRY_LOCK(lock, vol->mutex, this_ethread());
-    if (!lock.is_locked())
-      VC_LOCK_RETRY_EVENT();
-    int res = dir_probe(&first_key, vol, &dir, &last_collision);
-    if (res > 0) {
-      if ((res = do_read_call(&first_key)) == EVENT_RETURN)
-        goto Lcallreturn;
-      return res;
-    }
+Lcollision : {
+  CACHE_TRY_LOCK(lock, vol->mutex, this_ethread());
+  if (!lock.is_locked())
+    VC_LOCK_RETRY_EVENT();
+  int res = dir_probe(&first_key, vol, &dir, &last_collision);
+  if (res > 0) {
+    if ((res = do_read_call(&first_key)) == EVENT_RETURN)
+      goto Lcallreturn;
+    return res;
   }
+}
 Ldone:
   SET_HANDLER(&CacheVC::openWriteMain);
   return callcont(CACHE_EVENT_OPEN_WRITE);
@@ -1482,8 +1471,8 @@ CacheVC::openWriteStartDone(int event, Event *e)
     if (_action.cancelled && (!od || !od->has_multiple_writers()))
       goto Lcancel;
 
-    if (event == AIO_EVENT_DONE) {        // vector read done
-      Doc *doc = (Doc *) buf->data();
+    if (event == AIO_EVENT_DONE) { // vector read done
+      Doc *doc = (Doc *)buf->data();
       if (!io.ok()) {
         err = ECACHE_READ_FAIL;
         goto Lfailure;
@@ -1495,8 +1484,7 @@ CacheVC::openWriteStartDone(int event, Event *e)
          to NULL.
        */
       if (!dir_valid(vol, &dir)) {
-        DDebug("cache_write",
-               "OpenReadStartDone: Dir not valid: Write Head: %" PRId64 ", 
Dir: %" PRId64,
+        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));
         last_collision = NULL;
         goto Lcollision;
@@ -1504,8 +1492,7 @@ CacheVC::openWriteStartDone(int event, Event *e)
       if (!(doc->first_key == first_key))
         goto Lcollision;
 
-      if (doc->magic != DOC_MAGIC || !doc->hlen ||
-          this->load_http_info(write_vector, doc, buf) != doc->hlen) {
+      if (doc->magic != DOC_MAGIC || !doc->hlen || 
this->load_http_info(write_vector, doc, buf) != doc->hlen) {
         err = ECACHE_BAD_META_DATA;
 #if TS_USE_INTERIM_CACHE == 1
         if (dir_ininterim(&dir)) {
@@ -1518,7 +1505,7 @@ CacheVC::openWriteStartDone(int event, Event *e)
       }
       ink_assert(write_vector->count() > 0);
 #if TS_USE_INTERIM_CACHE == 1
-Lagain:
+    Lagain:
       if (dir_ininterim(&dir)) {
         dir_delete(&first_key, vol, &dir);
         last_collision = NULL;
@@ -1545,11 +1532,10 @@ Lagain:
       goto Lsuccess;
     }
 
-Lcollision:
-    int if_writers = ((uintptr_t) info == CACHE_ALLOW_MULTIPLE_WRITES);
+  Lcollision:
+    int if_writers = ((uintptr_t)info == CACHE_ALLOW_MULTIPLE_WRITES);
     if (!od) {
-      if ((err = vol->open_write(
-                this, if_writers, cache_config_http_max_alts > 1 ? 
cache_config_http_max_alts : 0)) > 0)
+      if ((err = vol->open_write(this, if_writers, cache_config_http_max_alts 
> 1 ? cache_config_http_max_alts : 0)) > 0)
         goto Lfailure;
       if (od->has_multiple_writers()) {
         MUTEX_RELEASE(lock);
@@ -1579,7 +1565,7 @@ Lsuccess:
 
 Lfailure:
   CACHE_INCREMENT_DYN_STAT(base_stat + CACHE_STAT_FAILURE);
-  _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) 
-err);
+  _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-err);
 Lcancel:
   if (od) {
     od->reading_vec = 0;
@@ -1593,7 +1579,7 @@ Lcallreturn:
 
 // handle lock failures from main Cache::open_write entry points below
 int
-CacheVC::openWriteStartBegin(int /* event ATS_UNUSED */, Event */* e 
ATS_UNUSED */)
+CacheVC::openWriteStartBegin(int /* event ATS_UNUSED */, Event * /* e 
ATS_UNUSED */)
 {
   intptr_t err;
   cancel_trigger();
@@ -1602,7 +1588,7 @@ CacheVC::openWriteStartBegin(int /* event ATS_UNUSED */, 
Event */* e ATS_UNUSED
   if (((err = vol->open_write_lock(this, false, 1)) > 0)) {
     CACHE_INCREMENT_DYN_STAT(base_stat + CACHE_STAT_FAILURE);
     free_CacheVC(this);
-    _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) 
-err);
+    _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-err);
     return EVENT_DONE;
   }
   if (err < 0)
@@ -1619,12 +1605,11 @@ CacheVC::openWriteStartBegin(int /* event ATS_UNUSED 
*/, Event */* e ATS_UNUSED
 
 // main entry point for writing of of non-http documents
 Action *
-Cache::open_write(Continuation *cont, CacheKey *key, CacheFragType frag_type,
-                  int options, time_t apin_in_cache, char *hostname, int 
host_len)
+Cache::open_write(Continuation *cont, CacheKey *key, CacheFragType frag_type, 
int options, time_t apin_in_cache, char *hostname,
+                  int host_len)
 {
-
   if (!CacheProcessor::IsCacheReady(frag_type)) {
-    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) 
-ECACHE_NOT_READY);
+    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-ECACHE_NOT_READY);
     return ACTION_RESULT_DONE;
   }
 
@@ -1658,12 +1643,12 @@ Cache::open_write(Continuation *cont, CacheKey *key, 
CacheFragType frag_type,
   c->f.overwrite = (options & CACHE_WRITE_OPT_OVERWRITE) != 0;
   c->f.close_complete = (options & CACHE_WRITE_OPT_CLOSE_COMPLETE) != 0;
   c->f.sync = (options & CACHE_WRITE_OPT_SYNC) == CACHE_WRITE_OPT_SYNC;
-  c->pin_in_cache = (uint32_t) apin_in_cache;
+  c->pin_in_cache = (uint32_t)apin_in_cache;
 
   if ((res = c->vol->open_write_lock(c, false, 1)) > 0) {
     // document currently being written, abort
     CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_FAILURE);
-    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) -res);
+    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-res);
     free_CacheVC(c);
     return ACTION_RESULT_DONE;
   }
@@ -1688,17 +1673,17 @@ Cache::open_write(Continuation *cont, CacheKey *key, 
CacheFragType frag_type,
 #ifdef HTTP_CACHE
 // main entry point for writing of http documents
 Action *
-Cache::open_write(Continuation *cont, CacheKey *key, CacheHTTPInfo *info, 
time_t apin_in_cache,
-                  CacheKey */* key1 ATS_UNUSED */, CacheFragType type, char 
*hostname, int host_len)
+Cache::open_write(Continuation *cont, CacheKey *key, CacheHTTPInfo *info, 
time_t apin_in_cache, CacheKey * /* key1 ATS_UNUSED */,
+                  CacheFragType type, char *hostname, int host_len)
 {
   if (!CacheProcessor::IsCacheReady(type)) {
-    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) 
-ECACHE_NOT_READY);
+    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-ECACHE_NOT_READY);
     return ACTION_RESULT_DONE;
   }
 
   ink_assert(caches[type] == this);
   intptr_t err = 0;
-  int if_writers = (uintptr_t) info == CACHE_ALLOW_MULTIPLE_WRITES;
+  int if_writers = (uintptr_t)info == CACHE_ALLOW_MULTIPLE_WRITES;
   CacheVC *c = new_CacheVC(cont);
   ProxyMutex *mutex = cont->mutex;
   c->vio.op = VIO::WRITE;
@@ -1712,14 +1697,13 @@ Cache::open_write(Continuation *cont, CacheKey *key, 
CacheHTTPInfo *info, time_t
    */
   do {
     rand_CacheKey(&c->key, cont->mutex);
-  }
-  while (DIR_MASK_TAG(c->key.slice32(2)) == 
DIR_MASK_TAG(c->first_key.slice32(2)));
+  } while (DIR_MASK_TAG(c->key.slice32(2)) == 
DIR_MASK_TAG(c->first_key.slice32(2)));
   c->earliest_key = c->key;
   c->frag_type = CACHE_FRAG_TYPE_HTTP;
   c->vol = key_to_vol(key, hostname, host_len);
   Vol *vol = c->vol;
   c->info = info;
-  if (c->info && (uintptr_t) info != CACHE_ALLOW_MULTIPLE_WRITES) {
+  if (c->info && (uintptr_t)info != CACHE_ALLOW_MULTIPLE_WRITES) {
     /*
        Update has the following code paths :
        a) Update alternate header only :
@@ -1758,13 +1742,12 @@ Cache::open_write(Continuation *cont, CacheKey *key, 
CacheHTTPInfo *info, time_t
   } else
     c->base_stat = cache_write_active_stat;
   CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE);
-  c->pin_in_cache = (uint32_t) apin_in_cache;
+  c->pin_in_cache = (uint32_t)apin_in_cache;
 
   {
     CACHE_TRY_LOCK(lock, c->vol->mutex, cont->mutex->thread_holding);
     if (lock.is_locked()) {
-      if ((err = c->vol->open_write(c, if_writers,
-                                     cache_config_http_max_alts > 1 ? 
cache_config_http_max_alts : 0)) > 0)
+      if ((err = c->vol->open_write(c, if_writers, cache_config_http_max_alts 
> 1 ? cache_config_http_max_alts : 0)) > 0)
         goto Lfailure;
       // If there are multiple writers, then this one cannot be an update.
       // Only the first writer can do an update. If that's the case, we can
@@ -1785,9 +1768,12 @@ Cache::open_write(Continuation *cont, CacheKey *key, 
CacheHTTPInfo *info, time_t
         // document exists, read vector
         SET_CONTINUATION_HANDLER(c, &CacheVC::openWriteStartDone);
         switch (c->do_read_call(&c->first_key)) {
-          case EVENT_DONE: return ACTION_RESULT_DONE;
-          case EVENT_RETURN: goto Lcallreturn;
-          default: return &c->_action;
+        case EVENT_DONE:
+          return ACTION_RESULT_DONE;
+        case EVENT_RETURN:
+          goto Lcallreturn;
+        default:
+          return &c->_action;
         }
       }
     }
@@ -1804,7 +1790,7 @@ Lmiss:
 
 Lfailure:
   CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_FAILURE);
-  cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) -err);
+  cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err);
   if (c->od) {
     c->openWriteCloseDir(EVENT_IMMEDIATE, 0);
     return ACTION_RESULT_DONE;
@@ -1826,18 +1812,16 @@ InterimCacheVol::aggWrite(int /* event ATS_UNUSED */, 
void * /* ATS_UNUSED e */)
   MigrateToInterimCache *mts;
   Doc *doc;
   uint64_t old_off, new_off;
-  ink_assert(this_ethread() == mutex.m_ptr->thread_holding
-      && vol->mutex.m_ptr == mutex.m_ptr);
+  ink_assert(this_ethread() == mutex.m_ptr->thread_holding && vol->mutex.m_ptr 
== mutex.m_ptr);
 Lagain:
 
   while ((mts = agg.head) != NULL) {
-    doc = (Doc *) mts->buf->data();
+    doc = (Doc *)mts->buf->data();
     uint32_t agg_len = dir_approx_size(&mts->dir);
     ink_assert(agg_len == mts->agg_len);
     ink_assert(agg_len <= AGG_SIZE && agg_buf_pos <= AGG_SIZE);
 
-    if (agg_buf_pos + agg_len > AGG_SIZE
-        || header->agg_pos + agg_len > (skip + len))
+    if (agg_buf_pos + agg_len > AGG_SIZE || header->agg_pos + agg_len > (skip 
+ len))
       break;
     mts = agg.dequeue();
 
@@ -1864,12 +1848,13 @@ Lagain:
         dir_overwrite(&mts->key, vol, &mts->dir, &old_dir);
       else
         dir_insert(&mts->key, vol, &mts->dir);
-      DDebug("cache_insert", "InterimCache: WriteDone: key: %X, first_key: %X, 
write_len: %d, write_offset: %" PRId64 ", dir_last_word: %X",
-          doc->key.slice32(0), doc->first_key.slice32(0), mts->agg_len, o, 
mts->dir.w[4]);
+      DDebug("cache_insert",
+             "InterimCache: WriteDone: key: %X, first_key: %X, write_len: %d, 
write_offset: %" PRId64 ", dir_last_word: %X",
+             doc->key.slice32(0), doc->first_key.slice32(0), mts->agg_len, o, 
mts->dir.w[4]);
 
       if (mts->copy) {
-        mts->interim_vol->vol->ram_cache->fixup(&mts->key, (uint32_t)(old_off 
>> 32), (uint32_t)old_off,
-            (uint32_t)(new_off >> 32), (uint32_t)new_off);
+        mts->interim_vol->vol->ram_cache->fixup(&mts->key, (uint32_t)(old_off 
>> 32), (uint32_t)old_off, (uint32_t)(new_off >> 32),
+                                                (uint32_t)new_off);
       } else {
         mts->vc->f.ram_fixup = 1;
         mts->vc->dir_off = new_off;
@@ -1895,14 +1880,13 @@ Lagain:
     return EVENT_CONT;
   }
 
-  if (agg.head == NULL && agg_buf_pos < (AGG_SIZE / 2) && !sync
-      && header->write_pos + AGG_SIZE <= (skip + len))
+  if (agg.head == NULL && agg_buf_pos < (AGG_SIZE / 2) && !sync && 
header->write_pos + AGG_SIZE <= (skip + len))
     return EVENT_CONT;
 
   for (mts = agg.head; mts != NULL; mts = mts->link.next) {
     if (!mts->copy) {
       Ptr<IOBufferData> buf = mts->buf;
-      doc = (Doc *) buf->data();
+      doc = (Doc *)buf->data();
       mts->buf = new_IOBufferData(iobuffer_size_to_index(mts->agg_len, 
MAX_BUFFER_SIZE_INDEX), MEMALIGNED);
       mts->copy = true;
       memcpy(mts->buf->data(), buf->data(), doc->len);
@@ -1930,42 +1914,40 @@ Lagain:
 int
 InterimCacheVol::aggWriteDone(int event, void *e)
 {
-  ink_release_assert(this_ethread() == mutex.m_ptr->thread_holding
-        && vol->mutex.m_ptr == mutex.m_ptr);
+  ink_release_assert(this_ethread() == mutex.m_ptr->thread_holding && 
vol->mutex.m_ptr == mutex.m_ptr);
   if (io.ok()) {
-     header->last_write_pos = header->write_pos;
-     header->write_pos += io.aiocb.aio_nbytes;
-     ink_assert(header->write_pos >= start);
-     DDebug("cache_agg", "Write: %" PRIu64 ", last Write: %" PRIu64 "\n",
-           header->write_pos, header->last_write_pos);
-     ink_assert(header->write_pos == header->agg_pos);
-     agg_buf_pos = 0;
-     header->write_serial++;
-   } else {
-     // delete all the directory entries that we inserted
-     // for fragments is this aggregation buffer
-     Debug("cache_disk_error", "Write error on disk %s\n \
+    header->last_write_pos = header->write_pos;
+    header->write_pos += io.aiocb.aio_nbytes;
+    ink_assert(header->write_pos >= start);
+    DDebug("cache_agg", "Write: %" PRIu64 ", last Write: %" PRIu64 "\n", 
header->write_pos, header->last_write_pos);
+    ink_assert(header->write_pos == header->agg_pos);
+    agg_buf_pos = 0;
+    header->write_serial++;
+  } else {
+    // delete all the directory entries that we inserted
+    // for fragments is this aggregation buffer
+    Debug("cache_disk_error", "Write error on disk %s\n \
                write range : [%" PRIu64 " - %" PRIu64 " bytes]  [%" PRIu64 " - 
%" PRIu64 " blocks] \n",
-           "InterimCache ID", (uint64_t)io.aiocb.aio_offset, 
(uint64_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes),
-           (uint64_t)io.aiocb.aio_offset / CACHE_BLOCK_SIZE,
-           (uint64_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes) / 
CACHE_BLOCK_SIZE);
-     Dir del_dir;
-     dir_clear(&del_dir);
-     dir_set_ininterim(&del_dir);
-     dir_set_index(&del_dir, (this - vol->interim_vols));
-     for (int done = 0; done < agg_buf_pos;) {
-       Doc *doc = (Doc *) (agg_buffer + done);
-       dir_set_offset(&del_dir, header->write_pos + done);
-       dir_delete(&doc->key, vol, &del_dir);
-       done += this->round_to_approx_size(doc->len);
-     }
-     agg_buf_pos = 0;
-   }
-   set_io_not_in_progress();
-   sync = false;
-   if (agg.head)
-     aggWrite(event, e);
-   return EVENT_CONT;
+          "InterimCache ID", (uint64_t)io.aiocb.aio_offset, 
(uint64_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes),
+          (uint64_t)io.aiocb.aio_offset / CACHE_BLOCK_SIZE,
+          (uint64_t)(io.aiocb.aio_offset + io.aiocb.aio_nbytes) / 
CACHE_BLOCK_SIZE);
+    Dir del_dir;
+    dir_clear(&del_dir);
+    dir_set_ininterim(&del_dir);
+    dir_set_index(&del_dir, (this - vol->interim_vols));
+    for (int done = 0; done < agg_buf_pos;) {
+      Doc *doc = (Doc *)(agg_buffer + done);
+      dir_set_offset(&del_dir, header->write_pos + done);
+      dir_delete(&doc->key, vol, &del_dir);
+      done += this->round_to_approx_size(doc->len);
+    }
+    agg_buf_pos = 0;
+  }
+  set_io_not_in_progress();
+  sync = false;
+  if (agg.head)
+    aggWrite(event, e);
+  return EVENT_CONT;
 }
 #endif
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/I_Cache.h
----------------------------------------------------------------------
diff --git a/iocore/cache/I_Cache.h b/iocore/cache/I_Cache.h
index 69fa156..af99d30 100644
--- a/iocore/cache/I_Cache.h
+++ b/iocore/cache/I_Cache.h
@@ -32,24 +32,22 @@
 
 #define CACHE_MODULE_MAJOR_VERSION 1
 #define CACHE_MODULE_MINOR_VERSION 0
-#define CACHE_MODULE_VERSION       
makeModuleVersion(CACHE_MODULE_MAJOR_VERSION,\
-                                                  CACHE_MODULE_MINOR_VERSION,\
-                                                  PUBLIC_MODULE_HEADER)
+#define CACHE_MODULE_VERSION makeModuleVersion(CACHE_MODULE_MAJOR_VERSION, 
CACHE_MODULE_MINOR_VERSION, PUBLIC_MODULE_HEADER)
 
-#define CACHE_WRITE_OPT_OVERWRITE       0x0001
-#define CACHE_WRITE_OPT_CLOSE_COMPLETE  0x0002
-#define CACHE_WRITE_OPT_SYNC            (CACHE_WRITE_OPT_CLOSE_COMPLETE | 
0x0004)
-#define CACHE_WRITE_OPT_OVERWRITE_SYNC  (CACHE_WRITE_OPT_SYNC | 
CACHE_WRITE_OPT_OVERWRITE)
+#define CACHE_WRITE_OPT_OVERWRITE 0x0001
+#define CACHE_WRITE_OPT_CLOSE_COMPLETE 0x0002
+#define CACHE_WRITE_OPT_SYNC (CACHE_WRITE_OPT_CLOSE_COMPLETE | 0x0004)
+#define CACHE_WRITE_OPT_OVERWRITE_SYNC (CACHE_WRITE_OPT_SYNC | 
CACHE_WRITE_OPT_OVERWRITE)
 
-#define SCAN_KB_PER_SECOND      8192 // 1TB/8MB = 131072 = 36 HOURS to scan a 
TB
+#define SCAN_KB_PER_SECOND 8192 // 1TB/8MB = 131072 = 36 HOURS to scan a TB
 
-#define RAM_CACHE_ALGORITHM_CLFUS        0
-#define RAM_CACHE_ALGORITHM_LRU          1
+#define RAM_CACHE_ALGORITHM_CLFUS 0
+#define RAM_CACHE_ALGORITHM_LRU 1
 
-#define CACHE_COMPRESSION_NONE           0
-#define CACHE_COMPRESSION_FASTLZ         1
-#define CACHE_COMPRESSION_LIBZ           2
-#define CACHE_COMPRESSION_LIBLZMA        3
+#define CACHE_COMPRESSION_NONE 0
+#define CACHE_COMPRESSION_FASTLZ 1
+#define CACHE_COMPRESSION_LIBZ 2
+#define CACHE_COMPRESSION_LIBLZMA 3
 
 struct CacheVC;
 struct CacheDisk;
@@ -64,13 +62,12 @@ typedef URL CacheURL;
 typedef HTTPInfo CacheHTTPInfo;
 #endif
 
-struct CacheProcessor:public Processor
-{
+struct CacheProcessor : public Processor {
   CacheProcessor()
-    : min_stripe_version(CACHE_DB_MAJOR_VERSION, CACHE_DB_MINOR_VERSION)
-    , max_stripe_version(CACHE_DB_MAJOR_VERSION, CACHE_DB_MINOR_VERSION)
-    , cb_after_init(0)
-  {}
+    : min_stripe_version(CACHE_DB_MAJOR_VERSION, CACHE_DB_MINOR_VERSION),
+      max_stripe_version(CACHE_DB_MAJOR_VERSION, CACHE_DB_MINOR_VERSION), 
cb_after_init(0)
+  {
+  }
 
   virtual int start(int n_cache_threads = 0, size_t stacksize = 
DEFAULT_STACKSIZE);
   virtual int start_internal(int flags = 0);
@@ -79,47 +76,35 @@ struct CacheProcessor:public Processor
   int dir_check(bool fix);
   int db_check(bool fix);
 
-  inkcoreapi Action *lookup(Continuation *cont, CacheKey *key, bool 
cluster_cache_local,
-                            bool local_only = false,
+  inkcoreapi Action *lookup(Continuation *cont, CacheKey *key, bool 
cluster_cache_local, bool local_only = false,
                             CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, 
char *hostname = 0, int host_len = 0);
   inkcoreapi Action *open_read(Continuation *cont, CacheKey *key, bool 
cluster_cache_local,
                                CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, 
char *hostname = 0, int host_len = 0);
-  inkcoreapi Action *open_write(Continuation *cont,
-                                CacheKey *key,
-                                bool cluster_cache_local,
-                                CacheFragType frag_type = CACHE_FRAG_TYPE_NONE,
-                                int expected_size = CACHE_EXPECTED_SIZE,
-                                int options = 0,
-                                time_t pin_in_cache = (time_t) 0,
-                                char *hostname = 0, int host_len = 0);
-  inkcoreapi Action *remove(Continuation *cont, CacheKey *key,
-                            bool cluster_cache_local,
-                            CacheFragType frag_type = CACHE_FRAG_TYPE_NONE,
-                            bool rm_user_agents = true, bool rm_link = false,
+  inkcoreapi Action *open_write(Continuation *cont, CacheKey *key, bool 
cluster_cache_local,
+                                CacheFragType frag_type = 
CACHE_FRAG_TYPE_NONE, int expected_size = CACHE_EXPECTED_SIZE,
+                                int options = 0, time_t pin_in_cache = 
(time_t)0, char *hostname = 0, int host_len = 0);
+  inkcoreapi Action *remove(Continuation *cont, CacheKey *key, bool 
cluster_cache_local,
+                            CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, 
bool rm_user_agents = true, bool rm_link = false,
                             char *hostname = 0, int host_len = 0);
   Action *scan(Continuation *cont, char *hostname = 0, int host_len = 0, int 
KB_per_second = SCAN_KB_PER_SECOND);
 #ifdef HTTP_CACHE
   Action *lookup(Continuation *cont, URL *url, bool cluster_cache_local, bool 
local_only = false,
                  CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
-  inkcoreapi Action *open_read(Continuation *cont, URL *url,
-                               bool cluster_cache_local,
-                               CacheHTTPHdr *request,
-                               CacheLookupHttpConfig *params,
-                               time_t pin_in_cache = (time_t) 0, CacheFragType 
frag_type = CACHE_FRAG_TYPE_HTTP);
-  Action *open_write(Continuation *cont, int expected_size, URL *url, bool 
cluster_cache_local,
-                     CacheHTTPHdr *request, CacheHTTPInfo *old_info,
-                     time_t pin_in_cache = (time_t) 0, CacheFragType frag_type 
= CACHE_FRAG_TYPE_HTTP);
+  inkcoreapi Action *open_read(Continuation *cont, URL *url, bool 
cluster_cache_local, CacheHTTPHdr *request,
+                               CacheLookupHttpConfig *params, time_t 
pin_in_cache = (time_t)0,
+                               CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
+  Action *open_write(Continuation *cont, int expected_size, URL *url, bool 
cluster_cache_local, CacheHTTPHdr *request,
+                     CacheHTTPInfo *old_info, time_t pin_in_cache = (time_t)0, 
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
   Action *remove(Continuation *cont, URL *url, bool cluster_cache_local, 
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP);
 
-  Action *open_read_internal(int, Continuation *, MIOBuffer *, CacheURL *,
-                             CacheHTTPHdr *, CacheLookupHttpConfig *,
-                             CacheKey *, time_t, CacheFragType type, char 
*hostname, int host_len);
+  Action *open_read_internal(int, Continuation *, MIOBuffer *, CacheURL *, 
CacheHTTPHdr *, CacheLookupHttpConfig *, CacheKey *,
+                             time_t, CacheFragType type, char *hostname, int 
host_len);
 #endif
   Action *link(Continuation *cont, CacheKey *from, CacheKey *to, bool 
cluster_cache_local,
                CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP, char *hostname 
= 0, int host_len = 0);
 
-  Action *deref(Continuation *cont, CacheKey *key, bool cluster_cache_local,
-                CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP, char *hostname 
= 0, int host_len = 0);
+  Action *deref(Continuation *cont, CacheKey *key, bool cluster_cache_local, 
CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP,
+                char *hostname = 0, int host_len = 0);
 
   /** Mark physical disk/device/file as offline.
       All stripes for this device are disabled.
@@ -128,13 +113,13 @@ struct CacheProcessor:public Processor
 
       @note This is what is called if a disk is disabled due to I/O errors.
   */
-  bool mark_storage_offline(CacheDisk* d);
+  bool mark_storage_offline(CacheDisk *d);
 
   /** Find the storage for a @a path.
       If @a len is 0 then @a path is presumed null terminated.
       @return @c NULL if the path does not match any defined storage.
    */
-  CacheDisk* find_by_path(char const* path, int len = 0);
+  CacheDisk *find_by_path(char const *path, int len = 0);
 
   /** Check if there are any online storage devices.
       If this returns @c false then the cache should be disabled as there is 
no storage available.
@@ -184,17 +169,17 @@ CacheProcessor::set_after_init_callback(CALLBACK_FUNC cb)
   cb_after_init = cb;
 }
 
-struct CacheVConnection:public VConnection
-{
+struct CacheVConnection : public VConnection {
   VIO *do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) = 0;
   virtual VIO *do_io_pread(Continuation *c, int64_t nbytes, MIOBuffer *buf, 
int64_t offset) = 0;
   VIO *do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool 
owner = false) = 0;
   void do_io_close(int lerrno = -1) = 0;
   void reenable(VIO *avio) = 0;
   void reenable_re(VIO *avio) = 0;
-  void do_io_shutdown(ShutdownHowTo_t howto)
+  void
+  do_io_shutdown(ShutdownHowTo_t howto)
   {
-    (void) howto;
+    (void)howto;
     ink_assert(!"CacheVConnection::do_io_shutdown unsupported");
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/cache/I_CacheDefs.h
----------------------------------------------------------------------
diff --git a/iocore/cache/I_CacheDefs.h b/iocore/cache/I_CacheDefs.h
index bd5bf46..93b0cac 100644
--- a/iocore/cache/I_CacheDefs.h
+++ b/iocore/cache/I_CacheDefs.h
@@ -22,50 +22,48 @@
  */
 
 
-
 #ifndef _I_CACHE_DEFS_H__
 #define _I_CACHE_DEFS_H__
 
-#define CACHE_INIT_FAILED           -1
-#define CACHE_INITIALIZING          0
-#define CACHE_INITIALIZED           1
+#define CACHE_INIT_FAILED -1
+#define CACHE_INITIALIZING 0
+#define CACHE_INITIALIZED 1
 
-#define CACHE_ALT_INDEX_DEFAULT     -1
-#define CACHE_ALT_REMOVED           -2
+#define CACHE_ALT_INDEX_DEFAULT -1
+#define CACHE_ALT_REMOVED -2
 
-#define CACHE_DB_MAJOR_VERSION      24
-#define CACHE_DB_MINOR_VERSION      0
+#define CACHE_DB_MAJOR_VERSION 24
+#define CACHE_DB_MINOR_VERSION 0
 
-#define CACHE_DIR_MAJOR_VERSION     18
-#define CACHE_DIR_MINOR_VERSION     0
+#define CACHE_DIR_MAJOR_VERSION 18
+#define CACHE_DIR_MINOR_VERSION 0
 
-#define CACHE_DB_FDS                128
+#define CACHE_DB_FDS 128
 
 // opcodes
-#define CACHE_OPEN_READ                        1
-#define CACHE_OPEN_READ_BUFFER         2
-#define CACHE_OPEN_READ_LONG           3
-#define CACHE_OPEN_READ_BUFFER_LONG    4
-#define CACHE_OPEN_WRITE               5
-#define CACHE_OPEN_WRITE_BUFFER                6
-#define CACHE_OPEN_WRITE_LONG          7
-#define CACHE_OPEN_WRITE_BUFFER_LONG   8
-#define CACHE_UPDATE                   9
-#define CACHE_REMOVE                   10
-#define CACHE_LINK                     11
-#define CACHE_DEREF                    12
-#define CACHE_LOOKUP_OP                        13
+#define CACHE_OPEN_READ 1
+#define CACHE_OPEN_READ_BUFFER 2
+#define CACHE_OPEN_READ_LONG 3
+#define CACHE_OPEN_READ_BUFFER_LONG 4
+#define CACHE_OPEN_WRITE 5
+#define CACHE_OPEN_WRITE_BUFFER 6
+#define CACHE_OPEN_WRITE_LONG 7
+#define CACHE_OPEN_WRITE_BUFFER_LONG 8
+#define CACHE_UPDATE 9
+#define CACHE_REMOVE 10
+#define CACHE_LINK 11
+#define CACHE_DEREF 12
+#define CACHE_LOOKUP_OP 13
 
 enum CacheType {
-  CACHE_NONE_TYPE = 0,  // for empty disk fragments
+  CACHE_NONE_TYPE = 0, // for empty disk fragments
   CACHE_HTTP_TYPE = 1,
   CACHE_RTSP_TYPE = 2
 };
 
 // NOTE: All the failures are ODD, and one greater than the success
 //       Some of these must match those in <ts/ts.h>
-enum CacheEventType
-{
+enum CacheEventType {
   CACHE_EVENT_LOOKUP = CACHE_EVENT_EVENTS_START + 0,
   CACHE_EVENT_LOOKUP_FAILED = CACHE_EVENT_EVENTS_START + 1,
   CACHE_EVENT_OPEN_READ = CACHE_EVENT_EVENTS_START + 2,
@@ -95,8 +93,7 @@ enum CacheEventType
   CACHE_EVENT_RESPONSE_RETRY
 };
 
-enum CacheScanResult
-{
+enum CacheScanResult {
   CACHE_SCAN_RESULT_CONTINUE = EVENT_CONT,
   CACHE_SCAN_RESULT_DONE = EVENT_DONE,
   CACHE_SCAN_RESULT_DELETE = 10,
@@ -105,18 +102,16 @@ enum CacheScanResult
   CACHE_SCAN_RESULT_RETRY
 };
 
-enum CacheDataType
-{
+enum CacheDataType {
   CACHE_DATA_HTTP_INFO = VCONNECTION_CACHE_DATA_BASE,
   CACHE_DATA_KEY,
-  CACHE_DATA_RAM_CACHE_HIT_FLAG
+  CACHE_DATA_RAM_CACHE_HIT_FLAG,
 };
 
-enum CacheFragType
-{
+enum CacheFragType {
   CACHE_FRAG_TYPE_NONE,
   CACHE_FRAG_TYPE_HTTP_V23, ///< DB version 23 or prior.
-  CACHE_FRAG_TYPE_RTSP, ///< Should be removed once Cache Toolkit is 
implemented.
+  CACHE_FRAG_TYPE_RTSP,     ///< Should be removed once Cache Toolkit is 
implemented.
   CACHE_FRAG_TYPE_HTTP,
   NUM_CACHE_FRAG_TYPES
 };

Reply via email to