diff --git a/newbrt/Makefile b/newbrt/Makefile index 4a563d3d54f..cae5015bf28 100644 --- a/newbrt/Makefile +++ b/newbrt/Makefile @@ -80,14 +80,14 @@ pma-test benchmark-test brt-test brt-serialize-test: LDFLAGS+=-lz BRT_INTERNAL_H_INCLUDES = brt-internal.h cachetable.h hashtable.h pma.h brt.h brttypes.h yerror.h ybt.h log.h ../include/db.h kv-pair.h memory.h crc.h key.o: brttypes.h key.h pma-test.o: $(BRT_INTERNAL_H_INCLUDES) pma-internal.h pma.h list.h mempool.h -pma-test: pma.o memory.o key.o ybt.o log.o mempool.o fingerprint.o brt-serialize.o hashtable.o primes.o +pma-test: pma.o memory.o key.o ybt.o log.o mempool.o fingerprint.o brt-serialize.o hashtable.o primes.o log_code.o pma.o: pma.h yerror.h pma-internal.h memory.h key.h ybt.h brttypes.h log.h ../include/db.h ybt.o: ybt.h brttypes.h ../include/db.h ybt-test: ybt-test.o ybt.o memory.o ybt-test.o: ybt.h ../include/db.h cachetable.o: cachetable.h hashfun.h -brt-test: ybt.o brt.o hashtable.o pma.o memory.o brt-serialize.o cachetable.o header-io.o ybt.o key.o primes.o log.o mempool.o brt-verify.o fingerprint.o -log.o: log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES) +brt-test: ybt.o brt.o hashtable.o pma.o memory.o brt-serialize.o cachetable.o header-io.o ybt.o key.o primes.o log.o mempool.o brt-verify.o fingerprint.o log_code.o +log.o: log_header.h log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES) brt-test.o brt.o: brt.h ../include/db.h hashtable.h pma.h brttypes.h cachetable.h brt-serialize-test.o: $(BRT_INTERNAL_H_INCLUDES) brt.o: $(BRT_INTERNAL_H_INCLUDES) @@ -105,7 +105,7 @@ log-test: log.o memory.o brt-verify.o: $(BRT_INTERNAL_H_INCLUDES) fingerprint.o: $(BRT_INTERNAL_H_INCLUDES) -brt-serialize-test: brt-serialize-test.o brt-serialize.o memory.o hashtable.o pma.o key.o ybt.o brt.o cachetable.o primes.o log.o mempool.o brt-verify.o fingerprint.o +brt-serialize-test: brt-serialize-test.o brt-serialize.o memory.o hashtable.o pma.o key.o ybt.o brt.o cachetable.o primes.o log.o mempool.o brt-verify.o fingerprint.o log_code.o @@ -115,7 +115,7 @@ cachetable-test: cachetable.o memory.o cachetable-test.o primes.o cachetable-test2.o: cachetable.h memory.h cachetable-test2: cachetable.o memory.o cachetable-test2.o primes.o -benchmark-test: benchmark-test.o ybt.o memory.o brt.o pma.o cachetable.o key.o hashtable.o brt-serialize.o primes.o log.o mempool.o brt-verify.o fingerprint.o +benchmark-test: benchmark-test.o ybt.o memory.o brt.o pma.o cachetable.o key.o hashtable.o brt-serialize.o primes.o log.o mempool.o brt-verify.o fingerprint.o log_code.o benchmark-test.o: brt.h ../include/db.h clean: diff --git a/newbrt/brt-internal.h b/newbrt/brt-internal.h index f585ef6c3d0..fdd7cc5a2c1 100644 --- a/newbrt/brt-internal.h +++ b/newbrt/brt-internal.h @@ -1,3 +1,5 @@ +#ifndef BRT_INTERNAL_H +#define BRT_INTERNAL_H #include "cachetable.h" #include "hashtable.h" #include "pma.h" @@ -210,3 +212,4 @@ static const BRTNODE null_brtnode=0; extern u_int32_t toku_calccrc32_kvpair (const void *key, int keylen, const void *val, int vallen); extern u_int32_t toku_calccrc32_cmd (int type, const void *key, int keylen, const void *val, int vallen); extern u_int32_t toku_calccrc32_cmdstruct (BRT_CMD *cmd); +#endif diff --git a/newbrt/log.c b/newbrt/log.c index b060c6b5f9a..966f91a4f66 100644 --- a/newbrt/log.c +++ b/newbrt/log.c @@ -15,6 +15,7 @@ #include "wbuf.h" #include "memory.h" #include "../src/ydb-internal.h" +#include "log_header.h" int tokulogger_find_next_unused_log_file(const char *directory, long long *result) { DIR *d=opendir(directory); @@ -203,26 +204,10 @@ int tokulogger_log_phys_add_or_delete_in_leaf (DB *db, TOKUTXN txn, DISKOFF disk return tokulogger_finish(txn->logger, &wbuf); } -int tokulogger_log_commit (TOKUTXN txn) { - struct wbuf wbuf; - const int buflen = (1 // log command - +8 // lsn - +8 // txnid - +8 // crc & len - ); - unsigned char buf[buflen]; - wbuf_init(&wbuf, buf, buflen); - wbuf_char(&wbuf, LT_COMMIT); - wbuf_LSN (&wbuf, txn->logger->lsn); - txn->logger->lsn.lsn++; - wbuf_TXNID(&wbuf, txn->txnid64); - int r = tokulogger_finish(txn->logger, &wbuf); - if (r!=0) return r; - int result; - if (txn->parent) result=0; - else result=tokulogger_fsync(txn->logger); +int tokulogger_commit (TOKUTXN txn) { + int r = toku_log_commit(txn, txn->txnid64); toku_free(txn); - return result; + return r; } int tokulogger_log_checkpoint (TOKULOGGER logger, LSN *lsn) { diff --git a/newbrt/log.h b/newbrt/log.h index 42871051eb9..a9664124df7 100644 --- a/newbrt/log.h +++ b/newbrt/log.h @@ -10,7 +10,7 @@ int tokulogger_log_checkpoint (TOKULOGGER, LSN*); int tokulogger_log_phys_add_or_delete_in_leaf (DB *db, TOKUTXN txn, DISKOFF diskoff, int is_add, const struct kv_pair *pair); -int tokulogger_log_commit (TOKUTXN txn); +int tokulogger_commit (TOKUTXN txn); int tokulogger_log_block_rename (TOKULOGGER /*logger*/, FILENUM /*fileid*/, DISKOFF /*olddiskoff*/, DISKOFF /*newdiskoff*/, DISKOFF /*parentdiskoff*/, int /*childnum*/); diff --git a/newbrt/logformat.c b/newbrt/logformat.c index ac1b5230610..702e8b882a3 100644 --- a/newbrt/logformat.c +++ b/newbrt/logformat.c @@ -112,7 +112,7 @@ void generate_log_struct (void) { void generate_log_writer (void) { DO_LOGTYPES(lt, ({ - fprintf2(cf, hf, "int toku_log_%s (TOKUTXN txn, LSN lsn", lt->name); + fprintf2(cf, hf, "int toku_log_%s (TOKUTXN txn", lt->name); DO_FIELDS(ft, lt, fprintf2(cf, hf, ", %s %s", ft->type, ft->name)); fprintf(hf, ");\n"); @@ -128,7 +128,8 @@ void generate_log_writer (void) { fprintf(cf, " if (buf==0) return errno;\n"); fprintf(cf, " wbuf_init(&wbuf, buf, buflen);\n"); fprintf(cf, " wbuf_char(&wbuf, '%c');\n", lt->command); - fprintf(cf, " wbuf_LSN(&wbuf, lsn);\n"); + fprintf(cf, " wbuf_LSN(&wbuf, txn->logger->lsn);\n"); + fprintf(cf, " txn->logger->lsn.lsn++;;\n"); DO_FIELDS(ft, lt, fprintf(cf, " wbuf_%s(&wbuf, %s);\n", ft->type, ft->name)); fprintf(cf, " int r= tokulogger_finish(txn->logger, &wbuf);\n"); diff --git a/src/Makefile b/src/Makefile index c3f18326692..6a0923c6ba3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -26,7 +26,7 @@ clean: rm -rf $(LIBNAME).$(LIBEXT) $(LIBNAME).a *.o ydb.o: ../include/db.h ../newbrt/cachetable.h ../newbrt/brt.h ../newbrt/log.c -DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/hashtable.o ../newbrt/header-io.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/pma.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o +DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/hashtable.o ../newbrt/header-io.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/pma.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o $(LIBNAME).$(LIBEXT): $(DBBINS) cc $(CPPFLAGS) $(DBBINS) $(SHARED) -o $@ $(CFLAGS) -lz diff --git a/src/ydb.c b/src/ydb.c index 45e0ac3d836..b7b7871a90b 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -444,7 +444,7 @@ int __toku_db_txn_commit(DB_TXN * txn, u_int32_t flags) { //notef("flags=%d\n", flags); if (!txn) return -1; - int r = tokulogger_log_commit(txn->i->tokutxn); + int r = tokulogger_commit(txn->i->tokutxn); if (r != 0) return r; if (txn->i)