trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jplev...@apache.org
Subject svn commit: r1103539 - in /trafficserver/traffic/trunk/iocore: aio/AIO.cc aio/I_AIO.h cache/Cache.cc cache/CacheDir.cc cache/CacheDisk.cc cache/CacheVol.cc cache/P_CacheDir.h cache/P_CacheVol.h
Date Sun, 15 May 2011 20:50:15 GMT
Author: jplevyak
Date: Sun May 15 20:50:15 2011
New Revision: 1103539

URL: http://svn.apache.org/viewvc?rev=1103539&view=rev
Log:
TS-773: the cache directory (and AIO reads and writes) can how exceed 2GB (MAX_INT).

Modified:
    trafficserver/traffic/trunk/iocore/aio/AIO.cc
    trafficserver/traffic/trunk/iocore/aio/I_AIO.h
    trafficserver/traffic/trunk/iocore/cache/Cache.cc
    trafficserver/traffic/trunk/iocore/cache/CacheDir.cc
    trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc
    trafficserver/traffic/trunk/iocore/cache/CacheVol.cc
    trafficserver/traffic/trunk/iocore/cache/P_CacheDir.h
    trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h

Modified: trafficserver/traffic/trunk/iocore/aio/AIO.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/aio/AIO.cc?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/aio/AIO.cc (original)
+++ trafficserver/traffic/trunk/iocore/aio/AIO.cc Sun May 15 20:50:15 2011
@@ -390,7 +390,7 @@ cache_op(AIOCallbackInternal *op)
   bool read = (op->aiocb.aio_lio_opcode == LIO_READ) ? 1 : 0;
   for (; op; op = (AIOCallbackInternal *) op->then) {
     ink_aiocb_t *a = &op->aiocb;
-    int err, res = 0;
+    ssize_t err, res = 0;
 
     while (a->aio_nbytes - res > 0) {
       do {
@@ -408,7 +408,7 @@ cache_op(AIOCallbackInternal *op)
       res += err;
     }
     op->aio_result = res;
-    ink_assert(op->aio_result == (int) a->aio_nbytes);
+    ink_assert(op->aio_result == (int64_t) a->aio_nbytes);
   }
   return 1;
 }

Modified: trafficserver/traffic/trunk/iocore/aio/I_AIO.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/aio/I_AIO.h?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/aio/I_AIO.h (original)
+++ trafficserver/traffic/trunk/iocore/aio/I_AIO.h Sun May 15 20:50:15 2011
@@ -67,7 +67,7 @@ struct AIOCallback: public Continuation
   EThread *thread;
   AIOCallback *then;
   // set on return from aio_read/aio_write
