diff --git a/benchmarks/sequentialThroughput.c b/benchmarks/sequentialThroughput.c index 2ceac1e..34a3703 100644 --- a/benchmarks/sequentialThroughput.c +++ b/benchmarks/sequentialThroughput.c @@ -97,18 +97,11 @@ int main(int argc, char ** argv) { byte * arg = calloc(PAGE_SIZE, 1); stasis_log_t * l = stasis_log(); - LogEntry * e = allocUpdateLogEntry(l, prevLSN, -1, OPERATION_NOOP, - 0, PAGE_SIZE); - memcpy(stasis_log_entry_update_args_ptr(e), arg, PAGE_SIZE); for(long i = 0; i < page_count; i++) { - void * h; - LogEntry * e2 = l->reserve_entry(l, sizeofLogEntry(l, e), &h); - e->prevLSN = e->LSN; - e->LSN = -1; - memcpy(e2, e, sizeofLogEntry(l, e)); - l->write_entry_done(l, e2, h); + LogEntry * e = allocUpdateLogEntry(l, prevLSN, -1, OPERATION_NOOP, + 0, PAGE_SIZE); + l->write_entry_done(l, e); } - freeLogEntry(l, e); free(arg); } else { if(stake) { diff --git a/src/stasis/logger/inMemoryLog.c b/src/stasis/logger/inMemoryLog.c index b8f3c63..2f535c4 100644 --- a/src/stasis/logger/inMemoryLog.c +++ b/src/stasis/logger/inMemoryLog.c @@ -79,15 +79,15 @@ static int stasis_log_impl_in_memory_write_entry(stasis_log_t * log, LogEntry *e return 0; } -LogEntry* stasis_log_impl_in_memory_reserve_entry(struct stasis_log_t* log, size_t sz, void **handle) { +LogEntry* stasis_log_impl_in_memory_reserve_entry(struct stasis_log_t* log, size_t sz) { // XXX need to assign LSN here. return malloc(sz); } -int stasis_log_impl_in_memory_entry_done(struct stasis_log_t* log, LogEntry* e, void * handle) { - int ret = stasis_log_impl_in_memory_write_entry(log, e); +int stasis_log_impl_in_memory_entry_done(struct stasis_log_t* log, LogEntry* e) { +// int ret = stasis_log_impl_in_memory_write_entry(log, e); free(e); - return ret; + return 0; } static lsn_t stasis_log_impl_in_memory_first_unstable_lsn(stasis_log_t* log, diff --git a/src/stasis/logger/logEntry.c b/src/stasis/logger/logEntry.c index 555818b..48eb9f4 100644 --- a/src/stasis/logger/logEntry.c +++ b/src/stasis/logger/logEntry.c @@ -119,10 +119,6 @@ LogEntry * allocCLRLogEntry(stasis_log_t* log, const LogEntry * old_e) { return (LogEntry*)ret; } -void freeLogEntry(stasis_log_t* log, const LogEntry* e) { - free((void*)e); -} - lsn_t sizeofLogEntry(stasis_log_t * log, const LogEntry * e) { switch (e->type) { diff --git a/src/stasis/logger/logger2.c b/src/stasis/logger/logger2.c index 189f085..898ed91 100644 --- a/src/stasis/logger/logger2.c +++ b/src/stasis/logger/logger2.c @@ -68,7 +68,7 @@ static lsn_t stasis_log_write_common(stasis_log_t* log, stasis_transaction_table ret = e->LSN; - freeLogEntry(log, e); + log->write_entry_done(log, e); return ret; } @@ -90,7 +90,7 @@ static lsn_t stasis_log_write_prepare(stasis_log_t* log, stasis_transaction_tabl ret = e->LSN; - freeLogEntry(log, e); + log->write_entry_done(log, e); return ret; @@ -125,7 +125,7 @@ lsn_t stasis_log_end_nta(stasis_log_t* log, stasis_transaction_table_entry_t * l if(l->prevLSN == INVALID_LSN) { l->recLSN = e->LSN; } lsn_t ret = l->prevLSN = e->LSN; // pthread_mutex_unlock(&l->mut); - freeLogEntry(log, e); + log->write_entry_done(log, e); return ret; } @@ -136,17 +136,17 @@ lsn_t stasis_log_write_clr(stasis_log_t* log, const LogEntry * old_e) { DEBUG("Log CLR %d, LSN: %ld (undoing: %ld, next to undo: %ld)\n", xid, e->LSN, LSN, prevLSN); lsn_t ret = e->LSN; - freeLogEntry(log, e); + log->write_entry_done(log, e); return ret; } lsn_t stasis_log_write_dummy_clr(stasis_log_t* log, int xid, lsn_t prevLSN) { // XXX waste of log bandwidth. - const LogEntry * e = allocUpdateLogEntry(log, prevLSN, xid, OPERATION_NOOP, + LogEntry * e = allocUpdateLogEntry(log, prevLSN, xid, OPERATION_NOOP, INVALID_PAGE, 0); lsn_t ret = stasis_log_write_clr(log, e); - freeLogEntry(log, e); + log->write_entry_done(log, e); return ret; } diff --git a/src/stasis/logger/safeWrites.c b/src/stasis/logger/safeWrites.c index 9a18eed..157647a 100644 --- a/src/stasis/logger/safeWrites.c +++ b/src/stasis/logger/safeWrites.c @@ -279,13 +279,13 @@ static inline lsn_t log_crc_next_lsn(stasis_log_t* log, lsn_t ret) { (unsigned int) le->prevLSN, crc, le->LSN); // The log wasn't successfully forced to this point; discard // everything after the last CRC. - freeLogEntry(log, le); + free(le); break; } } else { log_crc_update(log, le, &crc); } - freeLogEntry(log, le); + free(le); // we bypassed the api in order to get this log entry. readLogEntry() calls malloc. } return ret; } @@ -367,15 +367,15 @@ static int writeLogEntry_LogWriter(stasis_log_t* log, LogEntry * e) { return ret; } -LogEntry* reserveEntry_LogWriter(struct stasis_log_t* log, size_t sz, void **handle) { +LogEntry* reserveEntry_LogWriter(struct stasis_log_t* log, size_t sz) { // XXX need to assign LSN here return malloc(sz); } -int entryDone_LogWriter(struct stasis_log_t* log, LogEntry* e, void * handle) { - int ret = writeLogEntry_LogWriter(log, e); +int entryDone_LogWriter(struct stasis_log_t* log, LogEntry* e) { +// int ret = writeLogEntry_LogWriter(log, e); free(e); - return ret; + return 0; } static lsn_t sizeofInternalLogEntry_LogWriter(stasis_log_t * log, diff --git a/src/stasis/transactional2.c b/src/stasis/transactional2.c index b6f7a2f..84e14b2 100644 --- a/src/stasis/transactional2.c +++ b/src/stasis/transactional2.c @@ -160,7 +160,7 @@ compensated_function void Tupdate(int xid, pageid_t page, assert(xact->prevLSN == e->LSN); DEBUG("Tupdate() e->LSN: %ld\n", e->LSN); stasis_operation_do(e, p); - freeLogEntry(stasis_log_file, e); + stasis_log_file->write_entry_done(stasis_log_file, e); if(p) unlock(p->rwlatch); if(p) releasePage(p); @@ -193,7 +193,7 @@ void TreorderableUpdate(int xid, void * hp, pageid_t page, unlock(p->rwlatch); pthread_mutex_unlock(&h->mut); // page will be released by the log handle... - freeLogEntry(stasis_log_file, e); + stasis_log_file->write_entry_done(stasis_log_file, e); } lsn_t TwritebackUpdate(int xid, pageid_t page, const void *dat, size_t datlen, int op) { @@ -206,7 +206,7 @@ lsn_t TwritebackUpdate(int xid, pageid_t page, if(l->prevLSN == -1) { l->recLSN = e->LSN; } l->prevLSN = e->LSN; - freeLogEntry(stasis_log_file, e); + stasis_log_file->write_entry_done(stasis_log_file, e); return l->prevLSN; } /** DANGER: you need to set the LSN's on the pages that you want to write back, diff --git a/stasis/logger/logEntry.h b/stasis/logger/logEntry.h index 0719c4f..8c98b47 100644 --- a/stasis/logger/logEntry.h +++ b/stasis/logger/logEntry.h @@ -115,11 +115,7 @@ LogEntry * allocUpdateLogEntry(stasis_log_t *log, lsn_t prevLSN, int xid, */ LogEntry * allocCLRLogEntry(stasis_log_t *log, const LogEntry * e); /** - @param e a log entry returned from one of the alloc???LogEntry functions. - */ -void freeLogEntry(stasis_log_t *log, const LogEntry * e); -/** - @param lh The log handle the entry will be stored in. (Needed because some log entries are of type INTERNALLOG) May be NULL if e is not of type INTERNALLOG. + @param log The log the entry will be stored in. (Needed because some log entries are of type INTERNALLOG) May be NULL if e is not of type INTERNALLOG. @param e A log entry of any type. @return the length, in bytes, of e. */ diff --git a/stasis/logger/logger2.h b/stasis/logger/logger2.h index 935c26d..9f1c8cc 100644 --- a/stasis/logger/logger2.h +++ b/stasis/logger/logger2.h @@ -121,9 +121,9 @@ struct stasis_log_t { */ int (*write_entry)(struct stasis_log_t* log, LogEntry * e); - LogEntry* (*reserve_entry)(struct stasis_log_t* log, size_t sz, void **handle); + LogEntry* (*reserve_entry)(struct stasis_log_t* log, size_t sz); - int (*write_entry_done)(struct stasis_log_t* log, LogEntry* e, void * handle); + int (*write_entry_done)(struct stasis_log_t* log, LogEntry* e); /** Read a log entry, given its LSN. diff --git a/test/stasis/check_logEntry.c b/test/stasis/check_logEntry.c index e163149..7c1a692 100644 --- a/test/stasis/check_logEntry.c +++ b/test/stasis/check_logEntry.c @@ -51,13 +51,13 @@ START_TEST(rawLogEntryAlloc) { Tinit(); stasis_log_t *l = stasis_log(); - LogEntry * log = allocCommonLogEntry(log, 200, 1, XABORT); + LogEntry * log = allocCommonLogEntry(l, 200, 1, XABORT); assert(log->LSN == -1); assert(log->prevLSN == 200); assert(log->xid == 1); assert(log->type == XABORT); assert(sizeofLogEntry(0, log) == sizeof(struct __raw_log_entry)); - freeLogEntry(l, log); + l->write_entry_done(l, log); Tdeinit(); } END_TEST diff --git a/test/stasis/check_logWriter.c b/test/stasis/check_logWriter.c index 8ef8545..359fb59 100644 --- a/test/stasis/check_logWriter.c +++ b/test/stasis/check_logWriter.c @@ -100,7 +100,7 @@ static stasis_log_t * setup_log() { fail_unless(sizeofLogEntry(0, e) == sizeofLogEntry(0, f), "Log entry changed size!!"); fail_unless(0 == memcmp(e,f,sizeofLogEntry(0, e)), "Log entries did not agree!!"); - freeLogEntry(stasis_log_file, e); + stasis_log_file->write_entry_done(stasis_log_file, e); stasis_log_file->read_entry_done(stasis_log_file, f); e = allocUpdateLogEntry(stasis_log_file, prevLSN, xid, 1, rid.page, args_size); @@ -115,8 +115,8 @@ static stasis_log_t * setup_log() { assert (g->type == CLRLOG); prevLSN = g->LSN; - freeLogEntry (stasis_log_file, e); - freeLogEntry (stasis_log_file, g); + stasis_log_file->write_entry_done(stasis_log_file, e); + stasis_log_file->write_entry_done(stasis_log_file, g); } return stasis_log_file; } @@ -385,7 +385,7 @@ static void* worker_thread(void * arg) { /* Try to interleave requests as much as possible */ sched_yield(); - freeLogEntry(stasis_log_file, le); + stasis_log_file->write_entry_done(stasis_log_file, le); } @@ -550,8 +550,8 @@ void reopenLogWorkload(int truncating) { assert(i == (ENTRY_COUNT * 2)); for(int i = 0; i < ENTRY_COUNT; i++) { - freeLogEntry(stasis_log_file, entries[i]); - freeLogEntry(stasis_log_file, entries2[i]); + stasis_log_file->write_entry_done(stasis_log_file, entries[i]); + stasis_log_file->write_entry_done(stasis_log_file, entries2[i]); } stasis_truncation_automatic = 1; diff --git a/test/stasis/check_multiplexer.c b/test/stasis/check_multiplexer.c index 408060a..4af9077 100644 --- a/test/stasis/check_multiplexer.c +++ b/test/stasis/check_multiplexer.c @@ -177,6 +177,8 @@ START_TEST(multiplexTest) { array = (lsn_t*)calloc(NUM_INSERTS, sizeof(lsn_t)); + stasis_log_t * log = stasis_log(); + for(i = 0; i < NUM_INSERTS; i++) { (*(lsn_t*)(arg+1)) = i; @@ -186,8 +188,7 @@ START_TEST(multiplexTest) { ThashInsert(xid, hash, (byte*)&i, sizeof(lsn_t), (byte*)e, sizeofLogEntry(0, e)); - - freeLogEntry(stasis_log(), e); + log->write_entry_done(log, e); }