dependency cleanups; removed compenastions from alloc.c
This commit is contained in:
parent
94c542f8b1
commit
1ce1496226
39 changed files with 199 additions and 150 deletions
|
@ -1,5 +1,4 @@
|
|||
#include "lsn_bench_common.h"
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
unlink("storefile.txt");
|
||||
unlink("logfile.txt");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/truncation.h>
|
||||
|
||||
/*static stasis_handle_t * memory_factory(lsn_t off, lsn_t len, void * ignored) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/page/slotted.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stasis/page/raw.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char** argv) {
|
||||
assert(argc == 3);
|
||||
|
||||
|
||||
#define ZEROCOPY 0
|
||||
#define LSNMODE 1
|
||||
|
||||
|
@ -18,7 +20,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
int longsPerPage = PAGE_SIZE / sizeof(long);
|
||||
|
||||
if(ZEROCOPY == mode) {
|
||||
if(ZEROCOPY == mode) {
|
||||
printf("Running ZEROCOPY mode. Count = %d\n", count);
|
||||
}
|
||||
|
||||
|
@ -26,18 +28,18 @@ int main(int argc, char** argv) {
|
|||
int xid = Tbegin();
|
||||
|
||||
long * buf = malloc(longsPerPage * sizeof(long));
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
int pageNum = TpageAlloc(xid);
|
||||
|
||||
Page * p = loadPage(xid, pageNum);
|
||||
if(ZEROCOPY == mode) {
|
||||
if(ZEROCOPY == mode) {
|
||||
long * data = (long*) rawPageGetData(xid, p);
|
||||
for(int j = 0; j < longsPerPage; j++) {
|
||||
data[j] = j;
|
||||
}
|
||||
rawPageSetData(xid, 0, p);
|
||||
} else if(LSNMODE == mode) {
|
||||
} else if(LSNMODE == mode) {
|
||||
long * data = (long*) rawPageGetData(xid, p);
|
||||
memcpy(buf, data, PAGE_SIZE);
|
||||
for(int j = 0; j < longsPerPage; j++) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/page/raw.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <stasis/doubleLinkedList.h>
|
||||
|
||||
#include <stasis/pageHandle.h>
|
||||
#include <stasis/dirtyPageTable.h>
|
||||
#include <stasis/transactional.h>
|
||||
|
||||
#include <stasis/replacementPolicy.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <stasis/redblack.h>
|
||||
#include <stasis/common.h>
|
||||
#include <stasis/flags.h>
|
||||
#include <stasis/dirtyPageTable.h>
|
||||
#include <stasis/page.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/graph.h>
|
||||
#include <stasis/page.h>
|
||||
#include <stasis/crc32.h>
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include <stasis/common.h>
|
||||
#include <stasis/flags.h>
|
||||
|
||||
#include <stasis/latches.h>
|
||||
#include <stasis/logger/filePool.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <assert.h>
|
||||
/**
|
||||
@see stasis_log_safe_writes_state for more documentation;
|
||||
identically named fields serve analagous purposes.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stasis/transactional.h>
|
||||
#include <stasis/logger/reorderingHandle.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ terms specified in this license.
|
|||
|
||||
#include <config.h>
|
||||
#include <stasis/common.h>
|
||||
#include <stasis/flags.h>
|
||||
|
||||
#include <stasis/latches.h>
|
||||
#include <stasis/crc32.h>
|
||||
|
|
|
@ -93,6 +93,12 @@ typedef struct {
|
|||
int64_t type;
|
||||
} alloc_arg;
|
||||
|
||||
struct stasis_alloc_t {
|
||||
pthread_mutex_t mut;
|
||||
pageid_t lastFreepage;
|
||||
stasis_allocation_policy_t * allocPolicy;
|
||||
};
|
||||
|
||||
static int op_alloc(const LogEntry* e, Page* p) {
|
||||
assert(e->update.arg_size >= sizeof(alloc_arg));
|
||||
|
||||
|
@ -162,8 +168,6 @@ static int op_realloc(const LogEntry* e, Page* p) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static pthread_mutex_t talloc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
stasis_operation_impl stasis_op_impl_alloc() {
|
||||
stasis_operation_impl o = {
|
||||
OPERATION_ALLOC,
|
||||
|
@ -199,21 +203,24 @@ stasis_operation_impl stasis_op_impl_realloc() {
|
|||
return o;
|
||||
}
|
||||
|
||||
static pageid_t lastFreepage;
|
||||
static stasis_allocation_policy_t * allocPolicy;
|
||||
static void stasis_alloc_register_old_regions();
|
||||
void TallocInit() {
|
||||
lastFreepage = PAGEID_T_MAX;
|
||||
allocPolicy = stasis_allocation_policy_init();
|
||||
stasis_alloc_t* TallocInit() {
|
||||
stasis_alloc_t * alloc = malloc(sizeof(*alloc));
|
||||
alloc->lastFreepage = PAGEID_T_MAX;
|
||||
alloc->allocPolicy = stasis_allocation_policy_init();
|
||||
pthread_mutex_init(&alloc->mut, 0);
|
||||
return alloc;
|
||||
}
|
||||
void TallocPostInit() {
|
||||
stasis_alloc_register_old_regions();
|
||||
void TallocPostInit(stasis_alloc_t * alloc) {
|
||||
stasis_alloc_register_old_regions(alloc);
|
||||
}
|
||||
void TallocDeinit() {
|
||||
stasis_allocation_policy_deinit(allocPolicy);
|
||||
void TallocDeinit(stasis_alloc_t * alloc) {
|
||||
stasis_allocation_policy_deinit(alloc->allocPolicy);
|
||||
pthread_mutex_destroy(&alloc->mut);
|
||||
free(alloc);
|
||||
}
|
||||
|
||||
static void stasis_alloc_register_old_regions() {
|
||||
static void stasis_alloc_register_old_regions(stasis_alloc_t* alloc) {
|
||||
pageid_t boundary = REGION_FIRST_TAG;
|
||||
boundary_tag t;
|
||||
DEBUG("registering old regions\n");
|
||||
|
@ -226,7 +233,7 @@ static void stasis_alloc_register_old_regions() {
|
|||
Page * p = loadPage(-1, boundary + i);
|
||||
readlock(p->rwlatch,0);
|
||||
if(p->pageType == SLOTTED_PAGE) {
|
||||
stasis_allocation_policy_register_new_page(allocPolicy, p->id, stasis_record_freespace(-1, p));
|
||||
stasis_allocation_policy_register_new_page(alloc->allocPolicy, p->id, stasis_record_freespace(-1, p));
|
||||
DEBUG("registered page %lld\n", boundary+i);
|
||||
} else {
|
||||
abort();
|
||||
|
@ -239,7 +246,7 @@ static void stasis_alloc_register_old_regions() {
|
|||
}
|
||||
}
|
||||
|
||||
static void stasis_alloc_reserve_new_region(int xid) {
|
||||
static void stasis_alloc_reserve_new_region(stasis_alloc_t* alloc, int xid) {
|
||||
void* nta = TbeginNestedTopAction(xid, OPERATION_NOOP, 0,0);
|
||||
|
||||
pageid_t firstPage = TregionAlloc(xid, TALLOC_REGION_SIZE, STORAGE_MANAGER_TALLOC);
|
||||
|
@ -254,13 +261,14 @@ static void stasis_alloc_reserve_new_region(int xid) {
|
|||
unlock(p->rwlatch);
|
||||
releasePage(p);
|
||||
}
|
||||
stasis_allocation_policy_register_new_page(allocPolicy, firstPage + i, initialFreespace);
|
||||
stasis_allocation_policy_register_new_page(alloc->allocPolicy, firstPage + i, initialFreespace);
|
||||
}
|
||||
|
||||
TendNestedTopAction(xid, nta);
|
||||
}
|
||||
|
||||
compensated_function recordid Talloc(int xid, unsigned long size) {
|
||||
recordid Talloc(int xid, unsigned long size) {
|
||||
stasis_alloc_t* alloc = stasis_runtime_alloc_state();
|
||||
short type;
|
||||
if(size >= BLOB_THRESHOLD_SIZE) {
|
||||
type = BLOB_SLOT;
|
||||
|
@ -271,88 +279,87 @@ compensated_function recordid Talloc(int xid, unsigned long size) {
|
|||
|
||||
recordid rid;
|
||||
|
||||
begin_action_ret(pthread_mutex_unlock, &talloc_mutex, NULLRID) {
|
||||
pthread_mutex_lock(&talloc_mutex);
|
||||
pthread_mutex_lock(&alloc->mut);
|
||||
|
||||
pageid_t pageid =
|
||||
stasis_allocation_policy_pick_suitable_page(allocPolicy, xid,
|
||||
pageid_t pageid =
|
||||
stasis_allocation_policy_pick_suitable_page(alloc->allocPolicy, xid,
|
||||
stasis_record_type_to_size(type));
|
||||
|
||||
if(pageid == INVALID_PAGE) {
|
||||
stasis_alloc_reserve_new_region(xid);
|
||||
pageid = stasis_allocation_policy_pick_suitable_page(allocPolicy, xid,
|
||||
if(pageid == INVALID_PAGE) {
|
||||
stasis_alloc_reserve_new_region(alloc, xid);
|
||||
pageid = stasis_allocation_policy_pick_suitable_page(alloc->allocPolicy, xid,
|
||||
stasis_record_type_to_size(type));
|
||||
}
|
||||
lastFreepage = pageid;
|
||||
}
|
||||
alloc->lastFreepage = pageid;
|
||||
|
||||
Page * p = loadPage(xid, lastFreepage);
|
||||
Page * p = loadPage(xid, alloc->lastFreepage);
|
||||
|
||||
writelock(p->rwlatch, 0);
|
||||
while(stasis_record_freespace(xid, p) < stasis_record_type_to_size(type)) {
|
||||
stasis_record_compact(p);
|
||||
int newFreespace = stasis_record_freespace(xid, p);
|
||||
|
||||
if(newFreespace >= stasis_record_type_to_size(type)) {
|
||||
break;
|
||||
}
|
||||
|
||||
unlock(p->rwlatch);
|
||||
stasis_allocation_policy_update_freespace(allocPolicy, pageid, newFreespace);
|
||||
releasePage(p);
|
||||
|
||||
pageid = stasis_allocation_policy_pick_suitable_page(allocPolicy, xid,
|
||||
stasis_record_type_to_size(type));
|
||||
|
||||
if(pageid == INVALID_PAGE) {
|
||||
stasis_alloc_reserve_new_region(xid);
|
||||
pageid = stasis_allocation_policy_pick_suitable_page(allocPolicy, xid,
|
||||
stasis_record_type_to_size(type));
|
||||
}
|
||||
|
||||
lastFreepage = pageid;
|
||||
|
||||
p = loadPage(xid, lastFreepage);
|
||||
writelock(p->rwlatch, 0);
|
||||
}
|
||||
|
||||
rid = stasis_record_alloc_begin(xid, p, type);
|
||||
|
||||
assert(rid.size != INVALID_SLOT);
|
||||
|
||||
stasis_record_alloc_done(xid, p, rid);
|
||||
writelock(p->rwlatch, 0);
|
||||
while(stasis_record_freespace(xid, p) < stasis_record_type_to_size(type)) {
|
||||
stasis_record_compact(p);
|
||||
int newFreespace = stasis_record_freespace(xid, p);
|
||||
stasis_allocation_policy_alloced_from_page(allocPolicy, xid, pageid);
|
||||
stasis_allocation_policy_update_freespace(allocPolicy, pageid, newFreespace);
|
||||
unlock(p->rwlatch);
|
||||
|
||||
alloc_arg a = { rid.slot, type };
|
||||
|
||||
Tupdate(xid, rid.page, &a, sizeof(a), OPERATION_ALLOC);
|
||||
|
||||
if(type == BLOB_SLOT) {
|
||||
rid.size = size;
|
||||
stasis_blob_alloc(xid, rid);
|
||||
if(newFreespace >= stasis_record_type_to_size(type)) {
|
||||
break;
|
||||
}
|
||||
|
||||
unlock(p->rwlatch);
|
||||
stasis_allocation_policy_update_freespace(alloc->allocPolicy, pageid, newFreespace);
|
||||
releasePage(p);
|
||||
} compensate_ret(NULLRID);
|
||||
return rid;
|
||||
|
||||
pageid = stasis_allocation_policy_pick_suitable_page(alloc->allocPolicy, xid,
|
||||
stasis_record_type_to_size(type));
|
||||
|
||||
if(pageid == INVALID_PAGE) {
|
||||
stasis_alloc_reserve_new_region(alloc, xid);
|
||||
pageid = stasis_allocation_policy_pick_suitable_page(alloc->allocPolicy, xid,
|
||||
stasis_record_type_to_size(type));
|
||||
}
|
||||
|
||||
alloc->lastFreepage = pageid;
|
||||
|
||||
p = loadPage(xid, alloc->lastFreepage);
|
||||
writelock(p->rwlatch, 0);
|
||||
}
|
||||
|
||||
rid = stasis_record_alloc_begin(xid, p, type);
|
||||
|
||||
assert(rid.size != INVALID_SLOT);
|
||||
|
||||
stasis_record_alloc_done(xid, p, rid);
|
||||
int newFreespace = stasis_record_freespace(xid, p);
|
||||
stasis_allocation_policy_alloced_from_page(alloc->allocPolicy, xid, pageid);
|
||||
stasis_allocation_policy_update_freespace(alloc->allocPolicy, pageid, newFreespace);
|
||||
unlock(p->rwlatch);
|
||||
|
||||
alloc_arg a = { rid.slot, type };
|
||||
|
||||
Tupdate(xid, rid.page, &a, sizeof(a), OPERATION_ALLOC);
|
||||
|
||||
if(type == BLOB_SLOT) {
|
||||
rid.size = size;
|
||||
stasis_blob_alloc(xid, rid);
|
||||
}
|
||||
|
||||
releasePage(p);
|
||||
pthread_mutex_unlock(&alloc->mut);
|
||||
|
||||
return rid; // TODO return NULLRID on error
|
||||
}
|
||||
|
||||
void stasis_alloc_aborted(int xid) {
|
||||
begin_action(pthread_mutex_unlock, &talloc_mutex) {
|
||||
pthread_mutex_lock(&talloc_mutex);
|
||||
stasis_allocation_policy_transaction_completed(allocPolicy, xid);
|
||||
} compensate;
|
||||
void stasis_alloc_aborted(stasis_alloc_t* alloc, int xid) {
|
||||
pthread_mutex_lock(&alloc->mut);
|
||||
stasis_allocation_policy_transaction_completed(alloc->allocPolicy, xid);
|
||||
pthread_mutex_unlock(&alloc->mut);
|
||||
}
|
||||
void stasis_alloc_committed(int xid) {
|
||||
begin_action(pthread_mutex_unlock, &talloc_mutex) {
|
||||
pthread_mutex_lock(&talloc_mutex);
|
||||
stasis_allocation_policy_transaction_completed(allocPolicy, xid);
|
||||
} compensate;
|
||||
void stasis_alloc_committed(stasis_alloc_t* alloc, int xid) {
|
||||
pthread_mutex_lock(&alloc->mut);
|
||||
stasis_allocation_policy_transaction_completed(alloc->allocPolicy, xid);
|
||||
pthread_mutex_unlock(&alloc->mut);
|
||||
}
|
||||
|
||||
compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned long size) {
|
||||
recordid TallocFromPage(int xid, pageid_t page, unsigned long size) {
|
||||
stasis_alloc_t* alloc = stasis_runtime_alloc_state();
|
||||
short type;
|
||||
if(size >= BLOB_THRESHOLD_SIZE) {
|
||||
type = BLOB_SLOT;
|
||||
|
@ -361,9 +368,9 @@ compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned lo
|
|||
type = size;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&talloc_mutex);
|
||||
if(!stasis_allocation_policy_can_xid_alloc_from_page(allocPolicy, xid, page)) {
|
||||
pthread_mutex_unlock(&talloc_mutex);
|
||||
pthread_mutex_lock(&alloc->mut);
|
||||
if(!stasis_allocation_policy_can_xid_alloc_from_page(alloc->allocPolicy, xid, page)) {
|
||||
pthread_mutex_unlock(&alloc->mut);
|
||||
return NULLRID;
|
||||
}
|
||||
Page * p = loadPage(xid, page);
|
||||
|
@ -373,7 +380,7 @@ compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned lo
|
|||
|
||||
if(rid.size != INVALID_SLOT) {
|
||||
stasis_record_alloc_done(xid,p,rid);
|
||||
stasis_allocation_policy_alloced_from_page(allocPolicy, xid, page);
|
||||
stasis_allocation_policy_alloced_from_page(alloc->allocPolicy, xid, page);
|
||||
unlock(p->rwlatch);
|
||||
|
||||
alloc_arg a = { rid.slot, type };
|
||||
|
@ -384,29 +391,28 @@ compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned lo
|
|||
rid.size = size;
|
||||
stasis_blob_alloc(xid,rid);
|
||||
}
|
||||
|
||||
} else {
|
||||
unlock(p->rwlatch);
|
||||
}
|
||||
|
||||
|
||||
releasePage(p);
|
||||
pthread_mutex_unlock(&talloc_mutex);
|
||||
pthread_mutex_unlock(&alloc->mut);
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
||||
compensated_function void Tdealloc(int xid, recordid rid) {
|
||||
void Tdealloc(int xid, recordid rid) {
|
||||
stasis_alloc_t* alloc = stasis_runtime_alloc_state();
|
||||
|
||||
// @todo this needs to garbage collect empty storage regions.
|
||||
|
||||
pthread_mutex_lock(&talloc_mutex);
|
||||
pthread_mutex_lock(&alloc->mut);
|
||||
Page * p = loadPage(xid, rid.page);
|
||||
|
||||
readlock(p->rwlatch,0);
|
||||
|
||||
recordid newrid = stasis_record_dereference(xid, p, rid);
|
||||
stasis_allocation_policy_dealloced_from_page(allocPolicy, xid, newrid.page);
|
||||
stasis_allocation_policy_dealloced_from_page(alloc->allocPolicy, xid, newrid.page);
|
||||
|
||||
int64_t size = stasis_record_length_read(xid,p,rid);
|
||||
int64_t type = stasis_record_type_read(xid,p,rid);
|
||||
|
@ -431,7 +437,7 @@ compensated_function void Tdealloc(int xid, recordid rid) {
|
|||
// xacts.
|
||||
|
||||
// Also, there can be no reordering of allocations / deallocations ,
|
||||
// since we're holding talloc_mutex. However, we might reorder a Tset()
|
||||
// since we're holding alloc->mutex. However, we might reorder a Tset()
|
||||
// to and a Tdealloc() or Talloc() on the same page. If this happens,
|
||||
// it's an unsafe race in the application, and not technically our problem.
|
||||
|
||||
|
@ -445,7 +451,7 @@ compensated_function void Tdealloc(int xid, recordid rid) {
|
|||
|
||||
releasePage(p);
|
||||
|
||||
pthread_mutex_unlock(&talloc_mutex);
|
||||
pthread_mutex_unlock(&alloc->mut);
|
||||
|
||||
if(type==BLOB_SLOT) {
|
||||
stasis_blob_dealloc(xid,(blob_record_t*)(preimage+sizeof(alloc_arg)));
|
||||
|
@ -455,7 +461,7 @@ compensated_function void Tdealloc(int xid, recordid rid) {
|
|||
|
||||
}
|
||||
|
||||
compensated_function int TrecordType(int xid, recordid rid) {
|
||||
int TrecordType(int xid, recordid rid) {
|
||||
Page * p;
|
||||
p = loadPage(xid, rid.page);
|
||||
readlock(p->rwlatch,0);
|
||||
|
@ -466,7 +472,7 @@ compensated_function int TrecordType(int xid, recordid rid) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
compensated_function int TrecordSize(int xid, recordid rid) {
|
||||
int TrecordSize(int xid, recordid rid) {
|
||||
int ret;
|
||||
Page * p;
|
||||
p = loadPage(xid, rid.page);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stasis/operations/arrayList.h>
|
||||
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/transactional.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
#include<stasis/operations/bTree.h>
|
||||
|
||||
#include <stasis/bufferManager.h>
|
||||
|
||||
static stasis_comparator_t * btree_comparators;
|
||||
|
||||
static int stasis_btree_byte_array_comparator(const void * a, size_t alen, const void * b, size_t blen, void* arg) {
|
||||
|
|
|
@ -70,3 +70,6 @@ stasis_operation_impl stasis_op_impl_decrement() {
|
|||
};
|
||||
return o;
|
||||
}
|
||||
void Tdecrement(int xid, recordid rid) {
|
||||
Tupdate(xid,rid.page,&rid.slot,sizeof(rid.slot),OPERATION_DECREMENT);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ terms specified in this license.
|
|||
#include <stasis/operations.h>
|
||||
#include <stasis/page.h>
|
||||
|
||||
static int op_decrement(const LogEntry* e, Page* p) {
|
||||
static int op_increment(const LogEntry* e, Page* p) {
|
||||
int i;
|
||||
|
||||
assert(e->update.arg_size == sizeof(slotid_t));
|
||||
|
@ -67,7 +67,10 @@ stasis_operation_impl stasis_op_impl_increment() {
|
|||
UNKNOWN_TYPE_PAGE,
|
||||
OPERATION_INCREMENT,
|
||||
OPERATION_DECREMENT,
|
||||
op_decrement
|
||||
op_increment
|
||||
};
|
||||
return o;
|
||||
}
|
||||
void Tincrement(int xid, recordid rid) {
|
||||
Tupdate(xid,rid.page,&rid.slot,sizeof(rid.slot),OPERATION_INCREMENT);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <stasis/operations/lsmTree.h>
|
||||
#include <stasis/truncation.h>
|
||||
#include <stasis/constants.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/transactional.h>
|
||||
// XXX including fixed.h breaks page api encapsulation; we need a "last slot"
|
||||
// call.
|
||||
#include <stasis/page/fixed.h>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/operations.h>
|
||||
#include <stasis/page.h>
|
||||
#include <stasis/logger/reorderingHandle.h>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/operations.h>
|
||||
#include <stasis/hash.h>
|
||||
#include <stasis/latches.h>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stasis/page.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/logger/logEntry.h>
|
||||
#include <stasis/operations/pageOperations.h>
|
||||
#include <stasis/operations/regions.h>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stasis/page.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/operations.h>
|
||||
#include <stasis/logger/logger2.h>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* Author: sears
|
||||
*/
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ terms specified in this license.
|
|||
|
||||
#include <stasis/operations.h>
|
||||
#include <stasis/blobManager.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/page.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
|
|
@ -355,7 +355,7 @@ static void stasis_recovery_undo(stasis_log_t* log, int recovery) {
|
|||
freeLogHandle(lh);
|
||||
}
|
||||
}
|
||||
void stasis_recovery_initiate(stasis_log_t* log) {
|
||||
void stasis_recovery_initiate(stasis_log_t* log, stasis_alloc_t * alloc) {
|
||||
|
||||
transactionLSN = pblHtCreate();
|
||||
DEBUG("Analysis started\n");
|
||||
|
@ -363,8 +363,8 @@ void stasis_recovery_initiate(stasis_log_t* log) {
|
|||
DEBUG("Redo started\n");
|
||||
stasis_recovery_redo(log);
|
||||
DEBUG("Undo started\n");
|
||||
TallocPostInit();
|
||||
stasis_recovery_undo(log,1);
|
||||
TallocPostInit(alloc);
|
||||
DEBUG("Recovery complete.\n");
|
||||
|
||||
for(void * it = pblHtFirst(transactionLSN); it; it = pblHtNext(transactionLSN)) {
|
||||
|
|
|
@ -31,6 +31,8 @@ static int stasis_transaction_table_xid_count = 0;
|
|||
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;
|
||||
|
||||
/**
|
||||
This mutex protects stasis_transaction_table, numActiveXactions and
|
||||
xidCount.
|
||||
|
@ -53,6 +55,9 @@ void stasis_transaction_table_init() {
|
|||
void * stasis_runtime_dirty_page_table() {
|
||||
return stasis_dirty_page_table;
|
||||
}
|
||||
void * stasis_runtime_alloc_state() {
|
||||
return stasis_alloc;
|
||||
}
|
||||
|
||||
int Tinit() {
|
||||
pthread_mutex_init(&stasis_transaction_table_mutex, NULL);
|
||||
|
@ -94,7 +99,7 @@ int Tinit() {
|
|||
stasis_buffer_manager_open(bufferManagerType, page_handle);
|
||||
DEBUG("Buffer manager type = %d\n", bufferManagerType);
|
||||
pageOperationsInit();
|
||||
TallocInit();
|
||||
stasis_alloc = TallocInit();
|
||||
TnaiveHashInit();
|
||||
LinearHashNTAInit();
|
||||
BtreeInit();
|
||||
|
@ -104,7 +109,7 @@ int Tinit() {
|
|||
setupLockManagerCallbacksNil();
|
||||
//setupLockManagerCallbacksPage();
|
||||
|
||||
stasis_recovery_initiate(stasis_log_file);
|
||||
stasis_recovery_initiate(stasis_log_file, stasis_alloc);
|
||||
stasis_truncation = stasis_truncation_init(stasis_dirty_page_table, stasis_log_file);
|
||||
if(stasis_truncation_automatic) {
|
||||
// should this be before InitiateRecovery?
|
||||
|
@ -294,7 +299,7 @@ int Tcommit(int xid) {
|
|||
lsn = stasis_log_commit_transaction(stasis_log_file, &stasis_transaction_table[xid % MAX_TRANSACTIONS]);
|
||||
if(globalLockManager.commit) { globalLockManager.commit(xid); }
|
||||
|
||||
stasis_alloc_committed(xid);
|
||||
stasis_alloc_committed(stasis_alloc, xid);
|
||||
|
||||
pthread_mutex_lock(&stasis_transaction_table_mutex);
|
||||
|
||||
|
@ -328,7 +333,7 @@ int Tabort(int xid) {
|
|||
undoTrans(stasis_log_file, *t);
|
||||
if(globalLockManager.abort) { globalLockManager.abort(xid); }
|
||||
|
||||
stasis_alloc_aborted(xid);
|
||||
stasis_alloc_aborted(stasis_alloc, xid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -354,7 +359,7 @@ int Tdeinit() {
|
|||
assert( stasis_transaction_table_num_active == 0 );
|
||||
stasis_truncation_deinit(stasis_truncation);
|
||||
TnaiveHashDeinit();
|
||||
TallocDeinit();
|
||||
TallocDeinit(stasis_alloc);
|
||||
stasis_buffer_manager_close();
|
||||
DEBUG("Closing page file tdeinit\n");
|
||||
stasis_page_deinit();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stasis/truncation.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stdio.h>
|
||||
struct stasis_truncation_t {
|
||||
char initialized;
|
||||
|
|
|
@ -78,7 +78,7 @@ terms specified in this license.
|
|||
*/
|
||||
#ifndef __BUFFERMANAGER_H__
|
||||
#define __BUFFERMANAGER_H__
|
||||
|
||||
#include <stasis/common.h>
|
||||
BEGIN_C_DECLS
|
||||
#include <stasis/pageHandle.h>
|
||||
/**
|
||||
|
|
|
@ -62,6 +62,7 @@ typedef enum {
|
|||
} stasis_log_force_mode_t;
|
||||
|
||||
#include <stasis/logger/groupForce.h>
|
||||
#include <stasis/logger/logEntry.h>
|
||||
#include <stasis/constants.h>
|
||||
/**
|
||||
Contains the state needed by the logging layer to perform
|
||||
|
@ -74,9 +75,6 @@ typedef struct TransactionLog {
|
|||
pthread_mutex_t mut;
|
||||
} TransactionLog;
|
||||
|
||||
|
||||
#include <stasis/operations.h>
|
||||
|
||||
/**
|
||||
A callback function that allows logHandle's iterator to stop
|
||||
returning log entries depending on the context in which it was
|
||||
|
|
|
@ -65,11 +65,11 @@ terms specified in this license.
|
|||
#define __OPERATIONS_H__
|
||||
|
||||
#include <stasis/common.h>
|
||||
#include <stasis/transactional.h>
|
||||
//#include <stasis/transactional.h>
|
||||
#include <stasis/logger/logEntry.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/iterator.h>
|
||||
#include <stasis/arrayCollection.h>
|
||||
//#include <stasis/bufferManager.h>
|
||||
//#include <stasis/iterator.h>
|
||||
//#include <stasis/arrayCollection.h>
|
||||
BEGIN_C_DECLS
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
@file
|
||||
@file
|
||||
|
||||
Allocates and deallocates records.
|
||||
|
||||
|
@ -12,20 +12,24 @@
|
|||
#ifndef __ALLOC_H
|
||||
#define __ALLOC_H 1
|
||||
|
||||
#include <stasis/operations.h>
|
||||
|
||||
stasis_operation_impl stasis_op_impl_alloc();
|
||||
stasis_operation_impl stasis_op_impl_dealloc();
|
||||
stasis_operation_impl stasis_op_impl_realloc();
|
||||
|
||||
void stasis_alloc_aborted(int xid);
|
||||
void stasis_alloc_committed(int xid);
|
||||
typedef struct stasis_alloc_t stasis_alloc_t;
|
||||
|
||||
void TallocInit();
|
||||
void TallocPostInit();
|
||||
void TallocDeinit();
|
||||
/**
|
||||
Allocate a record.
|
||||
void stasis_alloc_aborted(stasis_alloc_t* alloc, int xid);
|
||||
void stasis_alloc_committed(stasis_alloc_t* alloc, int xid);
|
||||
|
||||
@param xid The transaction responsible for the allocation
|
||||
stasis_alloc_t* TallocInit();
|
||||
void TallocPostInit(stasis_alloc_t* alloc);
|
||||
void TallocDeinit(stasis_alloc_t* alloc);
|
||||
/**
|
||||
Allocate a record.
|
||||
|
||||
@param xid The transaction responsible for the allocation
|
||||
@param size The size of the new record to be allocated. Talloc will allocate a
|
||||
blob if the record will not easily fit on a page.
|
||||
|
||||
|
@ -35,19 +39,19 @@ compensated_function recordid Talloc(int xid, unsigned long size);
|
|||
|
||||
compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned long size);
|
||||
|
||||
/**
|
||||
Free a record.
|
||||
/**
|
||||
Free a record.
|
||||
*/
|
||||
compensated_function void Tdealloc(int xid, recordid rid);
|
||||
|
||||
/**
|
||||
Obtain the type of a record, as returned by getRecordType.
|
||||
Obtain the type of a record, as returned by getRecordType.
|
||||
|
||||
@param xid the transaction id.
|
||||
@param xid the transaction id.
|
||||
|
||||
@param rid the record of interest. The size field will be ignored,
|
||||
allowing this function to be used to probe for records in pages.
|
||||
|
||||
|
||||
@return UNINITIALIZED_RECORD, BLOB_RECORD, SLOTTED_RECORD, or FIXED_RECORD.
|
||||
|
||||
@see getRecordType
|
||||
|
@ -58,7 +62,7 @@ compensated_function int TrecordType(int xid, recordid rid);
|
|||
/**
|
||||
Obtain the length of the data stored in a record.
|
||||
|
||||
@param xid the transaction id.
|
||||
@param xid the transaction id.
|
||||
|
||||
@param rid the record of interest. The size field will be ignored,
|
||||
allowing this function to be used to probe for records in pages.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef BTREE_H_
|
||||
#define BTREE_H_
|
||||
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/operations.h>
|
||||
|
||||
typedef int(*stasis_comparator_t)(const void*, size_t, const void*, size_t, void*);
|
||||
typedef int16_t stasis_comparator_id_t;
|
||||
|
|
|
@ -46,8 +46,8 @@ terms specified in this license.
|
|||
* by one. The record should contain a 32-bit integer.
|
||||
*
|
||||
* @ingroup OPERATIONS
|
||||
*
|
||||
* @see increment.h
|
||||
*
|
||||
* @see increment.h
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
@ -57,9 +57,7 @@ terms specified in this license.
|
|||
|
||||
#include <stasis/constants.h>
|
||||
|
||||
static inline void Tdecrement(int xid, recordid rid) {
|
||||
Tupdate(xid,rid.page,&rid.slot,sizeof(rid.slot),OPERATION_DECREMENT);
|
||||
}
|
||||
void Tdecrement(int xid, recordid rid);
|
||||
stasis_operation_impl stasis_op_impl_decrement();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@ terms specified in this license.
|
|||
---*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @file
|
||||
*
|
||||
* sample logical operation that increments the contents of a record
|
||||
* by one. The record should contain a 32-bit integer.
|
||||
|
@ -55,7 +55,7 @@ terms specified in this license.
|
|||
* @ingroup OPERATIONS
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __INCREMENT_H__
|
||||
|
@ -63,9 +63,7 @@ terms specified in this license.
|
|||
|
||||
#include <stasis/constants.h>
|
||||
|
||||
static inline void Tincrement(int xid, recordid rid) {
|
||||
Tupdate(xid,rid.page,&rid.slot,sizeof(rid.slot),OPERATION_INCREMENT);
|
||||
}
|
||||
void Tincrement(int xid, recordid rid);
|
||||
stasis_operation_impl stasis_op_impl_increment();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define __LLADD_RECOVERY2_H
|
||||
|
||||
#include <stasis/logger/logger2.h>
|
||||
#include <stasis/operations/alloc.h>
|
||||
|
||||
void stasis_recovery_initiate(stasis_log_t* log);
|
||||
void stasis_recovery_initiate(stasis_log_t* log, stasis_alloc_t * alloc);
|
||||
/** This really doesn't belong in recovery.c, but there's so much code overlap, it doesn't make sense not to put it there. */
|
||||
void undoTrans(stasis_log_t*log, TransactionLog transaction);
|
||||
|
||||
|
|
|
@ -799,6 +799,8 @@ void * stasis_log(void);
|
|||
*/
|
||||
void * stasis_runtime_dirty_page_table();
|
||||
|
||||
void * stasis_runtime_alloc_state();
|
||||
|
||||
#include "operations.h"
|
||||
|
||||
END_C_DECLS
|
||||
|
|
|
@ -49,6 +49,7 @@ terms specified in this license.
|
|||
#include "../check_includes.h"
|
||||
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/bufferManager.h>
|
||||
#include <stasis/dirtyPageTable.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
@ -70,6 +71,7 @@ void * worker(void*arg) {
|
|||
pageid_t page = myrandom(NUM_PAGES);
|
||||
Page * p = loadPage(-1, page);
|
||||
writelock(p->rwlatch, 0);
|
||||
if(! (i % 100000)) { printf("."); fflush(stdout); }
|
||||
switch(myrandom(6)) {
|
||||
case 0: {
|
||||
stasis_dirty_page_table_set_dirty(dpt, p);
|
||||
|
|
|
@ -42,6 +42,7 @@ terms specified in this license.
|
|||
#include "../check_includes.h"
|
||||
|
||||
#include <stasis/transactional.h>
|
||||
#include <stasis/arrayCollection.h>
|
||||
#include <pbl/pbl.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <stasis/operations.h>
|
||||
#include <stasis/logger/logHandle.h>
|
||||
#include <stasis/logger/logger2.h>
|
||||
#include <stasis/logger/safeWrites.h>
|
||||
#include <stasis/flags.h>
|
||||
|
||||
static char * logEntryToString(const LogEntry * le) {
|
||||
char * ret = NULL;
|
||||
|
|
Loading…
Reference in a new issue