-  int aio_result;
+  int64_t aio_result;
 
   int ok();
   AIOCallback() : thread(AIO_CALLBACK_THREAD_ANY), then(0) {

Modified: trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Cache.cc Sun May 15 20:50:15 2011
@@ -978,7 +978,7 @@ vol_init_dir(Vol *d)
 void
 vol_clear_init(Vol *d)
 {
-  int dir_len = vol_dirlen(d);
+  size_t dir_len = vol_dirlen(d);
   memset(d->raw_dir, 0, dir_len);
   vol_init_dir(d);
   d->header->magic = VOL_MAGIC;
@@ -997,7 +997,7 @@ vol_clear_init(Vol *d)
 int
 vol_dir_clear(Vol *d)
 {
-  int dir_len = vol_dirlen(d);
+  size_t dir_len = vol_dirlen(d);
   vol_clear_init(d);
 
   if (pwrite(d->fd, d->raw_dir, dir_len, d->skip) < 0) {
@@ -1010,7 +1010,7 @@ vol_dir_clear(Vol *d)
 int
 Vol::clear_dir()
 {
-  int dir_len = vol_dirlen(this);
+  size_t dir_len = vol_dirlen(this);
   vol_clear_init(this);
 
   SET_HANDLER(&Vol::handle_dir_clear);
@@ -1112,17 +1112,17 @@ Vol::init(char *s, off_t blocks, off_t d
 int
 Vol::handle_dir_clear(int event, void *data)
 {
-  int dir_len = vol_dirlen(this);
+  size_t dir_len = vol_dirlen(this);
   AIOCallback *op;
 
   if (event == AIO_EVENT_DONE) {
     op = (AIOCallback *) data;
-    if ((int) op->aio_result != (int) op->aiocb.aio_nbytes) {
+    if ((size_t) op->aio_result != (size_t) op->aiocb.aio_nbytes) {
       Warning("unable to clear cache directory '%s'", hash_id);
       fd = -1;
     }
 
-    if ((int) op->aiocb.aio_nbytes == dir_len) {
+    if (op->aiocb.aio_nbytes == dir_len) {
       /* clear the header for directory B. We don't need to clear the
          whole of directory B. The header for directory B starts at
          skip + len */
@@ -1145,7 +1145,7 @@ Vol::handle_dir_read(int event, void *da
   AIOCallback *op = (AIOCallback *) data;
 
   if (event == AIO_EVENT_DONE) {
-    if ((int) op->aio_result != (int) op->aiocb.aio_nbytes) {
+    if ((size_t) op->aio_result != (size_t) op->aiocb.aio_nbytes) {
       clear_dir();
       return EVENT_DONE;
     }
@@ -1230,7 +1230,7 @@ Vol::handle_recover_from_data(int event,
     if ((off_t)(recover_pos + io.aiocb.aio_nbytes) > (off_t)(skip + len))
       io.aiocb.aio_nbytes = (skip + len) - recover_pos;
   } else if (event == AIO_EVENT_DONE) {
-    if ((int) io.aiocb.aio_nbytes != (int) io.aio_result) {
+    if ((size_t) io.aiocb.aio_nbytes != (size_t) io.aio_result) {
       Warning("disk read error on recover '%s', clearing", hash_id);
       goto Lclear;
     }
@@ -1424,7 +1424,7 @@ Ldone:{
       aio->then = (i < 2) ? &(init_info->vol_aio[i + 1]) : 0;
     }
     int footerlen = ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
-    int dirlen = vol_dirlen(this);
+    size_t dirlen = vol_dirlen(this);
     int B = header->sync_serial & 1;
     off_t ss = skip + (B ? dirlen : 0);
 
@@ -1483,7 +1483,7 @@ Vol::handle_header_read(int event, void 
     for (int i = 0; i < 4; i++) {
       ink_assert(op != 0);
       hf[i] = (VolHeaderFooter *) (op->aiocb.aio_buf);
-      if ((int) op->aio_result != (int) op->aiocb.aio_nbytes) {
+      if ((size_t) op->aio_result != (size_t) op->aiocb.aio_nbytes) {
         clear_dir();
         return EVENT_DONE;
       }
@@ -2084,7 +2084,7 @@ CacheVC::removeEvent(int event, Event *e
       goto Lcollision;
     }
     // check read completed correct FIXME: remove bad vols
-    if ((int) io.aio_result != (int) io.aiocb.aio_nbytes)
+    if ((size_t) io.aio_result != (size_t) io.aiocb.aio_nbytes)
       goto Ldone;
     {
       // verify that this is our document

Modified: trafficserver/traffic/trunk/iocore/cache/CacheDir.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/CacheDir.cc?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/CacheDir.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/CacheDir.cc Sun May 15 20:50:15 2011
@@ -891,7 +891,7 @@ sync_cache_dir_on_shutdown(void)
 {
   Debug("cache_dir_sync", "sync started");
   char *buf = NULL;
-  int buflen = 0;
+  size_t buflen = 0;
 
   EThread *t = (EThread *) 0xdeadbeef;
   for (int i = 0; i < gnvol; i++) {
@@ -905,7 +905,7 @@ sync_cache_dir_on_shutdown(void)
       Debug("cache_dir_sync", "Dir %s: ignoring -- bad disk", d->hash_id);
       continue;
     }
-    int dirlen = vol_dirlen(d);
+    size_t dirlen = vol_dirlen(d);
     if (!d->header->dirty && !d->dir_sync_in_progress) {
       Debug("cache_dir_sync", "Dir %s: ignoring -- not dirty", d->hash_id);
       continue;
@@ -953,7 +953,7 @@ sync_cache_dir_on_shutdown(void)
     d->footer->sync_serial = d->header->sync_serial;
     CHECK_DIR(d);
     memcpy(buf, d->raw_dir, dirlen);
-    int B = d->header->sync_serial & 1;
+    size_t B = d->header->sync_serial & 1;
     off_t start = d->skip + (B ? dirlen : 0);
     B = pwrite(d->fd, buf, dirlen, start);
     ink_debug_assert(B == dirlen);
@@ -994,7 +994,7 @@ Lrestart:
   }
   if (event == AIO_EVENT_DONE) {
     // AIO Thread
-    if (io.aio_result != (int) io.aiocb.aio_nbytes) {
+    if (io.aio_result != (int64_t)io.aiocb.aio_nbytes) {
       Warning("vol write error during directory sync '%s'", gvol[vol]->hash_id);
       event = EVENT_NONE;
       goto Ldone;
@@ -1019,7 +1019,7 @@ Lrestart:
       goto Ldone;
 
     int headerlen = ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
-    int dirlen = vol_dirlen(d);
+    size_t dirlen = vol_dirlen(d);
     if (!writepos) {
       // start
       Debug("cache_dir_sync", "sync started");
@@ -1054,22 +1054,22 @@ Lrestart:
       memcpy(buf, d->raw_dir, dirlen);
       d->dir_sync_in_progress = 1;
     }
-    int B = d->header->sync_serial & 1;
+    size_t B = d->header->sync_serial & 1;
     off_t start = d->skip + (B ? dirlen : 0);
 
     if (!writepos) {
       // write header
       aio_write(d->fd, buf + writepos, headerlen, start + writepos);
       writepos += headerlen;
-    } else if (writepos < dirlen - headerlen) {
+    } else if (writepos < (off_t)dirlen - headerlen) {
       // write part of body
       int l = SYNC_MAX_WRITE;
-      if (writepos + l > dirlen - headerlen)
+      if (writepos + l > (off_t)dirlen - headerlen)
         l = dirlen - headerlen - writepos;
       aio_write(d->fd, buf + writepos, l, start + writepos);
       writepos += l;
-    } else if (writepos < dirlen) {
-      ink_assert(writepos == dirlen - headerlen);
+    } else if (writepos < (off_t)dirlen) {
+      ink_assert(writepos == (off_t)dirlen - headerlen);
       // write footer
       aio_write(d->fd, buf + writepos, headerlen, start + writepos);
       writepos += headerlen;

Modified: trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc Sun May 15 20:50:15 2011
@@ -117,7 +117,7 @@ CacheDisk::clearDone(int event, void *da
   NOWARN_UNUSED(data);
   ink_assert(event == AIO_EVENT_DONE);
 
-  if ((int) io.aiocb.aio_nbytes != (int) io.aio_result) {
+  if ((size_t) io.aiocb.aio_nbytes != (size_t) io.aio_result) {
     Warning("Could not clear disk header for disk %s: declaring disk bad", path);
     SET_DISK_BAD(this);
   }
@@ -133,7 +133,7 @@ CacheDisk::openStart(int event, void *da
   NOWARN_UNUSED(data);
   ink_assert(event == AIO_EVENT_DONE);
 
-  if ((int) io.aiocb.aio_nbytes != (int) io.aio_result) {
+  if ((size_t) io.aiocb.aio_nbytes != (size_t) io.aio_result) {
     Warning("could not read disk header for disk %s: declaring disk bad", path);
     SET_DISK_BAD(this);
     SET_HANDLER(&CacheDisk::openDone);
@@ -188,7 +188,7 @@ CacheDisk::syncDone(int event, void *dat
 
   ink_assert(event == AIO_EVENT_DONE);
 
-  if ((int) io.aiocb.aio_nbytes != (int) io.aio_result) {
+  if ((size_t) io.aiocb.aio_nbytes != (size_t) io.aio_result) {
     Warning("Error writing disk header for disk %s:disk bad", path);
     SET_DISK_BAD(this);
     return EVENT_DONE;
@@ -217,7 +217,7 @@ CacheDisk::create_volume(int number, off
 //  ink_assert(!(size_in_blocks % blocks_per_vol));
   DiskVolBlock *p = 0;
   for (; q; q = q->link.next) {
-    if (q->b->len >= (unsigned int) size_in_blocks) {
+    if ((off_t)q->b->len >= size_in_blocks) {
       p = q->b;
       q->new_block = 1;
       break;
@@ -235,7 +235,7 @@ CacheDisk::create_volume(int number, off
     q = closest_match;
     p = q->b;
     q->new_block = 1;
-    ink_assert(size_in_blocks > (int) p->len);
+    ink_assert(size_in_blocks > (off_t) p->len);
     /* allocate in 128 megabyte chunks. The Remaining space should
        be thrown away */
     size_in_blocks = (p->len - (p->len % blocks_per_vol));
@@ -246,8 +246,8 @@ CacheDisk::create_volume(int number, off
   free_space -= p->len;
   free_blocks->size -= p->len;
 
-  int new_size = p->len - size_in_blocks;
-  if (new_size >= blocks_per_vol) {
+  size_t new_size = p->len - size_in_blocks;
+  if (new_size >= (size_t)blocks_per_vol) {
     /* create a new volume */
     DiskVolBlock *dpb = &header->vol_info[header->num_diskvol_blks];
     *dpb = *p;

Modified: trafficserver/traffic/trunk/iocore/cache/CacheVol.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/CacheVol.cc?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/CacheVol.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/CacheVol.cc Sun May 15 20:50:15 2011
@@ -194,7 +194,7 @@ CacheVC::scanObject(int event, Event * e
     goto Lread;
   }
 
-  if ((int) io.aio_result != (int) io.aiocb.aio_nbytes) {
+  if ((size_t)io.aio_result != (size_t) io.aiocb.aio_nbytes) {
     result = (void *) -ECACHE_READ_FAIL;
     goto Ldone;
   }

Modified: trafficserver/traffic/trunk/iocore/cache/P_CacheDir.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/P_CacheDir.h?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/P_CacheDir.h (original)
+++ trafficserver/traffic/trunk/iocore/cache/P_CacheDir.h Sun May 15 20:50:15 2011
@@ -265,8 +265,8 @@ struct CacheSync: public Continuation
 {
   int vol;
   char *buf;
-  int buflen;
-  int writepos;
+  size_t buflen;
+  off_t writepos;
   AIOCallbackInternal io;
   Event *trigger;
   int mainEvent(int event, Event *e);

Modified: trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h?rev=1103539&r1=1103538&r2=1103539&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h (original)
+++ trafficserver/traffic/trunk/iocore/cache/P_CacheVol.h Sun May 15 20:50:15 2011
@@ -343,11 +343,11 @@ vol_headerlen(Vol *d) {
   return ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter) + sizeof(uint16_t) * (d->segments-1));
 }
 
-TS_INLINE int
+TS_INLINE size_t
 vol_dirlen(Vol *d)
 {
   return vol_headerlen(d) + 
-    ROUND_TO_STORE_BLOCK(d->buckets * DIR_DEPTH * d->segments * SIZEOF_DIR) +
+    ROUND_TO_STORE_BLOCK(((size_t)d->buckets) * DIR_DEPTH * d->segments * SIZEOF_DIR)
+
     ROUND_TO_STORE_BLOCK(sizeof(VolHeaderFooter));
 }
 



Mime
View raw message