Commit e59ed34a authored by John Esmet's avatar John Esmet

FT-197 Store cachefiles in OMTs only, remove linked list pointers

parent a8cacc54
......@@ -178,8 +178,6 @@ class pair_list;
// Maps to a file on disk.
//
struct cachefile {
CACHEFILE next;
CACHEFILE prev;
// these next two fields are protected by cachetable's list lock
// they are managed whenever we add or remove a pair from
// the cachetable. As of Riddler, this linked list is only used to
......@@ -439,14 +437,12 @@ class cachefile_list {
bool evict_some_stale_pair(evictor* ev);
void free_stale_data(evictor* ev);
// access to these fields are protected by the lock
CACHEFILE m_active_head; // head of CACHEFILEs that are active
CACHEFILE m_stale_head; // head of CACHEFILEs that are stale
CACHEFILE m_stale_tail; // tail of CACHEFILEs that are stale
FILENUM m_next_filenum_to_use;
uint32_t m_next_hash_id_to_use;
toku_pthread_rwlock_t m_lock; // this field is publoc so we are still POD
toku::omt<CACHEFILE> m_active_filenum;
toku::omt<CACHEFILE> m_active_fileid;
toku::omt<CACHEFILE> m_stale_fileid;
private:
CACHEFILE find_cachefile_in_list_unlocked(CACHEFILE start, struct fileid* fileid);
};
......
This diff is collapsed.
......@@ -112,6 +112,14 @@ struct checkpointer_test {
uint32_t k);
};
static void init_cachefile(CACHEFILE cf, int which_cf, bool for_checkpoint) {
memset(cf, 0, sizeof(*cf));
create_dummy_functions(cf);
cf->fileid = { 0, (unsigned) which_cf };
cf->filenum = { (unsigned) which_cf };
cf->for_checkpoint = for_checkpoint;
}
//------------------------------------------------------------------------------
// test_begin_checkpoint() -
//
......@@ -135,33 +143,28 @@ void checkpointer_test::test_begin_checkpoint() {
// 2. Call checkpoint with ONE cachefile.
//cachefile cf;
struct cachefile cf;
cf.next = NULL;
cf.for_checkpoint = false;
m_cp.m_cf_list->m_active_head = &cf;
create_dummy_functions(&cf);
init_cachefile(&cf, 0, false);
m_cp.m_cf_list->add_cf_unlocked(&cf);
m_cp.begin_checkpoint();
assert(m_cp.m_checkpoint_num_files == 1);
assert(cf.for_checkpoint == true);
m_cp.m_cf_list->remove_cf(&cf);
// 3. Call checkpoint with MANY cachefiles.
const uint32_t count = 3;
struct cachefile cfs[count];
m_cp.m_cf_list->m_active_head = &cfs[0];
for (uint32_t i = 0; i < count; ++i) {
cfs[i].for_checkpoint = false;
init_cachefile(&cfs[i], i, false);
create_dummy_functions(&cfs[i]);
if (i == count - 1) {
cfs[i].next = NULL;
} else {
cfs[i].next = &cfs[i + 1];
}
m_cp.m_cf_list->add_cf_unlocked(&cfs[i]);
}
m_cp.begin_checkpoint();
assert(m_cp.m_checkpoint_num_files == count);
for (uint32_t i = 0; i < count; ++i) {
assert(cfs[i].for_checkpoint == true);
cfl.remove_cf(&cfs[i]);
}
ctbl.list.destroy();
m_cp.destroy();
......@@ -195,10 +198,8 @@ void checkpointer_test::test_pending_bits() {
//
struct cachefile cf;
cf.cachetable = &ctbl;
memset(&cf, 0, sizeof(cf));
cf.next = NULL;
cf.for_checkpoint = true;
m_cp.m_cf_list->m_active_head = &cf;
init_cachefile(&cf, 0, true);
m_cp.m_cf_list->add_cf_unlocked(&cf);
create_dummy_functions(&cf);
CACHEKEY k;
......@@ -258,6 +259,7 @@ void checkpointer_test::test_pending_bits() {
ctbl.list.destroy();
m_cp.destroy();
cfl.remove_cf(&cf);
cfl.destroy();
}
......@@ -337,14 +339,11 @@ void checkpointer_test::test_end_checkpoint() {
cfl.init();
struct cachefile cf;
memset(&cf, 0, sizeof(cf));
cf.next = NULL;
cf.for_checkpoint = true;
create_dummy_functions(&cf);
init_cachefile(&cf, 0, true);
ZERO_STRUCT(m_cp);
m_cp.init(&ctbl.list, NULL, &ctbl.ev, &cfl);
m_cp.m_cf_list->m_active_head = &cf;
m_cp.m_cf_list->add_cf_unlocked(&cf);
// 2. Add data before running checkpoint.
const uint32_t count = 6;
......@@ -394,6 +393,7 @@ void checkpointer_test::test_end_checkpoint() {
assert(pp);
m_cp.m_list->evict_completely(pp);
}
cfl.remove_cf(&cf);
m_cp.destroy();
ctbl.list.destroy();
cfl.destroy();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment