You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2009/12/03 22:55:17 UTC
svn commit: r886935 - in
/incubator/trafficserver/traffic/trunk/iocore/cache: Cache.cc CacheWrite.cc
P_CachePart.h
Author: jplevyak
Date: Thu Dec 3 21:55:17 2009
New Revision: 886935
URL: http://svn.apache.org/viewvc?rev=886935&view=rev
Log:
Fix for TS-39: recovery while the write_pos is at the end of the partititon
results in the partition being cleared.
Modified:
incubator/trafficserver/traffic/trunk/iocore/cache/Cache.cc
incubator/trafficserver/traffic/trunk/iocore/cache/CacheWrite.cc
incubator/trafficserver/traffic/trunk/iocore/cache/P_CachePart.h
Modified: incubator/trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=886935&r1=886934&r2=886935&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ incubator/trafficserver/traffic/trunk/iocore/cache/Cache.cc Thu Dec 3 21:55:17 2009
@@ -87,34 +87,23 @@
Cache *caches[1 << NumCacheFragTypes] = { 0 };
CacheSync *cacheDirSync = 0;
Store theCacheStore;
-volatile int
- CacheProcessor::initialized = CACHE_INITIALIZING;
-volatile inku32
- CacheProcessor::cache_ready = 0;
-volatile int
- CacheProcessor::start_done = 0;
-int
- CacheProcessor::clear = 0;
-int
- CacheProcessor::fix = 0;
-int
- CacheProcessor::start_internal_flags = 0;
-int
- CacheProcessor::auto_clear_flag = 0;
-CacheProcessor
- cacheProcessor;
-Part **
- gpart = NULL;
-volatile int
- gnpart = 0;
+volatile int CacheProcessor::initialized = CACHE_INITIALIZING;
+volatile inku32 CacheProcessor::cache_ready = 0;
+volatile int CacheProcessor::start_done = 0;
+int CacheProcessor::clear = 0;
+int CacheProcessor::fix = 0;
+int CacheProcessor::start_internal_flags = 0;
+int CacheProcessor::auto_clear_flag = 0;
+CacheProcessor cacheProcessor;
+Part ** gpart = NULL;
+volatile int gnpart = 0;
ClassAllocator<CacheVC> cacheVConnectionAllocator("cacheVConnection");
ClassAllocator<NewCacheVC> newCacheVConnectionAllocator("newCacheVConnection");
ClassAllocator<EvacuationBlock> evacuationBlockAllocator("evacuationBlock");
ClassAllocator<CacheRemoveCont> cacheRemoveContAllocator("cacheRemoveCont");
ClassAllocator<EvacuationKey> evacuationKeyAllocator("evacuationKey");
-int
- CacheVC::size_to_init = -1;
+int CacheVC::size_to_init = -1;
CacheKey zero_key(0, 0);
@@ -965,7 +954,6 @@
int
Part::init(char *s, ink_off_t blocks, ink_off_t dir_skip, bool clear)
{
-
dir_skip = ROUND_TO_BLOCK((dir_skip < START_POS ? START_POS : dir_skip));
path = strdup(s);
const size_t hash_id_size = strlen(s) + 32;
@@ -978,8 +966,9 @@
ink_assert(len <= MAX_PART_SIZE);
skip = dir_skip;
int i;
+ prev_recover_pos = 0;
+
// successive approximation, directory/meta data eats up some storage
- prev_recover_pos = 0; //Bug fixed by YTS Team, yamsat BZ 59274
start = dir_skip;
part_init_data(this);
part_init_data(this);
@@ -1162,6 +1151,10 @@
last_sync_serial = 0;
last_write_serial = 0;
recover_pos = header->last_write_pos;
+ if (recover_pos >= skip + len) {
+ recover_wrapped = 1;
+ recover_pos = start;
+ }
#if defined(_WIN32)
io.aiocb.aio_buf = (char *) malloc(MAX_RECOVER_BYTES);
#else
@@ -1317,20 +1310,19 @@
io.aiocb.aio_nbytes = (skip + len) - recover_pos;
}
}
- if (recover_pos == prev_recover_pos) //Bug fixed by YTS Team, yamsat BZ59274
- goto Lclear; //Bug fixed by YTS Team, yamsat BZ59274
- prev_recover_pos = recover_pos; //Bug fixed by YTS Team, yamsat BZ59274
+ if (recover_pos == prev_recover_pos) // this should never happen, but if it does break the loop
+ goto Lclear;
+ prev_recover_pos = recover_pos;
io.aiocb.aio_offset = recover_pos;
ink_assert(ink_aio_read(&io));
return EVENT_CONT;
Ldone:{
- /* if we come back to the starting position, then
- we don't have to recover anything??? */
+ /* if we come back to the starting position, then we don't have to recover anything */
if (recover_pos == header->write_pos && recover_wrapped) {
SET_HANDLER(&Part::handle_recover_write_dir);
if (is_debug_tag_set("cache_init"))
- Note("recovery wrapped around. Nothing to Clear\n");
+ Note("recovery wrapped around. nothing to clear\n");
return handle_recover_write_dir(EVENT_IMMEDIATE, 0);
}
Modified: incubator/trafficserver/traffic/trunk/iocore/cache/CacheWrite.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/cache/CacheWrite.cc?rev=886935&r1=886934&r2=886935&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/cache/CacheWrite.cc (original)
+++ incubator/trafficserver/traffic/trunk/iocore/cache/CacheWrite.cc Thu Dec 3 21:55:17 2009
@@ -976,7 +976,6 @@
void
Part::agg_wrap()
{
- // wrap -- FIXME: make these atomic
header->write_pos = start;
header->phase = !header->phase;
Modified: incubator/trafficserver/traffic/trunk/iocore/cache/P_CachePart.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/iocore/cache/P_CachePart.h?rev=886935&r1=886934&r2=886935&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/iocore/cache/P_CachePart.h (original)
+++ incubator/trafficserver/traffic/trunk/iocore/cache/P_CachePart.h Thu Dec 3 21:55:17 2009
@@ -201,7 +201,7 @@
Dir *segment[DIR_SEGMENTS];
MetaData *metadata;
ink_off_t recover_pos;
- ink_off_t prev_recover_pos; //Bug fixed by YTS Team, yamsat BZ59274
+ ink_off_t prev_recover_pos;
ink_off_t scan_pos;
ink_off_t metadata_pos;
ink_off_t skip; // start of headers