diff --git a/src/stasis/bufferManager/bufferHash.c b/src/stasis/bufferManager/bufferHash.c index b1b6563..d86f1bb 100644 --- a/src/stasis/bufferManager/bufferHash.c +++ b/src/stasis/bufferManager/bufferHash.c @@ -27,6 +27,20 @@ //#define LATCH_SANITY_CHECKING +struct stasis_buffer_hash_t { + struct LH_ENTRY(table) * cachedPages; + pthread_t worker; + pthread_mutex_t mut; + pthread_cond_t readComplete; + pthread_cond_t needFree; + pageid_t pageCount; + replacementPolicy *lru; + stasis_buffer_pool_t *buffer_pool; + stasis_page_handle_t *page_handler; + int flushing; + int running; +}; + static struct LH_ENTRY(table) * cachedPages; static pthread_t worker; diff --git a/src/stasis/logger/groupForce.c b/src/stasis/logger/groupForce.c index 1d4f41d..d92c424 100644 --- a/src/stasis/logger/groupForce.c +++ b/src/stasis/logger/groupForce.c @@ -5,9 +5,10 @@ * Author: sears */ #include - +#include #include #include +#include struct stasis_log_group_force_t { stasis_log_t * log; diff --git a/src/stasis/operations/alloc.c b/src/stasis/operations/alloc.c index 94960a9..f5001d4 100644 --- a/src/stasis/operations/alloc.c +++ b/src/stasis/operations/alloc.c @@ -204,18 +204,17 @@ stasis_operation_impl stasis_op_impl_realloc() { } static void stasis_alloc_register_old_regions(); -stasis_alloc_t* TallocInit() { +stasis_alloc_t* stasis_alloc_init(stasis_allocation_policy_t * allocPolicy) { stasis_alloc_t * alloc = malloc(sizeof(*alloc)); alloc->lastFreepage = PAGEID_T_MAX; - alloc->allocPolicy = stasis_allocation_policy_init(); + alloc->allocPolicy = allocPolicy; pthread_mutex_init(&alloc->mut, 0); return alloc; } -void TallocPostInit(stasis_alloc_t * alloc) { +void stasis_alloc_post_init(stasis_alloc_t * alloc) { stasis_alloc_register_old_regions(alloc); } -void TallocDeinit(stasis_alloc_t * alloc) { - stasis_allocation_policy_deinit(alloc->allocPolicy); +void stasis_alloc_deinit(stasis_alloc_t * alloc) { pthread_mutex_destroy(&alloc->mut); free(alloc); } diff --git a/src/stasis/recovery2.c b/src/stasis/recovery2.c index 9daf7ac..a709f44 100644 --- a/src/stasis/recovery2.c +++ b/src/stasis/recovery2.c @@ -364,7 +364,7 @@ void stasis_recovery_initiate(stasis_log_t* log, stasis_alloc_t * alloc) { stasis_recovery_redo(log); DEBUG("Undo started\n"); stasis_recovery_undo(log,1); - TallocPostInit(alloc); + stasis_alloc_post_init(alloc); DEBUG("Recovery complete.\n"); for(void * it = pblHtFirst(transactionLSN); it; it = pblHtNext(transactionLSN)) { diff --git a/src/stasis/transactional2.c b/src/stasis/transactional2.c index a5f0b81..2955b82 100644 --- a/src/stasis/transactional2.c +++ b/src/stasis/transactional2.c @@ -11,6 +11,7 @@ #include + #include #include #include @@ -32,6 +33,7 @@ static stasis_log_t* stasis_log_file = 0; stasis_dirty_page_table_t * stasis_dirty_page_table = 0; static stasis_truncation_t * stasis_truncation = 0; static stasis_alloc_t * stasis_alloc = 0; +static stasis_allocation_policy_t * stasis_allocation_policy = 0; /** This mutex protects stasis_transaction_table, numActiveXactions and @@ -99,7 +101,8 @@ int Tinit() { stasis_buffer_manager_open(bufferManagerType, page_handle); DEBUG("Buffer manager type = %d\n", bufferManagerType); pageOperationsInit(); - stasis_alloc = TallocInit(); + stasis_allocation_policy = stasis_allocation_policy_init(); + stasis_alloc = stasis_alloc_init(stasis_allocation_policy); TnaiveHashInit(); LinearHashNTAInit(); BtreeInit(); @@ -359,7 +362,8 @@ int Tdeinit() { assert( stasis_transaction_table_num_active == 0 ); stasis_truncation_deinit(stasis_truncation); TnaiveHashDeinit(); - TallocDeinit(stasis_alloc); + stasis_alloc_deinit(stasis_alloc); + stasis_allocation_policy_deinit(stasis_allocation_policy); stasis_buffer_manager_close(); DEBUG("Closing page file tdeinit\n"); stasis_page_deinit(); @@ -379,6 +383,9 @@ int TuncleanShutdown() { stasis_suppress_unclean_shutdown_warnings = 1; stasis_truncation_deinit(stasis_truncation); TnaiveHashDeinit(); + stasis_alloc_deinit(stasis_alloc); + stasis_allocation_policy_deinit(stasis_allocation_policy); + stasis_buffer_manager_simulate_crash(); // XXX: close_file? stasis_page_deinit(); diff --git a/stasis/operations/alloc.h b/stasis/operations/alloc.h index 8ab44a9..243ab6d 100644 --- a/stasis/operations/alloc.h +++ b/stasis/operations/alloc.h @@ -13,7 +13,7 @@ #define __ALLOC_H 1 #include - +#include stasis_operation_impl stasis_op_impl_alloc(); stasis_operation_impl stasis_op_impl_dealloc(); stasis_operation_impl stasis_op_impl_realloc(); @@ -23,9 +23,9 @@ typedef struct stasis_alloc_t stasis_alloc_t; void stasis_alloc_aborted(stasis_alloc_t* alloc, int xid); void stasis_alloc_committed(stasis_alloc_t* alloc, int xid); -stasis_alloc_t* TallocInit(); -void TallocPostInit(stasis_alloc_t* alloc); -void TallocDeinit(stasis_alloc_t* alloc); +stasis_alloc_t* stasis_alloc_init(stasis_allocation_policy_t * allocPolicy); +void stasis_alloc_post_init(stasis_alloc_t* alloc); +void stasis_alloc_deinit(stasis_alloc_t* alloc); /** Allocate a record.