Commit d7288dff authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make all external symbols in cachefile.o be start with toku_. Addresses #8

git-svn-id: file:///svn/tokudb@674 c7de825b-a66e-492c-adef-691d508d4ae1
parent f1b088cb
...@@ -37,7 +37,7 @@ void setup (void) { ...@@ -37,7 +37,7 @@ void setup (void) {
void shutdown (void) { void shutdown (void) {
int r; int r;
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
void long_long_to_array (unsigned char *a, unsigned long long l) { void long_long_to_array (unsigned char *a, unsigned long long l) {
int i; int i;
...@@ -53,7 +53,7 @@ void insert (long long v) { ...@@ -53,7 +53,7 @@ void insert (long long v) {
memset(vc, 0, sizeof vc); memset(vc, 0, sizeof vc);
long_long_to_array(vc, v); long_long_to_array(vc, v);
brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0, 0); brt_insert(t, fill_dbt(&kt, kc, keysize), fill_dbt(&vt, vc, valsize), 0, 0);
if (do_verify) cachetable_verify(ct); if (do_verify) toku_cachetable_verify(ct);
} }
void serial_insert_from (long long from) { void serial_insert_from (long long from) {
......
...@@ -34,7 +34,7 @@ static void test0 (void) { ...@@ -34,7 +34,7 @@ static void test0 (void) {
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
//printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -60,7 +60,7 @@ static void test1 (void) { ...@@ -60,7 +60,7 @@ static void test1 (void) {
assert(v.size==6); assert(v.size==6);
} }
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
printf("test1 ok\n"); printf("test1 ok\n");
} }
...@@ -98,7 +98,7 @@ static void test2 (int memcheck) { ...@@ -98,7 +98,7 @@ static void test2 (int memcheck) {
} }
printf("%s:%d inserted\n", __FILE__, __LINE__); printf("%s:%d inserted\n", __FILE__, __LINE__);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
printf("test2 ok\n"); printf("test2 ok\n");
} }
...@@ -125,7 +125,7 @@ static void test3 (int nodesize, int count, int memcheck) { ...@@ -125,7 +125,7 @@ static void test3 (int nodesize, int count, int memcheck) {
brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn); brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn);
} }
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
gettimeofday(&t1, 0); gettimeofday(&t1, 0);
{ {
...@@ -156,7 +156,7 @@ static void test4 (int nodesize, int count, int memcheck) { ...@@ -156,7 +156,7 @@ static void test4 (int nodesize, int count, int memcheck) {
brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn); brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn);
} }
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
gettimeofday(&t1, 0); gettimeofday(&t1, 0);
{ {
...@@ -208,7 +208,7 @@ static void test5 (void) { ...@@ -208,7 +208,7 @@ static void test5 (void) {
printf("\n"); printf("\n");
toku_free(values); toku_free(values);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -225,7 +225,7 @@ static void test_dump_empty_db (void) { ...@@ -225,7 +225,7 @@ static void test_dump_empty_db (void) {
assert(r==0); assert(r==0);
dump_brt(t); dump_brt(t);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -260,7 +260,7 @@ static void test_multiple_files_of_size (int size) { ...@@ -260,7 +260,7 @@ static void test_multiple_files_of_size (int size) {
r = close_brt(t0); assert(r==0); r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0); r = close_brt(t1); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
/* Now see if the data is all there. */ /* Now see if the data is all there. */
...@@ -288,7 +288,7 @@ static void test_multiple_files_of_size (int size) { ...@@ -288,7 +288,7 @@ static void test_multiple_files_of_size (int size) {
r = close_brt(t0); assert(r==0); r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0); r = close_brt(t1); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -316,7 +316,7 @@ static void test_named_db (void) { ...@@ -316,7 +316,7 @@ static void test_named_db (void) {
brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0);
r = close_brt(t0); assert(r==0); r = close_brt(t0); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
memory_check_all_free(); memory_check_all_free();
...@@ -331,7 +331,7 @@ static void test_named_db (void) { ...@@ -331,7 +331,7 @@ static void test_named_db (void) {
} }
r = close_brt(t0); assert(r==0); r = close_brt(t0); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -355,7 +355,7 @@ static void test_multiple_dbs (void) { ...@@ -355,7 +355,7 @@ static void test_multiple_dbs (void) {
r = close_brt(t0); assert(r==0); r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0); r = close_brt(t1); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
...@@ -383,7 +383,7 @@ static void test_multiple_dbs (void) { ...@@ -383,7 +383,7 @@ static void test_multiple_dbs (void) {
r = close_brt(t0); assert(r==0); r = close_brt(t0); assert(r==0);
r = close_brt(t1); assert(r==0); r = close_brt(t1); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
printf("ok\n"); printf("ok\n");
...@@ -416,7 +416,7 @@ static void test_multiple_dbs_many (void) { ...@@ -416,7 +416,7 @@ static void test_multiple_dbs_many (void) {
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
r = close_brt(trees[i]); assert(r==0); r = close_brt(trees[i]); assert(r==0);
} }
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -455,7 +455,7 @@ static void test_multiple_brts_one_db_one_file (void) { ...@@ -455,7 +455,7 @@ static void test_multiple_brts_one_db_one_file (void) {
for (i=0; i<MANYN; i++) { for (i=0; i<MANYN; i++) {
r=close_brt(trees[i]); assert(r==0); r=close_brt(trees[i]); assert(r==0);
} }
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
printf(" ok\n"); printf(" ok\n");
} }
...@@ -477,7 +477,7 @@ static void test_read_what_was_written (void) { ...@@ -477,7 +477,7 @@ static void test_read_what_was_written (void) {
r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<12, ct, null_txn, default_compare_fun); assert(r==0);
r = close_brt(brt); assert(r==0); r = close_brt(brt); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
...@@ -492,7 +492,7 @@ static void test_read_what_was_written (void) { ...@@ -492,7 +492,7 @@ static void test_read_what_was_written (void) {
} }
r = close_brt(brt); assert(r==0); r = close_brt(brt); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
...@@ -569,7 +569,7 @@ static void test_read_what_was_written (void) { ...@@ -569,7 +569,7 @@ static void test_read_what_was_written (void) {
r = close_brt(brt); assert(r==0); r = close_brt(brt); assert(r==0);
printf("%s:%d About to close %p\n", __FILE__, __LINE__, ct); printf("%s:%d About to close %p\n", __FILE__, __LINE__, ct);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
...@@ -598,7 +598,7 @@ static void test_read_what_was_written (void) { ...@@ -598,7 +598,7 @@ static void test_read_what_was_written (void) {
} }
r = close_brt(brt); assert(r==0); r = close_brt(brt); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
...@@ -637,7 +637,7 @@ void test_cursor_last_empty(void) { ...@@ -637,7 +637,7 @@ void test_cursor_last_empty(void) {
assert(r==DB_NOTFOUND); assert(r==DB_NOTFOUND);
r = close_brt(brt); r = close_brt(brt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
memory_check_all_free(); memory_check_all_free();
} }
...@@ -687,7 +687,7 @@ void test_cursor_next (void) { ...@@ -687,7 +687,7 @@ void test_cursor_next (void) {
r = close_brt(brt); r = close_brt(brt);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
//printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items(); //printf("%s:%d %d alloced\n", __FILE__, __LINE__, get_n_items_malloced()); print_malloced_items();
memory_check_all_free(); memory_check_all_free();
...@@ -766,9 +766,9 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -766,9 +766,9 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
} }
{ {
cachetable_verify(ct); toku_cachetable_verify(ct);
r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0); r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : default_compare_fun); assert(r==0);
cachetable_verify(ct); toku_cachetable_verify(ct);
for (i=0; i<N; i++) { for (i=0; i<N; i++) {
unsigned char a[4],b[4]; unsigned char a[4],b[4];
...@@ -783,7 +783,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -783,7 +783,7 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]); ((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]);
r = brt_insert(brt, &kbt, &vbt, &nonce_db, null_txn); r = brt_insert(brt, &kbt, &vbt, &nonce_db, null_txn);
assert(r==0); assert(r==0);
cachetable_verify(ct); toku_cachetable_verify(ct);
} }
r = brt_cursor(brt, &cursor); assert(r==0); r = brt_cursor(brt, &cursor); assert(r==0);
...@@ -804,12 +804,12 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) { ...@@ -804,12 +804,12 @@ static void test_wrongendian_compare (int wrong_p, unsigned int N) {
assert(prev<this); assert(prev<this);
prev=this; prev=this;
assert(this==(int)i); assert(this==(int)i);
cachetable_verify(ct); toku_cachetable_verify(ct);
} }
r = close_brt(brt); r = close_brt(brt);
} }
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
memory_check_all_free(); memory_check_all_free();
} }
...@@ -939,7 +939,7 @@ void test_brt_cursor_first(int n, DB *db) { ...@@ -939,7 +939,7 @@ void test_brt_cursor_first(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -981,7 +981,7 @@ void test_brt_cursor_last(int n, DB *db) { ...@@ -981,7 +981,7 @@ void test_brt_cursor_last(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1025,7 +1025,7 @@ void test_brt_cursor_first_last(int n, DB *db) { ...@@ -1025,7 +1025,7 @@ void test_brt_cursor_first_last(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
...@@ -1070,7 +1070,7 @@ void test_brt_cursor_rfirst(int n, DB *db) { ...@@ -1070,7 +1070,7 @@ void test_brt_cursor_rfirst(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1142,7 +1142,7 @@ void test_brt_cursor_walk(int n, DB *db) { ...@@ -1142,7 +1142,7 @@ void test_brt_cursor_walk(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1215,7 +1215,7 @@ void test_brt_cursor_rwalk(int n, DB *db) { ...@@ -1215,7 +1215,7 @@ void test_brt_cursor_rwalk(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1303,7 +1303,7 @@ void test_brt_cursor_rand(int n, DB *db) { ...@@ -1303,7 +1303,7 @@ void test_brt_cursor_rand(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1385,7 +1385,7 @@ void test_brt_cursor_split(int n, DB *db) { ...@@ -1385,7 +1385,7 @@ void test_brt_cursor_split(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1420,7 +1420,7 @@ void test_multiple_brt_cursors(int n, DB *db) { ...@@ -1420,7 +1420,7 @@ void test_multiple_brt_cursors(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1517,7 +1517,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) { ...@@ -1517,7 +1517,7 @@ void test_multiple_brt_cursor_walk(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1588,7 +1588,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) { ...@@ -1588,7 +1588,7 @@ void test_brt_cursor_set(int n, int cursor_op, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1655,7 +1655,7 @@ void test_brt_cursor_set_range(int n, DB *db) { ...@@ -1655,7 +1655,7 @@ void test_brt_cursor_set_range(int n, DB *db) {
r = close_brt(brt); r = close_brt(brt);
assert(r==0); assert(r==0);
r = cachetable_close(&ct); r = toku_cachetable_close(&ct);
assert(r==0); assert(r==0);
} }
...@@ -1717,7 +1717,7 @@ void test_brt_cursor_delete(int n, DB *db) { ...@@ -1717,7 +1717,7 @@ void test_brt_cursor_delete(int n, DB *db) {
error = close_brt(brt); error = close_brt(brt);
assert(error == 0); assert(error == 0);
error = cachetable_close(&ct); error = toku_cachetable_close(&ct);
assert(error == 0); assert(error == 0);
} }
...@@ -1821,7 +1821,7 @@ void test_brt_cursor_get_both(int n, DB *db) { ...@@ -1821,7 +1821,7 @@ void test_brt_cursor_get_both(int n, DB *db) {
error = close_brt(brt); error = close_brt(brt);
assert(error == 0); assert(error == 0);
error = cachetable_close(&ct); error = toku_cachetable_close(&ct);
assert(error == 0); assert(error == 0);
} }
...@@ -1904,7 +1904,7 @@ void test_large_kv(int bsize, int ksize, int vsize) { ...@@ -1904,7 +1904,7 @@ void test_large_kv(int bsize, int ksize, int vsize) {
toku_free(v); toku_free(v);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
/* /*
...@@ -1944,7 +1944,7 @@ void test_brt_delete_empty() { ...@@ -1944,7 +1944,7 @@ void test_brt_delete_empty() {
assert(r == 0); assert(r == 0);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
/* /*
...@@ -2010,7 +2010,7 @@ void test_brt_delete_present(int n) { ...@@ -2010,7 +2010,7 @@ void test_brt_delete_present(int n) {
assert(r == 0); assert(r == 0);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
void test_brt_delete_not_present(int n) { void test_brt_delete_not_present(int n) {
...@@ -2057,7 +2057,7 @@ void test_brt_delete_not_present(int n) { ...@@ -2057,7 +2057,7 @@ void test_brt_delete_not_present(int n) {
printf("brt_delete k=%d %d\n", k, r); printf("brt_delete k=%d %d\n", k, r);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
void test_brt_delete_cursor_first(int n) { void test_brt_delete_cursor_first(int n) {
...@@ -2143,7 +2143,7 @@ void test_brt_delete_cursor_first(int n) { ...@@ -2143,7 +2143,7 @@ void test_brt_delete_cursor_first(int n) {
assert(r == 0); assert(r == 0);
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
/* test for bug: insert cmd in a nonleaf node, delete removes the /* test for bug: insert cmd in a nonleaf node, delete removes the
...@@ -2193,7 +2193,7 @@ void test_insert_delete_lookup(int n) { ...@@ -2193,7 +2193,7 @@ void test_insert_delete_lookup(int n) {
} }
r = close_brt(t); assert(r==0); r = close_brt(t); assert(r==0);
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
void test_brt_delete() { void test_brt_delete() {
......
...@@ -58,8 +58,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve ...@@ -58,8 +58,8 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve
BRTNODE node; BRTNODE node;
void *node_v; void *node_v;
int r; int r;
if ((r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, if ((r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, (void*)(long)brt->h->nodesize))) brtnode_flush_callback, brtnode_fetch_callback, (void*)(long)brt->h->nodesize)))
return r; return r;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
node=node_v; node=node_v;
...@@ -116,7 +116,7 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve ...@@ -116,7 +116,7 @@ int verify_brtnode (BRT brt, DISKOFF off, bytevec lorange, ITEMLEN lolen, byteve
} }
} }
} }
if ((r = cachetable_unpin(brt->cf, off, 0, 0))) return r; if ((r = toku_cachetable_unpin(brt->cf, off, 0, 0))) return r;
return result; return result;
} }
......
...@@ -75,12 +75,12 @@ void fix_up_parent_pointers_of_children (BRT t, BRTNODE node) { ...@@ -75,12 +75,12 @@ void fix_up_parent_pointers_of_children (BRT t, BRTNODE node) {
assert(node->height>0); assert(node->height>0);
for (i=0; i<node->u.n.n_children; i++) { for (i=0; i<node->u.n.n_children; i++) {
void *v; void *v;
int r = cachetable_maybe_get_and_pin(t->cf, node->u.n.children[i], &v); int r = toku_cachetable_maybe_get_and_pin(t->cf, node->u.n.children[i], &v);
if (r==0) { if (r==0) {
BRTNODE child = v; BRTNODE child = v;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, v);
child->parent_brtnode = node; child->parent_brtnode = node;
r=cachetable_unpin(t->cf, node->u.n.children[i], child->dirty, brtnode_size(child)); r=toku_cachetable_unpin(t->cf, node->u.n.children[i], child->dirty, brtnode_size(child));
} }
} }
} }
...@@ -90,12 +90,12 @@ void fix_up_parent_pointers_of_children_now_that_parent_is_gone (CACHEFILE cf, B ...@@ -90,12 +90,12 @@ void fix_up_parent_pointers_of_children_now_that_parent_is_gone (CACHEFILE cf, B
if (node->height==0) return; if (node->height==0) return;
for (i=0; i<node->u.n.n_children; i++) { for (i=0; i<node->u.n.n_children; i++) {
void *v; void *v;
int r = cachetable_maybe_get_and_pin(cf, node->u.n.children[i], &v); int r = toku_cachetable_maybe_get_and_pin(cf, node->u.n.children[i], &v);
if (r==0) { if (r==0) {
BRTNODE child = v; BRTNODE child = v;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, v);
child->parent_brtnode = 0; child->parent_brtnode = 0;
r=cachetable_unpin(cf, node->u.n.children[i], child->dirty, brtnode_size(child)); r=toku_cachetable_unpin(cf, node->u.n.children[i], child->dirty, brtnode_size(child));
} }
} }
} }
...@@ -170,7 +170,7 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod ...@@ -170,7 +170,7 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod
// !!! Don't forget to free the old node (sometime after some future checkpoint. TODO!!!) // !!! Don't forget to free the old node (sometime after some future checkpoint. TODO!!!)
brtnode->thisnodename=newnodename; brtnode->thisnodename=newnodename;
parent->u.n.children[i] = newnodename; parent->u.n.children[i] = newnodename;
cachetable_rename(cachefile, nodename, newnodename); toku_cachetable_rename(cachefile, nodename, newnodename);
} }
#endif #endif
goto ok; goto ok;
...@@ -184,7 +184,7 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod ...@@ -184,7 +184,7 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod
} }
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]); //printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]);
if (write_me) { if (write_me) {
serialize_brtnode_to(cachefile_fd(cachefile), brtnode->thisnodename, brtnode->nodesize, brtnode); serialize_brtnode_to(toku_cachefile_fd(cachefile), brtnode->thisnodename, brtnode->nodesize, brtnode);
} }
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]); //printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]);
if (!keep_me) { if (!keep_me) {
...@@ -196,7 +196,7 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod ...@@ -196,7 +196,7 @@ void brtnode_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *brtnod
int brtnode_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **brtnode_pv, long *sizep, void*extraargs, LSN *written_lsn) { int brtnode_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **brtnode_pv, long *sizep, void*extraargs, LSN *written_lsn) {
BRT t =(BRT)extraargs; BRT t =(BRT)extraargs;
BRTNODE *result=(BRTNODE*)brtnode_pv; BRTNODE *result=(BRTNODE*)brtnode_pv;
int r = deserialize_brtnode_from(cachefile_fd(cachefile), nodename, result, t->flags, t->nodesize, int r = deserialize_brtnode_from(toku_cachefile_fd(cachefile), nodename, result, t->flags, t->nodesize,
t->compare_fun, t->dup_compare); t->compare_fun, t->dup_compare);
if (r == 0) if (r == 0)
*sizep = brtnode_size(*result); *sizep = brtnode_size(*result);
...@@ -211,7 +211,7 @@ void brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *head ...@@ -211,7 +211,7 @@ void brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *head
assert(nodename==0); assert(nodename==0);
assert(!h->dirty); // shouldn't be dirty once it is unpinned. assert(!h->dirty); // shouldn't be dirty once it is unpinned.
if (write_me) { if (write_me) {
serialize_brt_header_to(cachefile_fd(cachefile), h); serialize_brt_header_to(toku_cachefile_fd(cachefile), h);
} }
if (!keep_me) { if (!keep_me) {
if (h->n_named_roots>0) { if (h->n_named_roots>0) {
...@@ -229,7 +229,7 @@ void brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *head ...@@ -229,7 +229,7 @@ void brtheader_flush_callback (CACHEFILE cachefile, DISKOFF nodename, void *head
int brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **headerp_v, long *sizep __attribute__((unused)), void*extraargs __attribute__((__unused__)), LSN *written_lsn) { int brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **headerp_v, long *sizep __attribute__((unused)), void*extraargs __attribute__((__unused__)), LSN *written_lsn) {
struct brt_header **h = (struct brt_header **)headerp_v; struct brt_header **h = (struct brt_header **)headerp_v;
assert(nodename==0); assert(nodename==0);
int r = deserialize_brtheader_from(cachefile_fd(cachefile), nodename, h); int r = deserialize_brtheader_from(toku_cachefile_fd(cachefile), nodename, h);
written_lsn->lsn = 0; // !!! WRONG. This should be stored or kept redundantly or something. written_lsn->lsn = 0; // !!! WRONG. This should be stored or kept redundantly or something.
return r; return r;
} }
...@@ -237,7 +237,7 @@ int brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **head ...@@ -237,7 +237,7 @@ int brtheader_fetch_callback (CACHEFILE cachefile, DISKOFF nodename, void **head
int toku_read_and_pin_brt_header (CACHEFILE cf, struct brt_header **header) { int toku_read_and_pin_brt_header (CACHEFILE cf, struct brt_header **header) {
void *header_p; void *header_p;
//fprintf(stderr, "%s:%d read_and_pin_brt_header(...)\n", __FILE__, __LINE__); //fprintf(stderr, "%s:%d read_and_pin_brt_header(...)\n", __FILE__, __LINE__);
int r = cachetable_get_and_pin(cf, 0, &header_p, NULL, int r = toku_cachetable_get_and_pin(cf, 0, &header_p, NULL,
brtheader_flush_callback, brtheader_fetch_callback, 0); brtheader_flush_callback, brtheader_fetch_callback, 0);
if (r!=0) return r; if (r!=0) return r;
*header = header_p; *header = header_p;
...@@ -245,7 +245,7 @@ int toku_read_and_pin_brt_header (CACHEFILE cf, struct brt_header **header) { ...@@ -245,7 +245,7 @@ int toku_read_and_pin_brt_header (CACHEFILE cf, struct brt_header **header) {
} }
int toku_unpin_brt_header (BRT brt) { int toku_unpin_brt_header (BRT brt) {
int r = cachetable_unpin(brt->cf, 0, brt->h->dirty, 0); int r = toku_cachetable_unpin(brt->cf, 0, brt->h->dirty, 0);
brt->h->dirty=0; brt->h->dirty=0;
brt->h=0; brt->h=0;
return r; return r;
...@@ -343,7 +343,7 @@ static void create_new_brtnode (BRT t, BRTNODE *result, int height, BRTNODE pare ...@@ -343,7 +343,7 @@ static void create_new_brtnode (BRT t, BRTNODE *result, int height, BRTNODE pare
n->parent_brtnode = parent_brtnode; n->parent_brtnode = parent_brtnode;
// n->brt = t; // n->brt = t;
//printf("%s:%d putting %p (%lld) parent=%p\n", __FILE__, __LINE__, n, n->thisnodename, parent_brtnode); //printf("%s:%d putting %p (%lld) parent=%p\n", __FILE__, __LINE__, n, n->thisnodename, parent_brtnode);
r=cachetable_put(t->cf, n->thisnodename, n, brtnode_size(n), r=toku_cachetable_put(t->cf, n->thisnodename, n, brtnode_size(n),
brtnode_flush_callback, brtnode_fetch_callback, t); brtnode_flush_callback, brtnode_fetch_callback, t);
assert(r==0); assert(r==0);
} }
...@@ -370,7 +370,7 @@ void delete_node (BRT t, BRTNODE node) { ...@@ -370,7 +370,7 @@ void delete_node (BRT t, BRTNODE node) {
node->height=0; node->height=0;
node->u.l.buffer=0; /* It's a leaf now (height==0) so set the buffer to NULL. */ node->u.l.buffer=0; /* It's a leaf now (height==0) so set the buffer to NULL. */
} }
cachetable_remove(t->cf, node->thisnodename, 0); /* Don't write it back to disk. */ toku_cachetable_remove(t->cf, node->thisnodename, 0); /* Don't write it back to disk. */
} }
static int insert_to_hash_in_nonleaf (BRTNODE node, int childnum, DBT *k, DBT *v, int type) { static int insert_to_hash_in_nonleaf (BRTNODE node, int childnum, DBT *k, DBT *v, int type) {
...@@ -741,9 +741,9 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum, ...@@ -741,9 +741,9 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum,
verify_counts(childa); verify_counts(childa);
verify_counts(childb); verify_counts(childb);
r=cachetable_unpin(t->cf, childa->thisnodename, childa->dirty, brtnode_size(childa)); r=toku_cachetable_unpin(t->cf, childa->thisnodename, childa->dirty, brtnode_size(childa));
assert(r==0); assert(r==0);
r=cachetable_unpin(t->cf, childb->thisnodename, childb->dirty, brtnode_size(childb)); r=toku_cachetable_unpin(t->cf, childb->thisnodename, childb->dirty, brtnode_size(childb));
assert(r==0); assert(r==0);
if (node->u.n.n_children>TREE_FANOUT) { if (node->u.n.n_children>TREE_FANOUT) {
...@@ -781,7 +781,7 @@ static int push_some_brt_cmds_down (BRT t, BRTNODE node, int childnum, ...@@ -781,7 +781,7 @@ static int push_some_brt_cmds_down (BRT t, BRTNODE node, int childnum,
assert(node->height>0); assert(node->height>0);
DISKOFF targetchild = node->u.n.children[childnum]; DISKOFF targetchild = node->u.n.children[childnum];
assert(targetchild>=0 && targetchild<t->h->unused_memory); // This assertion could fail in a concurrent setting since another process might have bumped unused memory. assert(targetchild>=0 && targetchild<t->h->unused_memory); // This assertion could fail in a concurrent setting since another process might have bumped unused memory.
r = cachetable_get_and_pin(t->cf, targetchild, &childnode_v, NULL, r = toku_cachetable_get_and_pin(t->cf, targetchild, &childnode_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, t); brtnode_flush_callback, brtnode_fetch_callback, t);
if (r!=0) return r; if (r!=0) return r;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, childnode_v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, childnode_v);
...@@ -859,7 +859,7 @@ static int push_some_brt_cmds_down (BRT t, BRTNODE node, int childnum, ...@@ -859,7 +859,7 @@ static int push_some_brt_cmds_down (BRT t, BRTNODE node, int childnum,
if (debug) printf("%s:%d %*sdone push_some_brt_cmds_down, unpinning %lld\n", __FILE__, __LINE__, debug, "", targetchild); if (debug) printf("%s:%d %*sdone push_some_brt_cmds_down, unpinning %lld\n", __FILE__, __LINE__, debug, "", targetchild);
assert(serialize_brtnode_size(node)<=node->nodesize); assert(serialize_brtnode_size(node)<=node->nodesize);
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
r=cachetable_unpin(t->cf, targetchild, child->dirty, brtnode_size(child)); r=toku_cachetable_unpin(t->cf, targetchild, child->dirty, brtnode_size(child));
if (r!=0) return r; if (r!=0) return r;
*did_split=0; *did_split=0;
return 0; return 0;
...@@ -1037,9 +1037,9 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd, ...@@ -1037,9 +1037,9 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd,
*did_split = 0; *did_split = 0;
if (maybe) if (maybe)
r = cachetable_maybe_get_and_pin(t->cf, node->u.n.children[childnum], &child_v); r = toku_cachetable_maybe_get_and_pin(t->cf, node->u.n.children[childnum], &child_v);
else else
r = cachetable_get_and_pin(t->cf, node->u.n.children[childnum], &child_v, NULL, r = toku_cachetable_get_and_pin(t->cf, node->u.n.children[childnum], &child_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, t); brtnode_flush_callback, brtnode_fetch_callback, t);
if (r != 0) if (r != 0)
return r; return r;
...@@ -1052,7 +1052,7 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd, ...@@ -1052,7 +1052,7 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd,
&child_did_split, &childa, &childb, &childsplitk, debug, txn); &child_did_split, &childa, &childb, &childsplitk, debug, txn);
if (r != 0) { if (r != 0) {
/* putting to the child failed for some reason, so unpin the child and return the error code */ /* putting to the child failed for some reason, so unpin the child and return the error code */
int rr = cachetable_unpin(t->cf, child->thisnodename, child->dirty, brtnode_size(child)); int rr = toku_cachetable_unpin(t->cf, child->thisnodename, child->dirty, brtnode_size(child));
assert(rr == 0); assert(rr == 0);
return r; return r;
} }
...@@ -1068,7 +1068,7 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd, ...@@ -1068,7 +1068,7 @@ static int brt_nonleaf_put_cmd_child (BRT t, BRTNODE node, BRT_CMD *cmd,
} else { } else {
//verify_local_fingerprint_nonleaf(child); //verify_local_fingerprint_nonleaf(child);
fixup_child_fingerprint(node, childnum, child); fixup_child_fingerprint(node, childnum, child);
int rr = cachetable_unpin(t->cf, child->thisnodename, child->dirty, brtnode_size(child)); int rr = toku_cachetable_unpin(t->cf, child->thisnodename, child->dirty, brtnode_size(child));
assert(rr == 0); assert(rr == 0);
} }
return r; return r;
...@@ -1422,7 +1422,7 @@ static int brtnode_put_cmd (BRT t, BRTNODE node, BRT_CMD *cmd, ...@@ -1422,7 +1422,7 @@ static int brtnode_put_cmd (BRT t, BRTNODE node, BRT_CMD *cmd,
int brt_create_cachetable(CACHETABLE *ct, long cachesize, LSN initial_lsn, TOKULOGGER logger) { int brt_create_cachetable(CACHETABLE *ct, long cachesize, LSN initial_lsn, TOKULOGGER logger) {
if (cachesize == 0) if (cachesize == 0)
cachesize = 128*1024*1024; cachesize = 128*1024*1024;
return create_cachetable(ct, cachesize, initial_lsn, logger); return toku_create_cachetable(ct, cachesize, initial_lsn, logger);
} }
static int setup_brt_root_node (BRT t, DISKOFF offset) { static int setup_brt_root_node (BRT t, DISKOFF offset) {
...@@ -1440,7 +1440,7 @@ static int setup_brt_root_node (BRT t, DISKOFF offset) { ...@@ -1440,7 +1440,7 @@ static int setup_brt_root_node (BRT t, DISKOFF offset) {
printf("%s:%d put root at %lld\n", __FILE__, __LINE__, offset); printf("%s:%d put root at %lld\n", __FILE__, __LINE__, offset);
} }
//printf("%s:%d putting %p (%lld)\n", __FILE__, __LINE__, node, node->thisnodename); //printf("%s:%d putting %p (%lld)\n", __FILE__, __LINE__, node, node->thisnodename);
r=cachetable_put(t->cf, offset, node, brtnode_size(node), r=toku_cachetable_put(t->cf, offset, node, brtnode_size(node),
brtnode_flush_callback, brtnode_fetch_callback, t); brtnode_flush_callback, brtnode_fetch_callback, t);
if (r!=0) { if (r!=0) {
toku_free(node); toku_free(node);
...@@ -1449,7 +1449,7 @@ static int setup_brt_root_node (BRT t, DISKOFF offset) { ...@@ -1449,7 +1449,7 @@ static int setup_brt_root_node (BRT t, DISKOFF offset) {
//printf("%s:%d created %lld\n", __FILE__, __LINE__, node->thisnodename); //printf("%s:%d created %lld\n", __FILE__, __LINE__, node->thisnodename);
verify_counts(node); verify_counts(node);
// verify_local_fingerprint_nonleaf(node); // verify_local_fingerprint_nonleaf(node);
r=cachetable_unpin(t->cf, node->thisnodename, node->dirty, brtnode_size(node)); r=toku_cachetable_unpin(t->cf, node->thisnodename, node->dirty, brtnode_size(node));
if (r!=0) { if (r!=0) {
toku_free(node); toku_free(node);
return r; return r;
...@@ -1497,7 +1497,7 @@ int brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT* ...@@ -1497,7 +1497,7 @@ int brt_set_dup_compare(BRT brt, int (*dup_compare)(DB *, const DBT*, const DBT*
return 0; return 0;
} }
int brt_open(BRT t, const char *fname, const char *dbname, int is_create, int only_create, CACHETABLE cachetable, TOKUTXN txn __attribute__((__unused__))) { int brt_open(BRT t, const char *fname, const char *dbname, int is_create, int only_create, CACHETABLE cachetable, TOKUTXN txn) {
/* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */ /* If dbname is NULL then we setup to hold a single tree. Otherwise we setup an array. */
int r; int r;
...@@ -1517,9 +1517,26 @@ int brt_open(BRT t, const char *fname, const char *dbname, int is_create, int on ...@@ -1517,9 +1517,26 @@ int brt_open(BRT t, const char *fname, const char *dbname, int is_create, int on
} }
} }
t->database_name = malloced_name; t->database_name = malloced_name;
r=cachetable_openf(&t->cf, cachetable, fname, O_RDWR | (is_create ? O_CREAT : 0), 0777); {
int fd = open(fname, O_RDWR, 0777);
r = errno;
if (fd==-1 && errno==ENOENT) {
if (!is_create) {
t->database_name=0;
goto died0a;
}
fd = open(fname, O_RDWR | O_CREAT, 0777);
r = errno;
if (fd==-1) {
t->database_name=0;
goto died0a;
}
tokulogger_log_fcreate(txn, fname, 0777);
}
r=toku_cachetable_openfd(&t->cf, cachetable, fd);
}
if (r!=0) { if (r!=0) {
if (0) { died1: cachefile_close(&t->cf); } if (0) { died1: toku_cachefile_close(&t->cf); }
t->database_name = 0; t->database_name = 0;
goto died0a; goto died0a;
} }
...@@ -1554,7 +1571,7 @@ int brt_open(BRT t, const char *fname, const char *dbname, int is_create, int on ...@@ -1554,7 +1571,7 @@ int brt_open(BRT t, const char *fname, const char *dbname, int is_create, int on
t->h->roots=0; t->h->roots=0;
} }
if ((r=setup_brt_root_node(t, t->nodesize))!=0) { if (dbname) goto died5; else goto died2; } if ((r=setup_brt_root_node(t, t->nodesize))!=0) { if (dbname) goto died5; else goto died2; }
if ((r=cachetable_put(t->cf, 0, t->h, 0, brtheader_flush_callback, brtheader_fetch_callback, 0))) { if (dbname) goto died5; else goto died2; } if ((r=toku_cachetable_put(t->cf, 0, t->h, 0, brtheader_flush_callback, brtheader_fetch_callback, 0))) { if (dbname) goto died5; else goto died2; }
} else { } else {
int i; int i;
assert(r==0); assert(r==0);
...@@ -1683,9 +1700,9 @@ int close_brt (BRT brt) { ...@@ -1683,9 +1700,9 @@ int close_brt (BRT brt) {
if (r!=0) return r; if (r!=0) return r;
} }
if (brt->cf) { if (brt->cf) {
assert(0==cachefile_count_pinned(brt->cf, 1)); assert(0==toku_cachefile_count_pinned(brt->cf, 1));
//printf("%s:%d closing cachetable\n", __FILE__, __LINE__); //printf("%s:%d closing cachetable\n", __FILE__, __LINE__);
if ((r = cachefile_close(&brt->cf))!=0) return r; if ((r = toku_cachefile_close(&brt->cf))!=0) return r;
} }
if (brt->database_name) toku_free(brt->database_name); if (brt->database_name) toku_free(brt->database_name);
if (brt->skey) { toku_free(brt->skey); } if (brt->skey) { toku_free(brt->skey); }
...@@ -1737,12 +1754,12 @@ int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKE ...@@ -1737,12 +1754,12 @@ int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKE
verify_counts(newroot); verify_counts(newroot);
//verify_local_fingerprint_nonleaf(nodea); //verify_local_fingerprint_nonleaf(nodea);
//verify_local_fingerprint_nonleaf(nodeb); //verify_local_fingerprint_nonleaf(nodeb);
r=cachetable_unpin(brt->cf, nodea->thisnodename, nodea->dirty, brtnode_size(nodea)); r=toku_cachetable_unpin(brt->cf, nodea->thisnodename, nodea->dirty, brtnode_size(nodea));
if (r!=0) return r; if (r!=0) return r;
r=cachetable_unpin(brt->cf, nodeb->thisnodename, nodeb->dirty, brtnode_size(nodeb)); r=toku_cachetable_unpin(brt->cf, nodeb->thisnodename, nodeb->dirty, brtnode_size(nodeb));
if (r!=0) return r; if (r!=0) return r;
//printf("%s:%d put %lld\n", __FILE__, __LINE__, brt->root); //printf("%s:%d put %lld\n", __FILE__, __LINE__, brt->root);
cachetable_put(brt->cf, newroot_diskoff, newroot, brtnode_size(newroot), toku_cachetable_put(brt->cf, newroot_diskoff, newroot, brtnode_size(newroot),
brtnode_flush_callback, brtnode_fetch_callback, brt); brtnode_flush_callback, brtnode_fetch_callback, brt);
brt_update_cursors_new_root(brt, newroot, nodea, nodeb); brt_update_cursors_new_root(brt, newroot, nodea, nodeb);
return 0; return 0;
...@@ -1757,14 +1774,14 @@ static int brt_root_put_cmd(BRT brt, BRT_CMD *cmd, TOKUTXN txn) { ...@@ -1757,14 +1774,14 @@ static int brt_root_put_cmd(BRT brt, BRT_CMD *cmd, TOKUTXN txn) {
int did_split; BRTNODE nodea=0, nodeb=0; int did_split; BRTNODE nodea=0, nodeb=0;
DBT splitk; DBT splitk;
int debug = brt_debug_mode;//strcmp(key,"hello387")==0; int debug = brt_debug_mode;//strcmp(key,"hello387")==0;
//assert(0==cachetable_assert_all_unpinned(brt->cachetable)); //assert(0==toku_cachetable_assert_all_unpinned(brt->cachetable));
if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) { if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) {
if (0) { died0: toku_unpin_brt_header(brt); } if (0) { died0: toku_unpin_brt_header(brt); }
return r; return r;
} }
rootp = toku_calculate_root_offset_pointer(brt); rootp = toku_calculate_root_offset_pointer(brt);
if (debug) printf("%s:%d Getting %lld\n", __FILE__, __LINE__, *rootp); if (debug) printf("%s:%d Getting %lld\n", __FILE__, __LINE__, *rootp);
if ((r=cachetable_get_and_pin(brt->cf, *rootp, &node_v, NULL, if ((r=toku_cachetable_get_and_pin(brt->cf, *rootp, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt))) { brtnode_flush_callback, brtnode_fetch_callback, brt))) {
goto died0; goto died0;
} }
...@@ -1797,10 +1814,10 @@ static int brt_root_put_cmd(BRT brt, BRT_CMD *cmd, TOKUTXN txn) { ...@@ -1797,10 +1814,10 @@ static int brt_root_put_cmd(BRT brt, BRT_CMD *cmd, TOKUTXN txn) {
dirty = node->dirty; dirty = node->dirty;
size = brtnode_size(node); size = brtnode_size(node);
} }
cachetable_unpin(brt->cf, *rootp, dirty, size); toku_cachetable_unpin(brt->cf, *rootp, dirty, size);
r = toku_unpin_brt_header(brt); r = toku_unpin_brt_header(brt);
assert(r == 0); assert(r == 0);
//assert(0==cachetable_assert_all_unpinned(brt->cachetable)); //assert(0==toku_cachetable_assert_all_unpinned(brt->cachetable));
return result; return result;
} }
...@@ -1819,7 +1836,7 @@ int brt_insert (BRT brt, DBT *key, DBT *val, DB* db, TOKUTXN txn) { ...@@ -1819,7 +1836,7 @@ int brt_insert (BRT brt, DBT *key, DBT *val, DB* db, TOKUTXN txn) {
int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE parent_brtnode) { int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE parent_brtnode) {
int result; int result;
void *node_v; void *node_v;
int r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt); brtnode_flush_callback, brtnode_fetch_callback, brt);
if (r!=0) if (r!=0)
return r; return r;
...@@ -1836,7 +1853,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren ...@@ -1836,7 +1853,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren
result = pma_lookup(node->u.l.buffer, k, v, db); result = pma_lookup(node->u.l.buffer, k, v, db);
//printf("%s:%d looked up something, got answerlen=%d\n", __FILE__, __LINE__, answerlen); //printf("%s:%d looked up something, got answerlen=%d\n", __FILE__, __LINE__, answerlen);
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
r = cachetable_unpin(brt->cf, off, 0, 0); r = toku_cachetable_unpin(brt->cf, off, 0, 0);
assert(r == 0); assert(r == 0);
return result; return result;
} }
...@@ -1871,7 +1888,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren ...@@ -1871,7 +1888,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren
result = EINVAL; result = EINVAL;
} }
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
r = cachetable_unpin(brt->cf, off, 0, 0); r = toku_cachetable_unpin(brt->cf, off, 0, 0);
assert(r == 0); assert(r == 0);
return result; return result;
} }
...@@ -1879,7 +1896,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren ...@@ -1879,7 +1896,7 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren
result = brt_lookup_node(brt, node->u.n.children[childnum], k, v, db, node); result = brt_lookup_node(brt, node->u.n.children[childnum], k, v, db, node);
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
r = cachetable_unpin(brt->cf, off, 0, 0); r = toku_cachetable_unpin(brt->cf, off, 0, 0);
assert(r == 0); assert(r == 0);
return result; return result;
} }
...@@ -1888,12 +1905,12 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren ...@@ -1888,12 +1905,12 @@ int brt_lookup_node (BRT brt, DISKOFF off, DBT *k, DBT *v, DB *db, BRTNODE paren
int brt_lookup (BRT brt, DBT *k, DBT *v, DB *db) { int brt_lookup (BRT brt, DBT *k, DBT *v, DB *db) {
int r; int r;
CACHEKEY *rootp; CACHEKEY *rootp;
assert(0==cachefile_count_pinned(brt->cf, 1)); assert(0==toku_cachefile_count_pinned(brt->cf, 1));
if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) { if ((r = toku_read_and_pin_brt_header(brt->cf, &brt->h))) {
printf("%s:%d\n", __FILE__, __LINE__); printf("%s:%d\n", __FILE__, __LINE__);
if (0) { died0: toku_unpin_brt_header(brt); } if (0) { died0: toku_unpin_brt_header(brt); }
// printf("%s:%d returning %d\n", __FILE__, __LINE__, r); // printf("%s:%d returning %d\n", __FILE__, __LINE__, r);
assert(0==cachefile_count_pinned(brt->cf, 1)); assert(0==toku_cachefile_count_pinned(brt->cf, 1));
return r; return r;
} }
rootp = toku_calculate_root_offset_pointer(brt); rootp = toku_calculate_root_offset_pointer(brt);
...@@ -1903,7 +1920,7 @@ int brt_lookup (BRT brt, DBT *k, DBT *v, DB *db) { ...@@ -1903,7 +1920,7 @@ int brt_lookup (BRT brt, DBT *k, DBT *v, DB *db) {
} }
//printf("%s:%d r=%d", __FILE__, __LINE__, r); if (r==0) printf(" vallen=%d", *vallen); printf("\n"); //printf("%s:%d r=%d", __FILE__, __LINE__, r); if (r==0) printf(" vallen=%d", *vallen); printf("\n");
if ((r = toku_unpin_brt_header(brt))!=0) return r; if ((r = toku_unpin_brt_header(brt))!=0) return r;
assert(0==cachefile_count_pinned(brt->cf, 1)); assert(0==toku_cachefile_count_pinned(brt->cf, 1));
return 0; return 0;
} }
...@@ -1928,7 +1945,7 @@ int dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN lole ...@@ -1928,7 +1945,7 @@ int dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN lole
int result=0; int result=0;
BRTNODE node; BRTNODE node;
void *node_v; void *node_v;
int r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt); brtnode_flush_callback, brtnode_fetch_callback, brt);
assert(r==0); assert(r==0);
printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v); printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
...@@ -1972,7 +1989,7 @@ int dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN lole ...@@ -1972,7 +1989,7 @@ int dump_brtnode (BRT brt, DISKOFF off, int depth, bytevec lorange, ITEMLEN lole
( keylen=keylen, vallen=vallen, printf(" %s:%s", (char*)key, (char*)val))); ( keylen=keylen, vallen=vallen, printf(" %s:%s", (char*)key, (char*)val)));
printf("\n"); printf("\n");
} }
r = cachetable_unpin(brt->cf, off, 0, 0); r = toku_cachetable_unpin(brt->cf, off, 0, 0);
assert(r==0); assert(r==0);
return result; return result;
} }
...@@ -1996,9 +2013,9 @@ int show_brtnode_blocknumbers (BRT brt, DISKOFF off, BRTNODE parent_brtnode) { ...@@ -1996,9 +2013,9 @@ int show_brtnode_blocknumbers (BRT brt, DISKOFF off, BRTNODE parent_brtnode) {
void *node_v; void *node_v;
int i,r; int i,r;
assert(off%brt->h->nodesize==0); assert(off%brt->h->nodesize==0);
if ((r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, if ((r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt))) { brtnode_flush_callback, brtnode_fetch_callback, brt))) {
if (0) { died0: cachetable_unpin(brt->cf, off, 0, 0); } if (0) { died0: toku_cachetable_unpin(brt->cf, off, 0, 0); }
return r; return r;
} }
printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v); printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
...@@ -2010,7 +2027,7 @@ int show_brtnode_blocknumbers (BRT brt, DISKOFF off, BRTNODE parent_brtnode) { ...@@ -2010,7 +2027,7 @@ int show_brtnode_blocknumbers (BRT brt, DISKOFF off, BRTNODE parent_brtnode) {
if ((r=show_brtnode_blocknumbers(brt, node->u.n.children[i], node))) goto died0; if ((r=show_brtnode_blocknumbers(brt, node->u.n.children[i], node))) goto died0;
} }
} }
r = cachetable_unpin(brt->cf, off, 0, 0); r = toku_cachetable_unpin(brt->cf, off, 0, 0);
return r; return r;
} }
...@@ -2072,7 +2089,7 @@ void brt_flush_child(BRT t, BRTNODE node, int childnum, BRT_CURSOR cursor, DB *d ...@@ -2072,7 +2089,7 @@ void brt_flush_child(BRT t, BRTNODE node, int childnum, BRT_CURSOR cursor, DB *d
CACHEKEY *rootp = toku_calculate_root_offset_pointer(t); CACHEKEY *rootp = toku_calculate_root_offset_pointer(t);
r = brt_init_new_root(t, childa, childb, child_splitk, rootp); r = brt_init_new_root(t, childa, childb, child_splitk, rootp);
assert(r == 0); assert(r == 0);
r = cachetable_unpin(t->cf, *rootp, CACHETABLE_DIRTY, 0); r = toku_cachetable_unpin(t->cf, *rootp, CACHETABLE_DIRTY, 0);
assert(r == 0); assert(r == 0);
} else { } else {
BRTNODE upnode; BRTNODE upnode;
...@@ -2185,7 +2202,7 @@ void brt_cursor_new_root(BRT_CURSOR cursor, BRT t, BRTNODE newroot, BRTNODE left ...@@ -2185,7 +2202,7 @@ void brt_cursor_new_root(BRT_CURSOR cursor, BRT t, BRTNODE newroot, BRTNODE left
cursor->path[0] = newroot; cursor->path[0] = newroot;
childnum = cursor->path[1] == left ? 0 : 1; childnum = cursor->path[1] == left ? 0 : 1;
cursor->pathcnum[0] = childnum; cursor->pathcnum[0] = childnum;
r = cachetable_maybe_get_and_pin(t->cf, newroot->thisnodename, &v); r = toku_cachetable_maybe_get_and_pin(t->cf, newroot->thisnodename, &v);
assert(r == 0 && v == newroot); assert(r == 0 && v == newroot);
brt_node_add_cursor(newroot, childnum, cursor); brt_node_add_cursor(newroot, childnum, cursor);
} }
...@@ -2214,9 +2231,9 @@ void brt_cursor_leaf_split(BRT_CURSOR cursor, BRT t, BRTNODE oldnode, BRTNODE le ...@@ -2214,9 +2231,9 @@ void brt_cursor_leaf_split(BRT_CURSOR cursor, BRT t, BRTNODE oldnode, BRTNODE le
oldnode->thisnodename, newnode->thisnodename); oldnode->thisnodename, newnode->thisnodename);
//verify_local_fingerprint_nonleaf(oldnode); //verify_local_fingerprint_nonleaf(oldnode);
r = cachetable_unpin(t->cf, oldnode->thisnodename, oldnode->dirty, brtnode_size(oldnode)); r = toku_cachetable_unpin(t->cf, oldnode->thisnodename, oldnode->dirty, brtnode_size(oldnode));
assert(r == 0); assert(r == 0);
r = cachetable_maybe_get_and_pin(t->cf, newnode->thisnodename, &v); r = toku_cachetable_maybe_get_and_pin(t->cf, newnode->thisnodename, &v);
assert(r == 0 && v == newnode); assert(r == 0 && v == newnode);
cursor->path[cursor->path_len-1] = newnode; cursor->path[cursor->path_len-1] = newnode;
} }
...@@ -2290,9 +2307,9 @@ void brt_cursor_nonleaf_split(BRT_CURSOR cursor, BRT t, BRTNODE oldnode, BRTNODE ...@@ -2290,9 +2307,9 @@ void brt_cursor_nonleaf_split(BRT_CURSOR cursor, BRT t, BRTNODE oldnode, BRTNODE
cursor, oldnode->thisnodename, newnode->thisnodename); cursor, oldnode->thisnodename, newnode->thisnodename);
// The oldnode is probably dead. But we say it is dirty? ??? // The oldnode is probably dead. But we say it is dirty? ???
r = cachetable_unpin(t->cf, oldnode->thisnodename, oldnode->dirty, brtnode_size(oldnode)); r = toku_cachetable_unpin(t->cf, oldnode->thisnodename, oldnode->dirty, brtnode_size(oldnode));
assert(r == 0); assert(r == 0);
r = cachetable_maybe_get_and_pin(t->cf, newnode->thisnodename, &v); r = toku_cachetable_maybe_get_and_pin(t->cf, newnode->thisnodename, &v);
assert(r == 0 && v == newnode); assert(r == 0 && v == newnode);
brt_node_add_cursor(newnode, childnum, cursor); brt_node_add_cursor(newnode, childnum, cursor);
cursor->path[i] = newnode; cursor->path[i] = newnode;
...@@ -2366,10 +2383,10 @@ int brtcurs_set_position_last (BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db, ...@@ -2366,10 +2383,10 @@ int brtcurs_set_position_last (BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db,
BRT brt=cursor->brt; BRT brt=cursor->brt;
void *node_v; void *node_v;
int r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt); brtnode_flush_callback, brtnode_fetch_callback, brt);
if (r!=0) { if (r!=0) {
if (0) { died0: cachetable_unpin(brt->cf, off, 1, 0); } if (0) { died0: toku_cachetable_unpin(brt->cf, off, 1, 0); }
return r; return r;
} }
BRTNODE node = node_v; BRTNODE node = node_v;
...@@ -2428,10 +2445,10 @@ int brtcurs_set_position_first (BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db ...@@ -2428,10 +2445,10 @@ int brtcurs_set_position_first (BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db
BRT brt=cursor->brt; BRT brt=cursor->brt;
void *node_v; void *node_v;
int r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, int r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL,
brtnode_flush_callback, brtnode_fetch_callback, brt); brtnode_flush_callback, brtnode_fetch_callback, brt);
if (r!=0) { if (r!=0) {
if (0) { died0: cachetable_unpin(brt->cf, off, 1, 0); } if (0) { died0: toku_cachetable_unpin(brt->cf, off, 1, 0); }
return r; return r;
} }
BRTNODE node = node_v; BRTNODE node = node_v;
...@@ -2500,7 +2517,7 @@ int brtcurs_set_position_next2(BRT_CURSOR cursor, DBT *key, DB *db, TOKUTXN txn) ...@@ -2500,7 +2517,7 @@ int brtcurs_set_position_next2(BRT_CURSOR cursor, DBT *key, DB *db, TOKUTXN txn)
childnum = cursor->pathcnum[cursor->path_len-1]; childnum = cursor->pathcnum[cursor->path_len-1];
cursor->path_len -= 1; cursor->path_len -= 1;
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
cachetable_unpin(cursor->brt->cf, node->thisnodename, node->dirty, brtnode_size(node)); toku_cachetable_unpin(cursor->brt->cf, node->thisnodename, node->dirty, brtnode_size(node));
if (brt_cursor_path_empty(cursor)) if (brt_cursor_path_empty(cursor))
return DB_NOTFOUND; return DB_NOTFOUND;
...@@ -2561,7 +2578,7 @@ int brtcurs_set_position_prev2(BRT_CURSOR cursor, DBT *key, DB *db, TOKUTXN txn) ...@@ -2561,7 +2578,7 @@ int brtcurs_set_position_prev2(BRT_CURSOR cursor, DBT *key, DB *db, TOKUTXN txn)
childnum = cursor->pathcnum[cursor->path_len-1]; childnum = cursor->pathcnum[cursor->path_len-1];
cursor->path_len -= 1; cursor->path_len -= 1;
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
cachetable_unpin(cursor->brt->cf, node->thisnodename, node->dirty, brtnode_size(node)); toku_cachetable_unpin(cursor->brt->cf, node->thisnodename, node->dirty, brtnode_size(node));
if (brt_cursor_path_empty(cursor)) if (brt_cursor_path_empty(cursor))
return DB_NOTFOUND; return DB_NOTFOUND;
...@@ -2611,7 +2628,7 @@ int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag ...@@ -2611,7 +2628,7 @@ int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag
BRT brt = cursor->brt; BRT brt = cursor->brt;
void *node_v; void *node_v;
int r; int r;
r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, brtnode_flush_callback, r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL, brtnode_flush_callback,
brtnode_fetch_callback, brt); brtnode_fetch_callback, brt);
if (r != 0) if (r != 0)
return r; return r;
...@@ -2664,7 +2681,7 @@ int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag ...@@ -2664,7 +2681,7 @@ int brtcurs_set_key(BRT_CURSOR cursor, DISKOFF off, DBT *key, DBT *val, int flag
if (r != 0) { if (r != 0) {
cursor->path_len -= 1; cursor->path_len -= 1;
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
cachetable_unpin(brt->cf, off, node->dirty, brtnode_size(node)); toku_cachetable_unpin(brt->cf, off, node->dirty, brtnode_size(node));
} }
return r; return r;
} }
...@@ -2673,7 +2690,7 @@ int brtcurs_set_range(BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db, TOKUTXN ...@@ -2673,7 +2690,7 @@ int brtcurs_set_range(BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db, TOKUTXN
BRT brt = cursor->brt; BRT brt = cursor->brt;
void *node_v; void *node_v;
int r; int r;
r = cachetable_get_and_pin(brt->cf, off, &node_v, NULL, brtnode_flush_callback, r = toku_cachetable_get_and_pin(brt->cf, off, &node_v, NULL, brtnode_flush_callback,
brtnode_fetch_callback, brt); brtnode_fetch_callback, brt);
if (r != 0) if (r != 0)
return r; return r;
...@@ -2728,7 +2745,7 @@ int brtcurs_set_range(BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db, TOKUTXN ...@@ -2728,7 +2745,7 @@ int brtcurs_set_range(BRT_CURSOR cursor, DISKOFF off, DBT *key, DB *db, TOKUTXN
if (r != 0) { if (r != 0) {
cursor->path_len -= 1; cursor->path_len -= 1;
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
cachetable_unpin(brt->cf, off, node->dirty, brtnode_size(node)); toku_cachetable_unpin(brt->cf, off, node->dirty, brtnode_size(node));
} }
return r; return r;
} }
...@@ -2741,7 +2758,7 @@ static int unpin_cursor (BRT_CURSOR cursor) { ...@@ -2741,7 +2758,7 @@ static int unpin_cursor (BRT_CURSOR cursor) {
BRTNODE node = cursor->path[i]; BRTNODE node = cursor->path[i];
brt_node_remove_cursor(node, cursor->pathcnum[i], cursor); brt_node_remove_cursor(node, cursor->pathcnum[i], cursor);
//verify_local_fingerprint_nonleaf(node); //verify_local_fingerprint_nonleaf(node);
int r2 = cachetable_unpin(brt->cf, node->thisnodename, node->dirty, brtnode_size(node)); int r2 = toku_cachetable_unpin(brt->cf, node->thisnodename, node->dirty, brtnode_size(node));
if (r==0) r=r2; if (r==0) r=r2;
} }
if (cursor->pmacurs) { if (cursor->pmacurs) {
......
...@@ -79,60 +79,60 @@ void test0 (void) { ...@@ -79,60 +79,60 @@ void test0 (void) {
CACHEFILE f; CACHEFILE f;
int r; int r;
char fname[] = "test.dat"; char fname[] = "test.dat";
r=create_cachetable(&t, 5, ZERO_LSN, NULL_LOGGER); r=toku_create_cachetable(&t, 5, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r==0); assert(r==0);
expect_f = f; expect_f = f;
expect_n_flushes=0; expect_n_flushes=0;
r=cachetable_put(f, 1, make_item(1), test_object_size, flush, fetch, t3); /* 1P */ /* this is the lru list. 1 is pinned. */ r=toku_cachetable_put(f, 1, make_item(1), test_object_size, flush, fetch, t3); /* 1P */ /* this is the lru list. 1 is pinned. */
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
expect_n_flushes=0; expect_n_flushes=0;
r=cachetable_put(f, 2, make_item(2), test_object_size, flush, fetch, t3); r=toku_cachetable_put(f, 2, make_item(2), test_object_size, flush, fetch, t3);
assert(r==0); assert(r==0);
r=cachetable_unpin(f, 2, CACHETABLE_DIRTY, 1); /* 2U 1P */ r=toku_cachetable_unpin(f, 2, CACHETABLE_DIRTY, 1); /* 2U 1P */
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
expect_n_flushes=0; expect_n_flushes=0;
r=cachetable_put(f, 3, make_item(3), test_object_size, flush, fetch, t3); r=toku_cachetable_put(f, 3, make_item(3), test_object_size, flush, fetch, t3);
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); /* 3P 2U 1P */ /* 3 is most recently used (pinned), 2 is next (unpinned), 1 is least recent (pinned) */ assert(expect_n_flushes==0); /* 3P 2U 1P */ /* 3 is most recently used (pinned), 2 is next (unpinned), 1 is least recent (pinned) */
expect_n_flushes=0; expect_n_flushes=0;
r=cachetable_put(f, 4, make_item(4), test_object_size, flush, fetch, t3); r=toku_cachetable_put(f, 4, make_item(4), test_object_size, flush, fetch, t3);
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); /* 4P 3P 2U 1P */ assert(expect_n_flushes==0); /* 4P 3P 2U 1P */
expect_n_flushes=0; expect_n_flushes=0;
r=cachetable_put(f, 5, make_item(5), test_object_size, flush, fetch, t3); r=toku_cachetable_put(f, 5, make_item(5), test_object_size, flush, fetch, t3);
assert(r==0); assert(r==0);
r=cachetable_unpin(f, 5, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f, 5, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
r=cachetable_unpin(f, 3, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f, 3, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); /* 5U 4P 3U 2U 1P */ assert(expect_n_flushes==0); /* 5U 4P 3U 2U 1P */
expect1(2); /* 2 is the oldest unpinned item. */ expect1(2); /* 2 is the oldest unpinned item. */
r=cachetable_put(f, 6, make_item(6), test_object_size, flush, fetch, t3); /* 6P 5U 4P 3U 1P */ r=toku_cachetable_put(f, 6, make_item(6), test_object_size, flush, fetch, t3); /* 6P 5U 4P 3U 1P */
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
expect1(3); expect1(3);
r=cachetable_put(f, 7, make_item(7), test_object_size, flush, fetch, t3); r=toku_cachetable_put(f, 7, make_item(7), test_object_size, flush, fetch, t3);
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
r=cachetable_unpin(f, 7, CACHETABLE_DIRTY, test_object_size); /* 7U 6P 5U 4P 1P */ r=toku_cachetable_unpin(f, 7, CACHETABLE_DIRTY, test_object_size); /* 7U 6P 5U 4P 1P */
assert(r==0); assert(r==0);
{ {
void *item_v=0; void *item_v=0;
expect_n_flushes=0; expect_n_flushes=0;
r=cachetable_get_and_pin(f, 5, &item_v, NULL, flush, fetch, t3); /* 5P 7U 6P 4P 1P */ r=toku_cachetable_get_and_pin(f, 5, &item_v, NULL, flush, fetch, t3); /* 5P 7U 6P 4P 1P */
assert(r==0); assert(r==0);
assert(((struct item *)item_v)->key==5); assert(((struct item *)item_v)->key==5);
assert(strcmp(((struct item *)item_v)->something,"something")==0); assert(strcmp(((struct item *)item_v)->something,"something")==0);
...@@ -141,11 +141,11 @@ void test0 (void) { ...@@ -141,11 +141,11 @@ void test0 (void) {
{ {
void *item_v=0; void *item_v=0;
r=cachetable_unpin(f, 4, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f, 4, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
expect1(4); expect1(4);
did_fetch=-1; did_fetch=-1;
r=cachetable_get_and_pin(f, 2, &item_v, NULL, flush, fetch, t3); /* 2p 5P 7U 6P 1P */ r=toku_cachetable_get_and_pin(f, 2, &item_v, NULL, flush, fetch, t3); /* 2p 5P 7U 6P 1P */
assert(r==0); assert(r==0);
assert(did_fetch==2); /* Expect that 2 is fetched in. */ assert(did_fetch==2); /* Expect that 2 is fetched in. */
assert(((struct item *)item_v)->key==2); assert(((struct item *)item_v)->key==2);
...@@ -153,15 +153,15 @@ void test0 (void) { ...@@ -153,15 +153,15 @@ void test0 (void) {
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
} }
r=cachetable_unpin(f, 2, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f, 2, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
r=cachetable_unpin(f ,5, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f ,5, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
r=cachetable_unpin(f, 6, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f, 6, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
r=cachetable_unpin(f, 1, CACHETABLE_DIRTY, test_object_size); r=toku_cachetable_unpin(f, 1, CACHETABLE_DIRTY, test_object_size);
assert(r==0); assert(r==0);
r=cachetable_assert_all_unpinned(t); r=toku_cachetable_assert_all_unpinned(t);
assert(r==0); assert(r==0);
printf("Closing\n"); printf("Closing\n");
...@@ -170,9 +170,9 @@ void test0 (void) { ...@@ -170,9 +170,9 @@ void test0 (void) {
expectN(7); expectN(7);
expectN(6); expectN(6);
expectN(1); expectN(1);
r=cachefile_close(&f); r=toku_cachefile_close(&f);
assert(r==0); assert(r==0);
r=cachetable_close(&t); r=toku_cachetable_close(&t);
assert(r==0); assert(r==0);
assert(expect_n_flushes==0); assert(expect_n_flushes==0);
expect_f = 0; expect_f = 0;
...@@ -203,31 +203,31 @@ void test_nested_pin (void) { ...@@ -203,31 +203,31 @@ void test_nested_pin (void) {
int r; int r;
void *vv; void *vv;
char fname[] = "test_ct.dat"; char fname[] = "test_ct.dat";
r = create_cachetable(&t, 1, ZERO_LSN, NULL_LOGGER); r = toku_create_cachetable(&t, 1, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r==0); assert(r==0);
expect_f = f; expect_f = f;
i0=0; i1=0; i0=0; i1=0;
r = cachetable_put(f, 1, &i0, 1, flush_n, fetch_n, f2); r = toku_cachetable_put(f, 1, &i0, 1, flush_n, fetch_n, f2);
assert(r==0); assert(r==0);
r = cachetable_get_and_pin(f, 1, &vv, NULL, flush_n, fetch_n, f2); r = toku_cachetable_get_and_pin(f, 1, &vv, NULL, flush_n, fetch_n, f2);
assert(r==0); assert(r==0);
assert(vv==&i0); assert(vv==&i0);
assert(i0==0); assert(i0==0);
r = cachetable_unpin(f, 1, 0, test_object_size); r = toku_cachetable_unpin(f, 1, 0, test_object_size);
assert(r==0); assert(r==0);
r = cachetable_put(f, 2, &i1, test_object_size, flush_n, fetch_n, f2); r = toku_cachetable_put(f, 2, &i1, test_object_size, flush_n, fetch_n, f2);
assert(r!=0); // previously pinned, we shouldn't be able to put. assert(r!=0); // previously pinned, we shouldn't be able to put.
r = cachetable_unpin(f, 1, 0, test_object_size); r = toku_cachetable_unpin(f, 1, 0, test_object_size);
assert(r==0); assert(r==0);
r = cachetable_put(f, 2, &i1, test_object_size, flush_n, fetch_n, f2); r = toku_cachetable_put(f, 2, &i1, test_object_size, flush_n, fetch_n, f2);
assert(r==0); // now it is unpinned, we can put it. assert(r==0); // now it is unpinned, we can put it.
r = cachefile_close(&f); assert(r==0); r = toku_cachefile_close(&f); assert(r==0);
r = cachetable_close(&t); assert(r==0); r = toku_cachetable_close(&t); assert(r==0);
} }
...@@ -266,29 +266,29 @@ void test_multi_filehandles (void) { ...@@ -266,29 +266,29 @@ void test_multi_filehandles (void) {
unlink(fname1); unlink(fname1);
unlink(fname2); unlink(fname2);
r = create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = cachetable_openf(&f1, t, fname1, O_RDWR|O_CREAT, 0777); assert(r==0); r = toku_cachetable_openf(&f1, t, fname1, O_RDWR|O_CREAT, 0777); assert(r==0);
r = link(fname1, fname2); assert(r==0); r = link(fname1, fname2); assert(r==0);
r = cachetable_openf(&f2, t, fname2, O_RDWR|O_CREAT, 0777); assert(r==0); r = toku_cachetable_openf(&f2, t, fname2, O_RDWR|O_CREAT, 0777); assert(r==0);
r = cachetable_openf(&f3, t, fname3, O_RDWR|O_CREAT, 0777); assert(r==0); r = toku_cachetable_openf(&f3, t, fname3, O_RDWR|O_CREAT, 0777); assert(r==0);
assert(f1==f2); assert(f1==f2);
assert(f1!=f3); assert(f1!=f3);
r = cachetable_put(f1, 1, (void*)124, test_object_size, null_flush, add123_fetch, (void*)123); assert(r==0); r = toku_cachetable_put(f1, 1, (void*)124, test_object_size, null_flush, add123_fetch, (void*)123); assert(r==0);
r = cachetable_get_and_pin(f2, 1, &v, NULL, null_flush, add123_fetch, (void*)123); assert(r==0); r = toku_cachetable_get_and_pin(f2, 1, &v, NULL, null_flush, add123_fetch, (void*)123); assert(r==0);
assert((unsigned long)v==124); assert((unsigned long)v==124);
r = cachetable_get_and_pin(f2, 2, &v, NULL, null_flush, add123_fetch, (void*)123); assert(r==0); r = toku_cachetable_get_and_pin(f2, 2, &v, NULL, null_flush, add123_fetch, (void*)123); assert(r==0);
assert((unsigned long)v==125); assert((unsigned long)v==125);
r = cachetable_get_and_pin(f3, 2, &v, NULL, null_flush, add222_fetch, (void*)222); assert(r==0); r = toku_cachetable_get_and_pin(f3, 2, &v, NULL, null_flush, add222_fetch, (void*)222); assert(r==0);
assert((unsigned long)v==224); assert((unsigned long)v==224);
r = cachetable_maybe_get_and_pin(f1, 2, &v); assert(r==0); r = toku_cachetable_maybe_get_and_pin(f1, 2, &v); assert(r==0);
assert((unsigned long)v==125); assert((unsigned long)v==125);
r = cachefile_close(&f1); assert(r==0); r = toku_cachefile_close(&f1); assert(r==0);
r = cachefile_close(&f2); assert(r==0); r = toku_cachefile_close(&f2); assert(r==0);
r = cachefile_close(&f3); assert(r==0); r = toku_cachefile_close(&f3); assert(r==0);
r = cachetable_close(&t); assert(r==0); r = toku_cachetable_close(&t); assert(r==0);
} }
void test_dirty_flush(CACHEFILE f, CACHEKEY key, void *value, long size, BOOL do_write, BOOL keep, LSN modified_lsn __attribute__((__unused__)), BOOL rename_p __attribute__((__unused__))) { void test_dirty_flush(CACHEFILE f, CACHEKEY key, void *value, long size, BOOL do_write, BOOL keep, LSN modified_lsn __attribute__((__unused__)), BOOL rename_p __attribute__((__unused__))) {
...@@ -311,92 +311,92 @@ void test_dirty() { ...@@ -311,92 +311,92 @@ void test_dirty() {
int dirty; long long pinned; long entry_size; int dirty; long long pinned; long entry_size;
int r; int r;
r = create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER); r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER);
assert(r == 0); assert(r == 0);
char *fname = "test.dat"; char *fname = "test.dat";
unlink(fname); unlink(fname);
r = cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r == 0); assert(r == 0);
key = 1; value = (void*)1; key = 1; value = (void*)1;
r = cachetable_put(f, key, value, test_object_size, test_dirty_flush, 0, 0); r = toku_cachetable_put(f, key, value, test_object_size, test_dirty_flush, 0, 0);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 1); assert(pinned == 1);
r = cachetable_unpin(f, key, CACHETABLE_CLEAN, 0); r = toku_cachetable_unpin(f, key, CACHETABLE_CLEAN, 0);
assert(r == 0); assert(r == 0);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 0); assert(pinned == 0);
r = cachetable_get_and_pin(f, key, &value, NULL, test_dirty_flush, r = toku_cachetable_get_and_pin(f, key, &value, NULL, test_dirty_flush,
test_dirty_fetch, 0); test_dirty_fetch, 0);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 1); assert(pinned == 1);
r = cachetable_unpin(f, key, CACHETABLE_CLEAN, test_object_size); r = toku_cachetable_unpin(f, key, CACHETABLE_CLEAN, test_object_size);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 0); assert(pinned == 0);
key = 2; key = 2;
r = cachetable_get_and_pin(f, key, &value, NULL, test_dirty_flush, r = toku_cachetable_get_and_pin(f, key, &value, NULL, test_dirty_flush,
test_dirty_fetch, 0); test_dirty_fetch, 0);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 0); assert(dirty == 0);
assert(pinned == 1); assert(pinned == 1);
r = cachetable_unpin(f, key, CACHETABLE_CLEAN, test_object_size); r = toku_cachetable_unpin(f, key, CACHETABLE_CLEAN, test_object_size);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 0); assert(dirty == 0);
assert(pinned == 0); assert(pinned == 0);
r = cachetable_get_and_pin(f, key, &value, NULL, test_dirty_flush, r = toku_cachetable_get_and_pin(f, key, &value, NULL, test_dirty_flush,
test_dirty_fetch, 0); test_dirty_fetch, 0);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 0); assert(dirty == 0);
assert(pinned == 1); assert(pinned == 1);
r = cachetable_unpin(f, key, CACHETABLE_DIRTY, test_object_size); r = toku_cachetable_unpin(f, key, CACHETABLE_DIRTY, test_object_size);
assert(r == 0); assert(r == 0);
// cachetable_print_state(t); // cachetable_print_state(t);
r = cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 0); assert(pinned == 0);
r = cachefile_close(&f); r = toku_cachefile_close(&f);
assert(r == 0); assert(r == 0);
r = cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
} }
...@@ -419,22 +419,22 @@ void test_size_resize() { ...@@ -419,22 +419,22 @@ void test_size_resize() {
int n = 3; int n = 3;
long size = 1; long size = 1;
r = create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER); r = toku_create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER);
assert(r == 0); assert(r == 0);
char *fname = "test.dat"; char *fname = "test.dat";
unlink(fname); unlink(fname);
r = cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r == 0); assert(r == 0);
CACHEKEY key = 42; CACHEKEY key = 42;
void *value = (void *) -42; void *value = (void *) -42;
r = cachetable_put(f, key, value, size, test_size_flush_callback, 0, 0); r = toku_cachetable_put(f, key, value, size, test_size_flush_callback, 0, 0);
assert(r == 0); assert(r == 0);
void *entry_value; int dirty; long long pinned; long entry_size; void *entry_value; int dirty; long long pinned; long entry_size;
r = cachetable_get_key_state(t, key, &entry_value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &entry_value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 1); assert(pinned == 1);
...@@ -442,22 +442,22 @@ void test_size_resize() { ...@@ -442,22 +442,22 @@ void test_size_resize() {
assert(entry_size == size); assert(entry_size == size);
long long new_size = 2*size; long long new_size = 2*size;
r = cachetable_unpin(f, key, CACHETABLE_CLEAN, new_size); r = toku_cachetable_unpin(f, key, CACHETABLE_CLEAN, new_size);
assert(r == 0); assert(r == 0);
void *current_value; void *current_value;
long current_size; long current_size;
r = cachetable_get_and_pin(f, key, &current_value, &current_size, test_size_flush_callback, 0, 0); r = toku_cachetable_get_and_pin(f, key, &current_value, &current_size, test_size_flush_callback, 0, 0);
assert(r == 0); assert(r == 0);
assert(current_value == value); assert(current_value == value);
assert(current_size == new_size); assert(current_size == new_size);
r = cachetable_unpin(f, key, CACHETABLE_CLEAN, new_size); r = toku_cachetable_unpin(f, key, CACHETABLE_CLEAN, new_size);
assert(r == 0); assert(r == 0);
r = cachefile_close(&f); r = toku_cachefile_close(&f);
assert(r == 0); assert(r == 0);
r = cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
} }
...@@ -470,12 +470,12 @@ void test_size_flush() { ...@@ -470,12 +470,12 @@ void test_size_flush() {
const int n = 8; const int n = 8;
long long size = 1*1024*1024; long long size = 1*1024*1024;
r = create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER); r = toku_create_cachetable(&t, n*size, ZERO_LSN, NULL_LOGGER);
assert(r == 0); assert(r == 0);
char *fname = "test.dat"; char *fname = "test.dat";
unlink(fname); unlink(fname);
r = cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r == 0); assert(r == 0);
/* put 2*n keys into the table, ensure flushes occur in key order */ /* put 2*n keys into the table, ensure flushes occur in key order */
...@@ -487,16 +487,16 @@ void test_size_flush() { ...@@ -487,16 +487,16 @@ void test_size_flush() {
CACHEKEY key = i; CACHEKEY key = i;
void *value = (void *)(long)-i; void *value = (void *)(long)-i;
// printf("test_size put %lld %p %lld\n", key, value, size); // printf("test_size put %lld %p %lld\n", key, value, size);
r = cachetable_put(f, key, value, size, test_size_flush_callback, 0, 0); r = toku_cachetable_put(f, key, value, size, test_size_flush_callback, 0, 0);
assert(r == 0); assert(r == 0);
int n_entries; int n_entries;
cachetable_get_state(t, &n_entries, 0, 0, 0); toku_cachetable_get_state(t, &n_entries, 0, 0, 0);
int min2(int a, int b) { return a < b ? a : b; } int min2(int a, int b) { return a < b ? a : b; }
assert(n_entries == min2(i+1, n)); assert(n_entries == min2(i+1, n));
void *entry_value; int dirty; long long pinned; long entry_size; void *entry_value; int dirty; long long pinned; long entry_size;
r = cachetable_get_key_state(t, key, &entry_value, &dirty, &pinned, &entry_size); r = toku_cachetable_get_key_state(t, key, &entry_value, &dirty, &pinned, &entry_size);
assert(r == 0); assert(r == 0);
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 1); assert(pinned == 1);
...@@ -509,13 +509,13 @@ void test_size_flush() { ...@@ -509,13 +509,13 @@ void test_size_flush() {
expect_flush_key += 1; expect_flush_key += 1;
} }
r = cachetable_unpin(f, key, CACHETABLE_CLEAN, size); r = toku_cachetable_unpin(f, key, CACHETABLE_CLEAN, size);
assert(r == 0); assert(r == 0);
} }
r = cachefile_close(&f); r = toku_cachefile_close(&f);
assert(r == 0); assert(r == 0);
r = cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
} }
...@@ -564,9 +564,9 @@ void test_rename (void) { ...@@ -564,9 +564,9 @@ void test_rename (void) {
int i; int i;
int r; int r;
const char fname[] = "ct-test-rename.dat"; const char fname[] = "ct-test-rename.dat";
r=create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); r=toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777); r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r==0); assert(r==0);
for (i=0; i<TRIALLIMIT; i++) { for (i=0; i<TRIALLIMIT; i++) {
...@@ -576,14 +576,14 @@ void test_rename (void) { ...@@ -576,14 +576,14 @@ void test_rename (void) {
CACHEKEY nkey = random(); CACHEKEY nkey = random();
long nval = random(); long nval = random();
//printf("n_keys=%d Insert %08llx\n", n_keys, nkey); //printf("n_keys=%d Insert %08llx\n", n_keys, nkey);
r = cachetable_put(f, nkey, (void*)nval, 1, r = toku_cachetable_put(f, nkey, (void*)nval, 1,
r_flush, r_fetch, 0); r_flush, r_fetch, 0);
assert(r==0); assert(r==0);
assert(n_keys<KEYLIMIT); assert(n_keys<KEYLIMIT);
keys[n_keys] = nkey; keys[n_keys] = nkey;
vals[n_keys] = (void*)nval; vals[n_keys] = (void*)nval;
n_keys++; n_keys++;
r = cachetable_unpin(f, nkey, CACHETABLE_DIRTY, 1); r = toku_cachetable_unpin(f, nkey, CACHETABLE_DIRTY, 1);
assert(r==0); assert(r==0);
} else if (ra==2 && n_keys>0) { } else if (ra==2 && n_keys>0) {
// Rename something // Rename something
...@@ -594,17 +594,17 @@ void test_rename (void) { ...@@ -594,17 +594,17 @@ void test_rename (void) {
long current_size; long current_size;
keys[objnum]=nkey; keys[objnum]=nkey;
//printf("Rename %llx to %llx\n", okey, nkey); //printf("Rename %llx to %llx\n", okey, nkey);
r = cachetable_get_and_pin(f, okey, &current_value, &current_size, r_flush, r_fetch, 0); r = toku_cachetable_get_and_pin(f, okey, &current_value, &current_size, r_flush, r_fetch, 0);
assert(r==0); assert(r==0);
r = cachetable_rename(f, okey, nkey); r = toku_cachetable_rename(f, okey, nkey);
assert(r==0); assert(r==0);
r = cachetable_unpin(f, nkey, CACHETABLE_DIRTY, 1); r = toku_cachetable_unpin(f, nkey, CACHETABLE_DIRTY, 1);
} }
} }
r = cachefile_close(&f); r = toku_cachefile_close(&f);
assert(r == 0); assert(r == 0);
r = cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
assert(n_keys == 0); assert(n_keys == 0);
......
...@@ -67,7 +67,7 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)), ...@@ -67,7 +67,7 @@ static void flush_forchain (CACHEFILE f __attribute__((__unused__)),
LSN modified_lsn __attribute__((__unused__)), LSN modified_lsn __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))) { BOOL rename_p __attribute__((__unused__))) {
int *v = value; int *v = value;
//cachetable_print_state(ct); //toku_cachetable_print_state(ct);
//printf("Flush %lld %d\n", key, (int)value); //printf("Flush %lld %d\n", key, (int)value);
assert((long)v==(long)key); assert((long)v==(long)key);
item_becomes_not_present(f, key); item_becomes_not_present(f, key);
...@@ -86,10 +86,10 @@ void verify_cachetable_against_present (void) { ...@@ -86,10 +86,10 @@ void verify_cachetable_against_present (void) {
for (i=0; i<n_present; i++) { for (i=0; i<n_present; i++) {
void *v; void *v;
int r; int r;
assert(cachetable_maybe_get_and_pin(present_items[i].cf, assert(toku_cachetable_maybe_get_and_pin(present_items[i].cf,
present_items[i].key, present_items[i].key,
&v)==0); &v)==0);
r = cachetable_unpin(present_items[i].cf, present_items[i].key, CACHETABLE_CLEAN, test_object_size); r = toku_cachetable_unpin(present_items[i].cf, present_items[i].key, CACHETABLE_CLEAN, test_object_size);
} }
} }
...@@ -101,19 +101,19 @@ void test_chaining (void) { ...@@ -101,19 +101,19 @@ void test_chaining (void) {
char fname[N_FILES][FILENAME_LEN]; char fname[N_FILES][FILENAME_LEN];
int r; int r;
long i, trial; long i, trial;
r = create_cachetable(&ct, N_PRESENT_LIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_create_cachetable(&ct, N_PRESENT_LIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<N_FILES; i++) { for (i=0; i<N_FILES; i++) {
r = snprintf(fname[i], FILENAME_LEN, "cachetabletest2.%ld.dat", i); r = snprintf(fname[i], FILENAME_LEN, "cachetabletest2.%ld.dat", i);
assert(r>0 && r<FILENAME_LEN); assert(r>0 && r<FILENAME_LEN);
unlink(fname[i]); unlink(fname[i]);
r = cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, 0777); assert(r==0); r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, 0777); assert(r==0);
} }
for (i=0; i<N_PRESENT_LIMIT; i++) { for (i=0; i<N_PRESENT_LIMIT; i++) {
int fnum = i%N_FILES; int fnum = i%N_FILES;
//printf("%s:%d Add %d\n", __FILE__, __LINE__, i); //printf("%s:%d Add %d\n", __FILE__, __LINE__, i);
r = cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0); r = toku_cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0);
item_becomes_present(f[fnum], i); item_becomes_present(f[fnum], i);
r = cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0); r = toku_cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0);
//print_ints(); //print_ints();
} }
for (trial=0; trial<TRIALS; trial++) { for (trial=0; trial<TRIALS; trial++) {
...@@ -122,18 +122,18 @@ void test_chaining (void) { ...@@ -122,18 +122,18 @@ void test_chaining (void) {
int whichone = random()%n_present; int whichone = random()%n_present;
void *value; void *value;
//printf("Touching %d (%lld, %p)\n", whichone, present_items[whichone].key, present_items[whichone].cf); //printf("Touching %d (%lld, %p)\n", whichone, present_items[whichone].key, present_items[whichone].cf);
r = cachetable_get_and_pin(present_items[whichone].cf, r = toku_cachetable_get_and_pin(present_items[whichone].cf,
present_items[whichone].key, present_items[whichone].key,
&value, &value,
NULL, NULL,
flush_forchain, flush_forchain,
fetch_forchain, fetch_forchain,
(void*)(long)present_items[whichone].key (void*)(long)present_items[whichone].key
); );
assert(r==0); assert(r==0);
r = cachetable_unpin(present_items[whichone].cf, r = toku_cachetable_unpin(present_items[whichone].cf,
present_items[whichone].key, present_items[whichone].key,
CACHETABLE_CLEAN, test_object_size); CACHETABLE_CLEAN, test_object_size);
assert(r==0); assert(r==0);
} }
...@@ -141,11 +141,11 @@ void test_chaining (void) { ...@@ -141,11 +141,11 @@ void test_chaining (void) {
int fnum = i%N_FILES; int fnum = i%N_FILES;
// i is always incrementing, so we need not worry about inserting a duplicate // i is always incrementing, so we need not worry about inserting a duplicate
//printf("%s:%d Add {%d,%p}\n", __FILE__, __LINE__, i, f[fnum]); //printf("%s:%d Add {%d,%p}\n", __FILE__, __LINE__, i, f[fnum]);
r = cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0); r = toku_cachetable_put(f[fnum], i, (void*)i, test_object_size, flush_forchain, fetch_forchain, (void*)i); assert(r==0);
item_becomes_present(f[fnum], i); item_becomes_present(f[fnum], i);
//print_ints(); //print_ints();
//cachetable_print_state(ct); //cachetable_print_state(ct);
r = cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0); r = toku_cachetable_unpin(f[fnum], i, CACHETABLE_CLEAN, test_object_size); assert(r==0);
verify_cachetable_against_present(); verify_cachetable_against_present();
if (random()%10==0) { if (random()%10==0) {
...@@ -153,15 +153,15 @@ void test_chaining (void) { ...@@ -153,15 +153,15 @@ void test_chaining (void) {
//printf("Close %d (%p), now n_present=%d\n", i, f[i], n_present); //printf("Close %d (%p), now n_present=%d\n", i, f[i], n_present);
//print_ints(); //print_ints();
CACHEFILE oldcf=f[i]; CACHEFILE oldcf=f[i];
r = cachefile_close(&f[i]); assert(r==0); r = toku_cachefile_close(&f[i]); assert(r==0);
file_is_not_present(oldcf); file_is_not_present(oldcf);
r = cachetable_openf(&f[i], ct, fname[i], O_RDWR, 0777); assert(r==0); r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR, 0777); assert(r==0);
} }
} }
for (i=0; i<N_FILES; i++) { for (i=0; i<N_FILES; i++) {
r = cachefile_close(&f[i]); assert(r==0); r = toku_cachefile_close(&f[i]); assert(r==0);
} }
r = cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
......
...@@ -65,7 +65,7 @@ struct cachefile { ...@@ -65,7 +65,7 @@ struct cachefile {
FILENUM filenum; FILENUM filenum;
}; };
int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER logger) { int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER logger) {
TAGMALLOC(CACHETABLE, t); TAGMALLOC(CACHETABLE, t);
int i; int i;
t->n_in_table = 0; t->n_in_table = 0;
...@@ -86,7 +86,7 @@ int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKU ...@@ -86,7 +86,7 @@ int create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKU
return 0; return 0;
} }
static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) { int toku_cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) {
int r; int r;
CACHEFILE extant; CACHEFILE extant;
struct stat statbuf; struct stat statbuf;
...@@ -118,13 +118,13 @@ static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) { ...@@ -118,13 +118,13 @@ static int cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) {
} }
} }
int cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) { int toku_cachetable_openf (CACHEFILE *cf, CACHETABLE t, const char *fname, int flags, mode_t mode) {
int fd = open(fname, flags, mode); int fd = open(fname, flags, mode);
if (fd<0) return errno; if (fd<0) return errno;
return cachetable_openfd (cf, t, fd); return toku_cachetable_openfd (cf, t, fd);
} }
CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) { static CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) {
if (list==0) return 0; if (list==0) return 0;
else if (list==cf) { else if (list==cf) {
return list->next; return list->next;
...@@ -136,7 +136,7 @@ CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) { ...@@ -136,7 +136,7 @@ CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) {
static int cachefile_flush_and_remove (CACHEFILE cf); static int cachefile_flush_and_remove (CACHEFILE cf);
int cachefile_close (CACHEFILE *cfp) { int toku_cachefile_close (CACHEFILE *cfp) {
CACHEFILE cf = *cfp; CACHEFILE cf = *cfp;
assert(cf->refcount>0); assert(cf->refcount>0);
cf->refcount--; cf->refcount--;
...@@ -156,7 +156,7 @@ int cachefile_close (CACHEFILE *cfp) { ...@@ -156,7 +156,7 @@ int cachefile_close (CACHEFILE *cfp) {
} }
} }
int cachetable_assert_all_unpinned (CACHETABLE t) { int toku_cachetable_assert_all_unpinned (CACHETABLE t) {
int i; int i;
int some_pinned=0; int some_pinned=0;
for (i=0; i<t->table_size; i++) { for (i=0; i<t->table_size; i++) {
...@@ -172,7 +172,7 @@ int cachetable_assert_all_unpinned (CACHETABLE t) { ...@@ -172,7 +172,7 @@ int cachetable_assert_all_unpinned (CACHETABLE t) {
return some_pinned; return some_pinned;
} }
int cachefile_count_pinned (CACHEFILE cf, int print_them) { int toku_cachefile_count_pinned (CACHEFILE cf, int print_them) {
int i; int i;
int n_pinned=0; int n_pinned=0;
CACHETABLE t = cf->cachetable; CACHETABLE t = cf->cachetable;
...@@ -189,11 +189,13 @@ int cachefile_count_pinned (CACHEFILE cf, int print_them) { ...@@ -189,11 +189,13 @@ int cachefile_count_pinned (CACHEFILE cf, int print_them) {
return n_pinned; return n_pinned;
} }
#if 0
unsigned int ct_hash_longlong (unsigned long long l) { unsigned int ct_hash_longlong (unsigned long long l) {
unsigned int r = hash_key((unsigned char*)&l, 8); unsigned int r = hash_key((unsigned char*)&l, 8);
printf("%lld --> %d --> %d\n", l, r, r%64); printf("%lld --> %d --> %d\n", l, r, r%64);
return r; return r;
} }
#endif
static unsigned int hashit (CACHETABLE t, CACHEKEY key) { static unsigned int hashit (CACHETABLE t, CACHEKEY key) {
return hash_key((unsigned char*)&key, sizeof(key))%t->table_size; return hash_key((unsigned char*)&key, sizeof(key))%t->table_size;
...@@ -353,7 +355,7 @@ static int cachetable_insert_at(CACHEFILE cachefile, int h, CACHEKEY key, void * ...@@ -353,7 +355,7 @@ static int cachetable_insert_at(CACHEFILE cachefile, int h, CACHEKEY key, void *
return 0; return 0;
} }
int cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size, int toku_cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) { cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) {
WHEN_TRACE_CT(printf("%s:%d CT cachetable_put(%lld)=%p\n", __FILE__, __LINE__, key, value)); WHEN_TRACE_CT(printf("%s:%d CT cachetable_put(%lld)=%p\n", __FILE__, __LINE__, key, value));
{ {
...@@ -375,7 +377,7 @@ int cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size, ...@@ -375,7 +377,7 @@ int cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size,
return r; return r;
} }
int cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long *sizep, int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long *sizep,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) { cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
int tsize __attribute__((__unused__)) = t->table_size; int tsize __attribute__((__unused__)) = t->table_size;
...@@ -410,7 +412,7 @@ int cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long ...@@ -410,7 +412,7 @@ int cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value, long
return 0; return 0;
} }
int cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value) { int toku_cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR p; PAIR p;
for (p=t->table[hashit(t,key)]; p; p=p->hash_chain) { for (p=t->table[hashit(t,key)]; p; p=p->hash_chain) {
...@@ -426,7 +428,7 @@ int cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value ...@@ -426,7 +428,7 @@ int cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, void**value
} }
int cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) { int toku_cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR p; PAIR p;
WHEN_TRACE_CT(printf("%s:%d unpin(%lld)", __FILE__, __LINE__, key)); WHEN_TRACE_CT(printf("%s:%d unpin(%lld)", __FILE__, __LINE__, key));
...@@ -450,7 +452,7 @@ int cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) { ...@@ -450,7 +452,7 @@ int cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, int dirty, long size) {
// effect: Move an object from one key to another key. // effect: Move an object from one key to another key.
// requires: The object is pinned in the table // requires: The object is pinned in the table
int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) { int toku_cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) {
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR *ptr_to_p,p; PAIR *ptr_to_p,p;
for (ptr_to_p = &t->table[hashit(t, oldkey)], p = *ptr_to_p; for (ptr_to_p = &t->table[hashit(t, oldkey)], p = *ptr_to_p;
...@@ -468,7 +470,7 @@ int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) { ...@@ -468,7 +470,7 @@ int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey) {
return -1; return -1;
} }
int cachetable_flush (CACHETABLE t) { static int cachetable_flush (CACHETABLE t) {
int i; int i;
for (i=0; i<t->table_size; i++) { for (i=0; i<t->table_size; i++) {
PAIR p; PAIR p;
...@@ -478,11 +480,11 @@ int cachetable_flush (CACHETABLE t) { ...@@ -478,11 +480,11 @@ int cachetable_flush (CACHETABLE t) {
return 0; return 0;
} }
void cachefile_verify (CACHEFILE cf) { void toku_cachefile_verify (CACHEFILE cf) {
cachetable_verify(cf->cachetable); toku_cachetable_verify(cf->cachetable);
} }
void cachetable_verify (CACHETABLE t) { void toku_cachetable_verify (CACHETABLE t) {
// First clear all the verify flags by going through the hash chains // First clear all the verify flags by going through the hash chains
{ {
int i; int i;
...@@ -569,7 +571,7 @@ static int cachefile_flush_and_remove (CACHEFILE cf) { ...@@ -569,7 +571,7 @@ static int cachefile_flush_and_remove (CACHEFILE cf) {
} }
/* Require that it all be flushed. */ /* Require that it all be flushed. */
int cachetable_close (CACHETABLE *tp) { int toku_cachetable_close (CACHETABLE *tp) {
CACHETABLE t=*tp; CACHETABLE t=*tp;
int i; int i;
int r; int r;
...@@ -583,7 +585,7 @@ int cachetable_close (CACHETABLE *tp) { ...@@ -583,7 +585,7 @@ int cachetable_close (CACHETABLE *tp) {
return 0; return 0;
} }
int cachetable_remove (CACHEFILE cachefile, CACHEKEY key, int write_me) { int toku_cachetable_remove (CACHEFILE cachefile, CACHEKEY key, int write_me) {
/* Removing something already present is OK. */ /* Removing something already present is OK. */
CACHETABLE t = cachefile->cachetable; CACHETABLE t = cachefile->cachetable;
PAIR p; PAIR p;
...@@ -644,13 +646,13 @@ int cachefile_pread (CACHEFILE cf, void *buf, size_t count, off_t offset) { ...@@ -644,13 +646,13 @@ int cachefile_pread (CACHEFILE cf, void *buf, size_t count, off_t offset) {
} }
#endif #endif
int cachefile_fd (CACHEFILE cf) { int toku_cachefile_fd (CACHEFILE cf) {
return cf->fd; return cf->fd;
} }
/* debug functions */ /* debug functions */
void cachetable_print_state (CACHETABLE ct) { void toku_cachetable_print_state (CACHETABLE ct) {
int i; int i;
for (i=0; i<ct->table_size; i++) { for (i=0; i<ct->table_size; i++) {
PAIR p = ct->table[i]; PAIR p = ct->table[i];
...@@ -664,7 +666,7 @@ int cachefile_fd (CACHEFILE cf) { ...@@ -664,7 +666,7 @@ int cachefile_fd (CACHEFILE cf) {
} }
} }
void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr) { void toku_cachetable_get_state (CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr) {
if (num_entries_ptr) if (num_entries_ptr)
*num_entries_ptr = ct->n_in_table; *num_entries_ptr = ct->n_in_table;
if (hash_size_ptr) if (hash_size_ptr)
...@@ -675,8 +677,8 @@ void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_pt ...@@ -675,8 +677,8 @@ void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_pt
*size_limit_ptr = ct->size_limit; *size_limit_ptr = ct->size_limit;
} }
int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr, int toku_cachetable_get_key_state (CACHETABLE ct, CACHEKEY key, void **value_ptr,
int *dirty_ptr, long long *pin_ptr, long *size_ptr) { int *dirty_ptr, long long *pin_ptr, long *size_ptr) {
PAIR p; PAIR p;
for (p = ct->table[hashit(ct, key)]; p; p = p->hash_chain) { for (p = ct->table[hashit(ct, key)]; p; p = p->hash_chain) {
if (p->key == key) { if (p->key == key) {
...@@ -694,7 +696,7 @@ int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr, ...@@ -694,7 +696,7 @@ int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr,
return 1; return 1;
} }
int cachetable_checkpoint (CACHETABLE ct) { int toku_cachetable_checkpoint (CACHETABLE ct) {
// Single threaded checkpoint. // Single threaded checkpoint.
// In future: for multithreaded checkpoint we should not proceed if the previous checkpoint has not finished. // In future: for multithreaded checkpoint we should not proceed if the previous checkpoint has not finished.
// Requires: Everything is unpinned. (In the multithreaded version we have to wait for things to get unpinned and then // Requires: Everything is unpinned. (In the multithreaded version we have to wait for things to get unpinned and then
...@@ -737,10 +739,10 @@ int cachetable_checkpoint (CACHETABLE ct) { ...@@ -737,10 +739,10 @@ int cachetable_checkpoint (CACHETABLE ct) {
return 0; return 0;
} }
TOKULOGGER cachefile_logger (CACHEFILE cf) { TOKULOGGER toku_cachefile_logger (CACHEFILE cf) {
return cf->cachetable->logger; return cf->cachetable->logger;
} }
FILENUM cachefile_filenum (CACHEFILE cf) { FILENUM toku_cachefile_filenum (CACHEFILE cf) {
return cf->filenum; return cf->filenum;
} }
...@@ -23,9 +23,10 @@ typedef struct cachefile *CACHEFILE; ...@@ -23,9 +23,10 @@ typedef struct cachefile *CACHEFILE;
* table_size is the initial size of the cache table hash table (in number of entries) * table_size is the initial size of the cache table hash table (in number of entries)
* size limit is the upper bound of the sum of size of the entries in the cache table (total number of bytes) * size limit is the upper bound of the sum of size of the entries in the cache table (total number of bytes)
*/ */
int create_cachetable(CACHETABLE */*result*/, long size_limit, LSN initial_lsn, TOKULOGGER); int toku_create_cachetable(CACHETABLE */*result*/, long size_limit, LSN initial_lsn, TOKULOGGER);
int cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname*/, int flags, mode_t mode); int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname*/, int flags, mode_t mode);
int toku_cachetable_openfd (CACHEFILE *,CACHETABLE, int /*fd*/);
typedef void (cachetable_flush_func_t)(CACHEFILE, CACHEKEY key, void*value, long size, BOOL write_me, BOOL keep_me, LSN modified_lsn, BOOL rename_p); typedef void (cachetable_flush_func_t)(CACHEFILE, CACHEKEY key, void*value, long size, BOOL write_me, BOOL keep_me, LSN modified_lsn, BOOL rename_p);
typedef cachetable_flush_func_t *CACHETABLE_FLUSH_FUNC_T; typedef cachetable_flush_func_t *CACHETABLE_FLUSH_FUNC_T;
...@@ -35,50 +36,50 @@ typedef int (cachetable_fetch_func_t)(CACHEFILE, CACHEKEY key, void **value, lon ...@@ -35,50 +36,50 @@ typedef int (cachetable_fetch_func_t)(CACHEFILE, CACHEKEY key, void **value, lon
typedef cachetable_fetch_func_t *CACHETABLE_FETCH_FUNC_T; typedef cachetable_fetch_func_t *CACHETABLE_FETCH_FUNC_T;
/* Error if already present. On success, pin the value. */ /* Error if already present. On success, pin the value. */
int cachetable_put(CACHEFILE cf, CACHEKEY key, void* value, long size, int toku_cachetable_put(CACHEFILE cf, CACHEKEY key, void* value, long size,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs); cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs);
int cachetable_get_and_pin(CACHEFILE, CACHEKEY, void**/*value*/, long *sizep, int toku_cachetable_get_and_pin(CACHEFILE, CACHEKEY, void**/*value*/, long *sizep,
cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs); cachetable_flush_func_t flush_callback, cachetable_fetch_func_t fetch_callback, void *extraargs);
/* If the the item is already in memory, then return 0 and store it in the void**. /* If the the item is already in memory, then return 0 and store it in the void**.
* If the item is not in memory, then return nonzero. */ * If the item is not in memory, then return nonzero. */
int cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, void**); int toku_cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, void**);
/* cachetable object state wrt external memory */ /* cachetable object state wrt external memory */
#define CACHETABLE_CLEAN 0 #define CACHETABLE_CLEAN 0
#define CACHETABLE_DIRTY 1 #define CACHETABLE_DIRTY 1
int cachetable_unpin(CACHEFILE, CACHEKEY, int dirty, long size); /* Note whether it is dirty when we unpin it. */ int toku_cachetable_unpin(CACHEFILE, CACHEKEY, int dirty, long size); /* Note whether it is dirty when we unpin it. */
int cachetable_remove (CACHEFILE, CACHEKEY, int /*write_me*/); /* Removing something already present is OK. */ int toku_cachetable_remove (CACHEFILE, CACHEKEY, int /*write_me*/); /* Removing something already present is OK. */
int cachetable_assert_all_unpinned (CACHETABLE); int toku_cachetable_assert_all_unpinned (CACHETABLE);
int cachefile_count_pinned (CACHEFILE, int /*printthem*/ ); int toku_cachefile_count_pinned (CACHEFILE, int /*printthem*/ );
/* Rename whatever is at oldkey to be newkey. Requires that the object be pinned. */ /* Rename whatever is at oldkey to be newkey. Requires that the object be pinned. */
int cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey); int toku_cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newkey);
//int cachetable_fsync_all (CACHETABLE); /* Flush everything to disk, but keep it in cache. */ //int cachetable_fsync_all (CACHETABLE); /* Flush everything to disk, but keep it in cache. */
int cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */ int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */
int cachefile_close (CACHEFILE*); int toku_cachefile_close (CACHEFILE*);
//int cachefile_flush (CACHEFILE); /* Flush everything related to the VOID* to disk and free all memory. Don't destroy the cachetable. */ //int cachefile_flush (CACHEFILE); /* Flush everything related to the VOID* to disk and free all memory. Don't destroy the cachetable. */
// Return on success (different from pread and pwrite) // Return on success (different from pread and pwrite)
//int cachefile_pwrite (CACHEFILE, const void *buf, size_t count, off_t offset); //int cachefile_pwrite (CACHEFILE, const void *buf, size_t count, off_t offset);
//int cachefile_pread (CACHEFILE, void *buf, size_t count, off_t offset); //int cachefile_pread (CACHEFILE, void *buf, size_t count, off_t offset);
int cachefile_fd (CACHEFILE); int toku_cachefile_fd (CACHEFILE);
// Useful for debugging // Useful for debugging
void cachetable_print_state (CACHETABLE ct); void toku_cachetable_print_state (CACHETABLE ct);
void cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr); void toku_cachetable_get_state(CACHETABLE ct, int *num_entries_ptr, int *hash_size_ptr, long *size_current_ptr, long *size_limit_ptr);
int cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr, int toku_cachetable_get_key_state(CACHETABLE ct, CACHEKEY key, void **value_ptr,
int *dirty_ptr, long long *pin_ptr, long *size_ptr); int *dirty_ptr, long long *pin_ptr, long *size_ptr);
void cachefile_verify (CACHEFILE cf); // Verify the whole cachetable that the CF is in. Slow. void toku_cachefile_verify (CACHEFILE cf); // Verify the whole cachetable that the CF is in. Slow.
void cachetable_verify (CACHETABLE t); // Slow... void toku_cachetable_verify (CACHETABLE t); // Slow...
TOKULOGGER cachefile_logger (CACHEFILE); TOKULOGGER toku_cachefile_logger (CACHEFILE);
FILENUM cachefile_filenum (CACHEFILE); FILENUM toku_cachefile_filenum (CACHEFILE);
#endif #endif
...@@ -21,10 +21,10 @@ int tokulogger_find_next_unused_log_file(const char *directory, long long *resul ...@@ -21,10 +21,10 @@ int tokulogger_find_next_unused_log_file(const char *directory, long long *resul
enum { enum {
LT_COMMIT = 'C', LT_COMMIT = 'C',
LT_DELETE = 'D', LT_DELETE = 'D',
LT_FCREATE = 'F',
LT_INSERT_WITH_NO_OVERWRITE = 'I', LT_INSERT_WITH_NO_OVERWRITE = 'I',
LT_CHECKPOINT = 'P', LT_CHECKPOINT = 'P',
LT_BLOCK_RENAME = 'R', LT_BLOCK_RENAME = 'R',
LT_FCREATE_TMP = 'T',
LT_UNLINK = 'U' LT_UNLINK = 'U'
}; };
......
...@@ -263,7 +263,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd ...@@ -263,7 +263,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd
return tokulogger_finish(logger, &wbuf); return tokulogger_finish(logger, &wbuf);
} }
int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) { int tokulogger_log_fcreate (TOKUTXN txn, const char *fname, int mode) {
if (txn==0) return 0; if (txn==0) return 0;
const int fnamelen = strlen(fname); const int fnamelen = strlen(fname);
const int buflen = (+1 // log command const int buflen = (+1 // log command
...@@ -275,7 +275,7 @@ int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) { ...@@ -275,7 +275,7 @@ int tokulogger_log_fcreate_tmp (TOKUTXN txn, const char *fname, int mode) {
unsigned char buf[buflen]; unsigned char buf[buflen];
struct wbuf wbuf; struct wbuf wbuf;
wbuf_init (&wbuf, buf, buflen); wbuf_init (&wbuf, buf, buflen);
wbuf_char (&wbuf, LT_FCREATE_TMP); wbuf_char (&wbuf, LT_FCREATE);
wbuf_bytes(&wbuf, fname, fnamelen); wbuf_bytes(&wbuf, fname, fnamelen);
wbuf_int (&wbuf, mode); wbuf_int (&wbuf, mode);
return tokulogger_finish(txn->logger, &wbuf); return tokulogger_finish(txn->logger, &wbuf);
......
...@@ -16,7 +16,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd ...@@ -16,7 +16,7 @@ int tokulogger_log_block_rename (TOKULOGGER logger, FILENUM fileid, DISKOFF oldd
int tokutxn_begin (TOKUTXN /*parent*/,TOKUTXN *, TXNID txnid64, TOKULOGGER logger); int tokutxn_begin (TOKUTXN /*parent*/,TOKUTXN *, TXNID txnid64, TOKULOGGER logger);
int tokulogger_log_fcreate_tmp (TOKUTXN, const char */*fname*/, int /*mode*/); int tokulogger_log_fcreate (TOKUTXN, const char */*fname*/, int /*mode*/);
int tokulogger_log_unlink (TOKUTXN, const char */*fname*/); int tokulogger_log_unlink (TOKUTXN, const char */*fname*/);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment