removed freeLogEntry
This commit is contained in:
parent
8999f1acd4
commit
d71e248291
11 changed files with 36 additions and 50 deletions
|
@ -97,18 +97,11 @@ int main(int argc, char ** argv) {
|
||||||
byte * arg = calloc(PAGE_SIZE, 1);
|
byte * arg = calloc(PAGE_SIZE, 1);
|
||||||
stasis_log_t * l = stasis_log();
|
stasis_log_t * l = stasis_log();
|
||||||
|
|
||||||
|
for(long i = 0; i < page_count; i++) {
|
||||||
LogEntry * e = allocUpdateLogEntry(l, prevLSN, -1, OPERATION_NOOP,
|
LogEntry * e = allocUpdateLogEntry(l, prevLSN, -1, OPERATION_NOOP,
|
||||||
0, PAGE_SIZE);
|
0, PAGE_SIZE);
|
||||||
memcpy(stasis_log_entry_update_args_ptr(e), arg, PAGE_SIZE);
|
l->write_entry_done(l, e);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
freeLogEntry(l, e);
|
|
||||||
free(arg);
|
free(arg);
|
||||||
} else {
|
} else {
|
||||||
if(stake) {
|
if(stake) {
|
||||||
|
|
|
@ -79,15 +79,15 @@ static int stasis_log_impl_in_memory_write_entry(stasis_log_t * log, LogEntry *e
|
||||||
return 0;
|
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.
|
// XXX need to assign LSN here.
|
||||||
return malloc(sz);
|
return malloc(sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
int stasis_log_impl_in_memory_entry_done(struct stasis_log_t* log, LogEntry* e, void * handle) {
|
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);
|
// int ret = stasis_log_impl_in_memory_write_entry(log, e);
|
||||||
free(e);
|
free(e);
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static lsn_t stasis_log_impl_in_memory_first_unstable_lsn(stasis_log_t* log,
|
static lsn_t stasis_log_impl_in_memory_first_unstable_lsn(stasis_log_t* log,
|
||||||
|
|
|
@ -119,10 +119,6 @@ LogEntry * allocCLRLogEntry(stasis_log_t* log, const LogEntry * old_e) {
|
||||||
|
|
||||||
return (LogEntry*)ret;
|
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) {
|
lsn_t sizeofLogEntry(stasis_log_t * log, const LogEntry * e) {
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ static lsn_t stasis_log_write_common(stasis_log_t* log, stasis_transaction_table
|
||||||
|
|
||||||
ret = e->LSN;
|
ret = e->LSN;
|
||||||
|
|
||||||
freeLogEntry(log, e);
|
log->write_entry_done(log, e);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ static lsn_t stasis_log_write_prepare(stasis_log_t* log, stasis_transaction_tabl
|
||||||
|
|
||||||
ret = e->LSN;
|
ret = e->LSN;
|
||||||
|
|
||||||
freeLogEntry(log, e);
|
log->write_entry_done(log, e);
|
||||||
|
|
||||||
return ret;
|
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; }
|
if(l->prevLSN == INVALID_LSN) { l->recLSN = e->LSN; }
|
||||||
lsn_t ret = l->prevLSN = e->LSN;
|
lsn_t ret = l->prevLSN = e->LSN;
|
||||||
// pthread_mutex_unlock(&l->mut);
|
// pthread_mutex_unlock(&l->mut);
|
||||||
freeLogEntry(log, e);
|
log->write_entry_done(log, e);
|
||||||
return ret;
|
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,
|
DEBUG("Log CLR %d, LSN: %ld (undoing: %ld, next to undo: %ld)\n", xid,
|
||||||
e->LSN, LSN, prevLSN);
|
e->LSN, LSN, prevLSN);
|
||||||
lsn_t ret = e->LSN;
|
lsn_t ret = e->LSN;
|
||||||
freeLogEntry(log, e);
|
log->write_entry_done(log, e);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
lsn_t stasis_log_write_dummy_clr(stasis_log_t* log, int xid, lsn_t prevLSN) {
|
lsn_t stasis_log_write_dummy_clr(stasis_log_t* log, int xid, lsn_t prevLSN) {
|
||||||
// XXX waste of log bandwidth.
|
// 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);
|
INVALID_PAGE, 0);
|
||||||
lsn_t ret = stasis_log_write_clr(log, e);
|
lsn_t ret = stasis_log_write_clr(log, e);
|
||||||
freeLogEntry(log, e);
|
log->write_entry_done(log, e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
(unsigned int) le->prevLSN, crc, le->LSN);
|
||||||
// The log wasn't successfully forced to this point; discard
|
// The log wasn't successfully forced to this point; discard
|
||||||
// everything after the last CRC.
|
// everything after the last CRC.
|
||||||
freeLogEntry(log, le);
|
free(le);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_crc_update(log, le, &crc);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -367,15 +367,15 @@ static int writeLogEntry_LogWriter(stasis_log_t* log, LogEntry * e) {
|
||||||
return ret;
|
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
|
// XXX need to assign LSN here
|
||||||
return malloc(sz);
|
return malloc(sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
int entryDone_LogWriter(struct stasis_log_t* log, LogEntry* e, void * handle) {
|
int entryDone_LogWriter(struct stasis_log_t* log, LogEntry* e) {
|
||||||
int ret = writeLogEntry_LogWriter(log, e);
|
// int ret = writeLogEntry_LogWriter(log, e);
|
||||||
free(e);
|
free(e);
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static lsn_t sizeofInternalLogEntry_LogWriter(stasis_log_t * log,
|
static lsn_t sizeofInternalLogEntry_LogWriter(stasis_log_t * log,
|
||||||
|
|
|
@ -160,7 +160,7 @@ compensated_function void Tupdate(int xid, pageid_t page,
|
||||||
assert(xact->prevLSN == e->LSN);
|
assert(xact->prevLSN == e->LSN);
|
||||||
DEBUG("Tupdate() e->LSN: %ld\n", e->LSN);
|
DEBUG("Tupdate() e->LSN: %ld\n", e->LSN);
|
||||||
stasis_operation_do(e, p);
|
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) unlock(p->rwlatch);
|
||||||
if(p) releasePage(p);
|
if(p) releasePage(p);
|
||||||
|
@ -193,7 +193,7 @@ void TreorderableUpdate(int xid, void * hp, pageid_t page,
|
||||||
unlock(p->rwlatch);
|
unlock(p->rwlatch);
|
||||||
pthread_mutex_unlock(&h->mut);
|
pthread_mutex_unlock(&h->mut);
|
||||||
// page will be released by the log handle...
|
// 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,
|
lsn_t TwritebackUpdate(int xid, pageid_t page,
|
||||||
const void *dat, size_t datlen, int op) {
|
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; }
|
if(l->prevLSN == -1) { l->recLSN = e->LSN; }
|
||||||
l->prevLSN = e->LSN;
|
l->prevLSN = e->LSN;
|
||||||
|
|
||||||
freeLogEntry(stasis_log_file, e);
|
stasis_log_file->write_entry_done(stasis_log_file, e);
|
||||||
return l->prevLSN;
|
return l->prevLSN;
|
||||||
}
|
}
|
||||||
/** DANGER: you need to set the LSN's on the pages that you want to write back,
|
/** DANGER: you need to set the LSN's on the pages that you want to write back,
|
||||||
|
|
|
@ -115,11 +115,7 @@ LogEntry * allocUpdateLogEntry(stasis_log_t *log, lsn_t prevLSN, int xid,
|
||||||
*/
|
*/
|
||||||
LogEntry * allocCLRLogEntry(stasis_log_t *log, const LogEntry * e);
|
LogEntry * allocCLRLogEntry(stasis_log_t *log, const LogEntry * e);
|
||||||
/**
|
/**
|
||||||
@param e a log entry returned from one of the alloc???LogEntry functions.
|
@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.
|
||||||
*/
|
|
||||||
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 e A log entry of any type.
|
@param e A log entry of any type.
|
||||||
@return the length, in bytes, of e.
|
@return the length, in bytes, of e.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,9 +121,9 @@ struct stasis_log_t {
|
||||||
*/
|
*/
|
||||||
int (*write_entry)(struct stasis_log_t* log, LogEntry * e);
|
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.
|
Read a log entry, given its LSN.
|
||||||
|
|
|
@ -51,13 +51,13 @@ START_TEST(rawLogEntryAlloc)
|
||||||
{
|
{
|
||||||
Tinit();
|
Tinit();
|
||||||
stasis_log_t *l = stasis_log();
|
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->LSN == -1);
|
||||||
assert(log->prevLSN == 200);
|
assert(log->prevLSN == 200);
|
||||||
assert(log->xid == 1);
|
assert(log->xid == 1);
|
||||||
assert(log->type == XABORT);
|
assert(log->type == XABORT);
|
||||||
assert(sizeofLogEntry(0, log) == sizeof(struct __raw_log_entry));
|
assert(sizeofLogEntry(0, log) == sizeof(struct __raw_log_entry));
|
||||||
freeLogEntry(l, log);
|
l->write_entry_done(l, log);
|
||||||
Tdeinit();
|
Tdeinit();
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
|
@ -100,7 +100,7 @@ static stasis_log_t * setup_log() {
|
||||||
fail_unless(sizeofLogEntry(0, e) == sizeofLogEntry(0, f), "Log entry changed size!!");
|
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!!");
|
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);
|
stasis_log_file->read_entry_done(stasis_log_file, f);
|
||||||
|
|
||||||
e = allocUpdateLogEntry(stasis_log_file, prevLSN, xid, 1, rid.page, args_size);
|
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);
|
assert (g->type == CLRLOG);
|
||||||
prevLSN = g->LSN;
|
prevLSN = g->LSN;
|
||||||
|
|
||||||
freeLogEntry (stasis_log_file, e);
|
stasis_log_file->write_entry_done(stasis_log_file, e);
|
||||||
freeLogEntry (stasis_log_file, g);
|
stasis_log_file->write_entry_done(stasis_log_file, g);
|
||||||
}
|
}
|
||||||
return stasis_log_file;
|
return stasis_log_file;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ static void* worker_thread(void * arg) {
|
||||||
|
|
||||||
/* Try to interleave requests as much as possible */
|
/* Try to interleave requests as much as possible */
|
||||||
sched_yield();
|
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));
|
assert(i == (ENTRY_COUNT * 2));
|
||||||
|
|
||||||
for(int i = 0; i < ENTRY_COUNT; i++) {
|
for(int i = 0; i < ENTRY_COUNT; i++) {
|
||||||
freeLogEntry(stasis_log_file, entries[i]);
|
stasis_log_file->write_entry_done(stasis_log_file, entries[i]);
|
||||||
freeLogEntry(stasis_log_file, entries2[i]);
|
stasis_log_file->write_entry_done(stasis_log_file, entries2[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stasis_truncation_automatic = 1;
|
stasis_truncation_automatic = 1;
|
||||||
|
|
|
@ -177,6 +177,8 @@ START_TEST(multiplexTest) {
|
||||||
|
|
||||||
array = (lsn_t*)calloc(NUM_INSERTS, sizeof(lsn_t));
|
array = (lsn_t*)calloc(NUM_INSERTS, sizeof(lsn_t));
|
||||||
|
|
||||||
|
stasis_log_t * log = stasis_log();
|
||||||
|
|
||||||
for(i = 0; i < NUM_INSERTS; i++) {
|
for(i = 0; i < NUM_INSERTS; i++) {
|
||||||
|
|
||||||
(*(lsn_t*)(arg+1)) = 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));
|
ThashInsert(xid, hash, (byte*)&i, sizeof(lsn_t), (byte*)e, sizeofLogEntry(0, e));
|
||||||
|
|
||||||
|
log->write_entry_done(log, e);
|
||||||
freeLogEntry(stasis_log(), e);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue