Commit 6d1565ea authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4456], merge to main

git-svn-id: file:///svn/toku/tokudb@39504 c7de825b-a66e-492c-adef-691d508d4ae1
parent a8089e75
......@@ -8,7 +8,6 @@
#include <brttypes.h>
#include <brt-flusher.h>
#include <brt-internal.h>
#include <cachetable.h>
static void
brtnode_get_key_and_fullhash(
......@@ -49,11 +48,7 @@ cachetable_put_empty_node_with_dep_nodes(
brtnode_get_key_and_fullhash,
new_node,
make_pair_attr(sizeof(BRTNODE)),
toku_brtnode_flush_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_cleaner_callback,
h,
get_write_callbacks_for_node(h),
h,
num_dependent_nodes,
dependent_cf,
......@@ -142,15 +137,11 @@ toku_pin_brtnode(
fullhash,
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
bfe, //read_extraargs
brt->h, //write_extraargs
unlockers);
if (r==0) {
BRTNODE node = node_v;
......@@ -184,15 +175,11 @@ toku_pin_brtnode_holding_lock(
fullhash,
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
bfe,
brt->h
bfe
);
assert(r==0);
BRTNODE node = node_v;
......@@ -228,15 +215,11 @@ toku_pin_brtnode_off_client_thread(
fullhash,
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
bfe,
h,
num_dependent_nodes,
dependent_cf,
dependent_keys,
......
......@@ -8,6 +8,7 @@
#include <c_dialects.h>
#include <brttypes.h>
#include "cachetable.h"
C_BEGIN
......
......@@ -65,22 +65,6 @@ toku_flusher_thread_set_callback(
void* extra
);
/**
* Brings the node into memory and flushes the fullest buffer. If the
* heaviest child is empty, does nothing, otherwise, executes
* flush_some_child to do the flush.
*
* Wrapped by toku_brtnode_cleaner_callback to provide access to
* brt_status which currently just lives in brt.c.
*/
int
toku_brtnode_cleaner_callback(
void *brtnode_pv,
BLOCKNUM blocknum,
u_int32_t fullhash,
void *extraargs
);
/**
* Puts a workitem on the flusher thread queue, scheduling the node to be
* flushed by flush_some_child.
......
......@@ -532,10 +532,21 @@ extern void toku_brtnode_pe_est_callback(void* brtnode_pv, long* bytes_freed_est
extern int toku_brtnode_pe_callback (void *brtnode_pv, PAIR_ATTR old_attr, PAIR_ATTR* new_attr, void *extraargs);
extern BOOL toku_brtnode_pf_req_callback(void* brtnode_pv, void* read_extraargs);
int toku_brtnode_pf_callback(void* brtnode_pv, void* read_extraargs, int fd, PAIR_ATTR* sizep);
extern int toku_brtnode_cleaner_callback( void *brtnode_pv, BLOCKNUM blocknum, u_int32_t fullhash, void *extraargs);
extern int toku_brt_alloc_init_header(BRT t, TOKUTXN txn);
extern int toku_read_brt_header_and_store_in_cachefile (BRT brt, CACHEFILE cf, LSN max_acceptable_lsn, struct brt_header **header, BOOL* was_open);
extern CACHEKEY* toku_calculate_root_offset_pointer (struct brt_header* h, u_int32_t *root_hash);
static inline CACHETABLE_WRITE_CALLBACK get_write_callbacks_for_node(struct brt_header* h) {
CACHETABLE_WRITE_CALLBACK wc;
wc.flush_callback = toku_brtnode_flush_callback;
wc.pe_est_callback = toku_brtnode_pe_est_callback;
wc.pe_callback = toku_brtnode_pe_callback;
wc.cleaner_callback = toku_brtnode_cleaner_callback;
wc.write_extraargs = h;
return wc;
}
static const BRTNODE null_brtnode=0;
// How long is the pivot key?
......
......@@ -94,15 +94,11 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on
toku_cachetable_hash(brt->cf, diskoff),
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
&bfe,
brt->h
&bfe
);
assert(r==0);
int size = toku_serialize_brtnode_size(node_v);
......@@ -124,15 +120,11 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
toku_cachetable_hash(brt->cf, blocknum),
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
&bfe,
brt->h
&bfe
);
if (r!=0) return r;
BRTNODE node=node_v;
......@@ -200,15 +192,11 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
toku_cachetable_hash(brt->cf, blocknum),
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
&bfe,
brt->h
&bfe
);
if (r!=0) return r;
BRTNODE node=node_v;
......
......@@ -1298,8 +1298,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r
//printf("%s:%d put %lld\n", __FILE__, __LINE__, newroot_diskoff);
u_int32_t fullhash = toku_cachetable_hash(brt->cf, newroot_diskoff);
newroot->fullhash = fullhash;
toku_cachetable_put(brt->cf, newroot_diskoff, fullhash, newroot, make_brtnode_pair_attr(newroot),
toku_brtnode_flush_callback, toku_brtnode_pe_est_callback, toku_brtnode_pe_callback, toku_brtnode_cleaner_callback, brt->h);
toku_cachetable_put(brt->cf, newroot_diskoff, fullhash, newroot, make_brtnode_pair_attr(newroot), get_write_callbacks_for_node(brt->h));
*newrootp = newroot;
}
......@@ -2915,7 +2914,7 @@ static int setup_initial_brt_root_node (BRT t, BLOCKNUM blocknum) {
node->fullhash = fullhash;
int r = toku_cachetable_put(t->cf, blocknum, fullhash,
node, make_brtnode_pair_attr(node),
toku_brtnode_flush_callback, toku_brtnode_pe_est_callback, toku_brtnode_pe_callback, toku_brtnode_cleaner_callback, t->h);
get_write_callbacks_for_node(t->h));
if (r != 0)
toku_free(node);
else
......@@ -4999,15 +4998,11 @@ brt_node_maybe_prefetch(BRT brt, BRTNODE node, int childnum, BRT_CURSOR brtcurso
brt->cf,
nextchildblocknum,
nextfullhash,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
brtnode_fetch_callback_and_free_bfe,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
brtnode_pf_callback_and_free_bfe,
toku_brtnode_cleaner_callback,
bfe,
brt->h,
&doing_prefetch
);
if (!doing_prefetch) {
......@@ -6011,15 +6006,11 @@ toku_dump_brtnode (FILE *file, BRT brt, BLOCKNUM blocknum, int depth, struct kv_
fullhash,
&node_v,
NULL,
toku_brtnode_flush_callback,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pe_est_callback,
toku_brtnode_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_brtnode_cleaner_callback,
&bfe,
brt->h
&bfe
);
assert_zero(r);
node=node_v;
......
This diff is collapsed.
......@@ -178,6 +178,14 @@ typedef int (*CACHETABLE_PARTIAL_FETCH_CALLBACK)(void *brtnode_pv, void *read_ex
// TODO(leif) XXX TODO XXX
typedef int (*CACHETABLE_CLEANER_CALLBACK)(void *brtnode_pv, BLOCKNUM blocknum, u_int32_t fullhash, void *write_extraargs);
typedef struct {
CACHETABLE_FLUSH_CALLBACK flush_callback;
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback;
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback;
CACHETABLE_CLEANER_CALLBACK cleaner_callback;
void* write_extraargs; // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
} CACHETABLE_WRITE_CALLBACK;
typedef void (*CACHETABLE_GET_KEY_AND_FULLHASH)(CACHEKEY* cachekey, u_int32_t* fullhash, void* extra);
typedef void (*CACHETABLE_REMOVE_KEY)(CACHEKEY* cachekey, BOOL for_checkpoint, void* extra);
......@@ -210,11 +218,7 @@ int toku_cachetable_put_with_dep_pairs(
CACHETABLE_GET_KEY_AND_FULLHASH get_key_and_fullhash,
void*value,
PAIR_ATTR attr,
CACHETABLE_FLUSH_CALLBACK flush_callback,
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
void *write_extraargs, // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
CACHETABLE_WRITE_CALLBACK write_callback,
void *get_key_and_fullhash_extra,
u_int32_t num_dependent_pairs, // number of dependent pairs that we may need to checkpoint
CACHEFILE* dependent_cfs, // array of cachefiles of dependent pairs
......@@ -234,11 +238,7 @@ int toku_cachetable_put_with_dep_pairs(
// error number.
int toku_cachetable_put(CACHEFILE cf, CACHEKEY key, u_int32_t fullhash,
void *value, PAIR_ATTR size,
CACHETABLE_FLUSH_CALLBACK flush_callback,
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
void *write_extraargs // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
CACHETABLE_WRITE_CALLBACK write_callback
);
......@@ -258,15 +258,11 @@ int toku_cachetable_get_and_pin_with_dep_pairs (
u_int32_t fullhash,
void**value,
long *sizep,
CACHETABLE_FLUSH_CALLBACK flush_callback,
CACHETABLE_WRITE_CALLBACK write_callback,
CACHETABLE_FETCH_CALLBACK fetch_callback,
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback,
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
void* read_extraargs, // parameter for fetch_callback, pf_req_callback, and pf_callback
void* write_extraargs, // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
u_int32_t num_dependent_pairs, // number of dependent pairs that we may need to checkpoint
CACHEFILE* dependent_cfs, // array of cachefiles of dependent pairs
CACHEKEY* dependent_keys, // array of cachekeys of dependent pairs
......@@ -286,15 +282,11 @@ int toku_cachetable_get_and_pin (
u_int32_t fullhash,
void**value,
long *sizep,
CACHETABLE_FLUSH_CALLBACK flush_callback,
CACHETABLE_WRITE_CALLBACK write_callback,
CACHETABLE_FETCH_CALLBACK fetch_callback,
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback __attribute__((unused)),
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback __attribute__((unused)),
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
void* read_extraargs, // parameter for fetch_callback, pf_req_callback, and pf_callback
void* write_extraargs // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback,
void* read_extraargs // parameter for fetch_callback, pf_req_callback, and pf_callback
);
struct unlockers {
......@@ -313,15 +305,11 @@ int toku_cachetable_get_and_pin_nonblocking (
u_int32_t fullhash,
void**value,
long *sizep,
CACHETABLE_FLUSH_CALLBACK flush_callback,
CACHETABLE_WRITE_CALLBACK write_callback,
CACHETABLE_FETCH_CALLBACK fetch_callback,
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback __attribute__((unused)),
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback __attribute__((unused)),
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
void *read_extraargs, // parameter for fetch_callback, pf_req_callback, and pf_callback
void* write_extraargs, // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
UNLOCKERS unlockers
);
......@@ -353,15 +341,11 @@ int toku_cachetable_unpin_and_remove (CACHEFILE, CACHEKEY, CACHETABLE_REMOVE_KEY
// Requires: The object must be pinned exactly once.
int toku_cachefile_prefetch(CACHEFILE cf, CACHEKEY key, u_int32_t fullhash,
CACHETABLE_FLUSH_CALLBACK flush_callback,
CACHETABLE_WRITE_CALLBACK write_callback,
CACHETABLE_FETCH_CALLBACK fetch_callback,
CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK pe_est_callback,
CACHETABLE_PARTIAL_EVICTION_CALLBACK pe_callback,
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback,
CACHETABLE_CLEANER_CALLBACK cleaner_callback,
void *read_extraargs, // parameter for fetch_callback, pf_req_callback, and pf_callback
void *write_extraargs, // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
BOOL *doing_prefetch);
// Effect: Prefetch a memory object for a given key into the cachetable
// Precondition: The cachetable mutex is NOT held.
......
......@@ -578,6 +578,15 @@ static int toku_rollback_cleaner_callback (
return 0;
}
static inline CACHETABLE_WRITE_CALLBACK get_write_callbacks_for_rollback_log(struct brt_header* h) {
CACHETABLE_WRITE_CALLBACK wc;
wc.flush_callback = toku_rollback_flush_callback;
wc.pe_est_callback = toku_rollback_pe_est_callback;
wc.pe_callback = toku_rollback_pe_callback;
wc.cleaner_callback = toku_rollback_cleaner_callback;
wc.write_extraargs = h;
return wc;
}
static int toku_create_new_rollback_log (TOKUTXN txn, BLOCKNUM older, uint32_t older_hash, ROLLBACK_LOG_NODE *result) {
ROLLBACK_LOG_NODE MALLOC(log);
......@@ -605,11 +614,7 @@ static int toku_create_new_rollback_log (TOKUTXN txn, BLOCKNUM older, uint32_t o
*result = log;
r=toku_cachetable_put(cf, log->thislogname, log->thishash,
log, rollback_memory_size(log),
toku_rollback_flush_callback,
toku_rollback_pe_est_callback,
toku_rollback_pe_callback,
toku_rollback_cleaner_callback,
h);
get_write_callbacks_for_rollback_log(h));
assert(r==0);
txn->current_rollback = log->thislogname;
txn->current_rollback_hash = log->thishash;
......@@ -833,14 +838,10 @@ toku_maybe_prefetch_older_rollback_log(TOKUTXN txn, ROLLBACK_LOG_NODE log) {
struct brt_header *h = toku_cachefile_get_userdata(cf);
BOOL doing_prefetch = FALSE;
r = toku_cachefile_prefetch(cf, name, hash,
toku_rollback_flush_callback,
get_write_callbacks_for_rollback_log(h),
toku_rollback_fetch_callback,
toku_rollback_pe_est_callback,
toku_rollback_pe_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_rollback_cleaner_callback,
h,
h,
&doing_prefetch);
assert(r==0);
......@@ -865,14 +866,10 @@ int toku_get_and_pin_rollback_log(TOKUTXN txn, TXNID xid, uint64_t sequence, BLO
struct brt_header *h = toku_cachefile_get_userdata(cf);
r = toku_cachetable_get_and_pin(cf, name, hash,
&log_v, NULL,
toku_rollback_flush_callback,
get_write_callbacks_for_rollback_log(h),
toku_rollback_fetch_callback,
toku_rollback_pe_est_callback,
toku_rollback_pe_callback,
toku_rollback_pf_req_callback,
toku_rollback_pf_callback,
toku_rollback_cleaner_callback,
h,
h
);
assert(r==0);
......
......@@ -5,27 +5,6 @@
CACHETABLE ct;
//
// This test exposed a bug (#3970) caught only by Valgrind.
// freed memory was being accessed by toku_cachetable_unpin_and_remove
//
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
CACHEFILE f1;
static void
......@@ -52,11 +31,11 @@ run_test (void) {
long s1;
long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
for (int i = 0; i < 20; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
}
......@@ -68,12 +47,12 @@ run_test (void) {
// pin 1 and 2
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, &s2, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, &s2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_begin_checkpoint(ct, NULL);
// mark nodes as pending a checkpoint, so that get_and_pin_nonblocking on block 1 will return TOKUDB_TRY_AGAIN
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, NULL);
// now we try to pin 1, and it should get evicted out from under us
struct unlockers foo;
foo.extra = NULL;
......@@ -86,14 +65,10 @@ run_test (void) {
1,
&v1,
&s1,
def_flush,
fetch,
def_pe_est_callback,
def_pe_callback,
def_write_callback(NULL),
def_fetch,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
NULL,
NULL,
&foo
);
......
......@@ -3,39 +3,6 @@
#include "includes.h"
#include "test.h"
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
//usleep (5*1024*1024);
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
CACHEFILE f1;
static void *pin_nonblocking(void *arg) {
......@@ -47,8 +14,7 @@ static void *pin_nonblocking(void *arg) {
toku_cachetable_hash(f1, make_blocknum(1)),
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
NULL,
NULL
);
......@@ -75,8 +41,7 @@ cachetable_test (void) {
toku_cachetable_hash(f1, make_blocknum(1)),
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
NULL
);
toku_pthread_t pin_nonblocking_tid;
......
......@@ -3,39 +3,6 @@
#include "includes.h"
#include "test.h"
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
//usleep (5*1024*1024);
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
CACHEFILE f1;
static void *pin_nonblocking(void *arg) {
......@@ -47,8 +14,7 @@ static void *pin_nonblocking(void *arg) {
toku_cachetable_hash(f1, make_blocknum(1)),
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
NULL,
NULL
);
......@@ -63,8 +29,7 @@ static void *put_same_key(void *arg) {
toku_cachetable_hash(f1,make_blocknum(1)),
NULL,
make_pair_attr(4),
flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback,
NULL
def_write_callback(NULL)
);
assert(r==0);
return arg;
......@@ -97,8 +62,7 @@ cachetable_test (void) {
toku_cachetable_hash(f1, make_blocknum(1)),
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
NULL
);
toku_pthread_t pin_nonblocking_tid;
......
......@@ -37,9 +37,11 @@ cachetable_test (void) {
void* v1;
void* v2;
long s1, s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
// usleep (2*1024*1024);
//r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, def_fetch, def_pe_est_callback, pe_callback, pf_req_callback, pf_callback, NULL);
......
......@@ -82,7 +82,9 @@ do_update (void *UU(ignore))
u_int32_t hi = toku_cachetable_hash(cf, key);
void *vv;
long size;
int r = toku_cachetable_get_and_pin(cf, key, hi, &vv, &size, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
int r = toku_cachetable_get_and_pin(cf, key, hi, &vv, &size, wc, fetch, def_pf_req_callback, def_pf_callback, 0);
//printf("g");
assert(r==0);
assert(size==sizeof(int));
......@@ -131,7 +133,9 @@ static void checkpoint_pending(void) {
CACHEKEY key = make_blocknum(i);
u_int32_t hi = toku_cachetable_hash(cf, key);
values[i] = 42;
r = toku_cachetable_put(cf, key, hi, &values[i], make_pair_attr(sizeof(int)), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_put(cf, key, hi, &values[i], make_pair_attr(sizeof(int)), wc);
assert(r == 0);
r = toku_cachetable_unpin(cf, key, hi, CACHETABLE_DIRTY, make_pair_attr(item_size));
......
......@@ -71,8 +71,11 @@ cachetable_test (void) {
void* v2;
long s1;
long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &dirty_val, &dirty_val);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(&dirty_val);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, &dirty_val);
wc.write_extraargs = NULL;
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
//
// Here is the test, we have two pairs, v1 is dirty, v2 is clean, but both are currently pinned
......
......@@ -70,10 +70,13 @@ cachetable_test (void) {
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
BOOL doing_prefetch = FALSE;
r = toku_cachefile_prefetch(f1, make_blocknum(1), 1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &dirty_val, &dirty_val, &doing_prefetch);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(&dirty_val);
wc.flush_callback = flush;
r = toku_cachefile_prefetch(f1, make_blocknum(1), 1, wc, fetch, def_pf_req_callback, def_pf_callback, &dirty_val, &doing_prefetch);
assert(doing_prefetch);
doing_prefetch = FALSE;
r = toku_cachefile_prefetch(f1, make_blocknum(2), 2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, &doing_prefetch);
wc.write_extraargs = NULL;
r = toku_cachefile_prefetch(f1, make_blocknum(2), 2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL, &doing_prefetch);
assert(doing_prefetch);
//
......
......@@ -61,7 +61,9 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
for (i=0; i<n; i++) {
CACHEKEY key = make_blocknum(i);
u_int32_t hi = toku_cachetable_hash(f1, key);
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
r = toku_cachetable_unpin(f1, key, hi, dirty, make_pair_attr(item_size));
......
......@@ -32,22 +32,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
}
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
BOOL cleaner_called;
static int
......@@ -83,7 +67,10 @@ cachetable_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.cleaner_callback = cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
PAIR_ATTR attr = make_pair_attr(8);
attr.cache_pressure_size = 8;
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, attr);
......
......@@ -32,22 +32,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
}
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
BOOL cleaner_called;
static int
......@@ -83,7 +67,10 @@ cachetable_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.cleaner_callback = cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
PAIR_ATTR attr = make_pair_attr(8);
attr.cache_pressure_size = 8;
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, attr);
......
......@@ -29,22 +29,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
}
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static int
cleaner_callback(
void* UU(brtnode_pv),
......@@ -72,7 +56,10 @@ cachetable_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.cleaner_callback = cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
PAIR_ATTR attr = make_pair_attr(8);
attr.cache_pressure_size = 8;
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, attr);
......
......@@ -76,16 +76,16 @@ run_test (void) {
long ss[n_pairs];
//long s2;
PAIR_ATTR expect = { .size = 0, .nonleaf_size = 0, .leaf_size = 0, .rollback_size = 0, .cache_pressure_size = 0 };
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.write_extraargs = &expect;
for (int i = 0; i < n_pairs; ++i) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
NULL, &expect);
&expect);
assert_zero(r);
r = toku_cachetable_unpin(f1, make_blocknum(i+1), i+1, CACHETABLE_DIRTY, attrs[i]);
assert_zero(r);
......@@ -105,14 +105,11 @@ run_test (void) {
void *big_v;
long big_s;
r = toku_cachetable_get_and_pin(f1, make_blocknum(n_pairs + 1), n_pairs + 1, &big_v, &big_s,
flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
NULL, &expect);
&expect);
toku_cachetable_unpin(f1, make_blocknum(n_pairs + 1), n_pairs + 1, CACHETABLE_CLEAN,
make_pair_attr(test_limit - expect.size + 20));
......
......@@ -8,7 +8,7 @@
// everything is pinned.
//
static UU() int
static int
everything_pinned_cleaner_callback(
void* UU(brtnode_pv),
BLOCKNUM UU(blocknum),
......@@ -40,15 +40,14 @@ run_test (void) {
long ss[8];
//long s2;
for (int i = 0; i < 8; ++i) {
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.cleaner_callback = everything_pinned_cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
def_flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
everything_pinned_cleaner_callback,
NULL, NULL);
NULL);
assert_zero(r);
}
......
......@@ -38,15 +38,14 @@ run_test (void) {
long ss[8];
//long s2;
for (int i = 0; i < 8; ++i) {
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.cleaner_callback = everything_pinned_cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
def_flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
everything_pinned_cleaner_callback,
NULL, NULL);
NULL);
assert_zero(r);
// set cachepressure_size to 0
PAIR_ATTR attr = make_pair_attr(8);
......
......@@ -11,7 +11,7 @@
CACHEFILE f1;
bool my_cleaner_callback_called;
static UU() int
static int
my_cleaner_callback(
void* UU(brtnode_pv),
BLOCKNUM UU(blocknum),
......@@ -45,29 +45,25 @@ run_test (void) {
//void* v2;
long ss[5];
//long s2;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.cleaner_callback = my_cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(100), 100, &vs[4], &ss[4],
def_flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
my_cleaner_callback,
NULL, NULL);
NULL);
PAIR_ATTR attr = make_pair_attr(8);
attr.cache_pressure_size = 100;
r = toku_cachetable_unpin(f1, make_blocknum(100), 100, CACHETABLE_CLEAN, attr);
for (int i = 0; i < 4; ++i) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
def_flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
NULL, NULL);
NULL);
assert_zero(r);
// set cachepressure_size to 0
attr = make_pair_attr(8);
......
......@@ -4,23 +4,6 @@
#include "test.h"
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
}
static void
cachetable_test (void) {
int num_entries = 100;
......@@ -34,14 +17,15 @@ cachetable_test (void) {
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// test that putting something too big in the cachetable works fine
r = toku_cachetable_put(f1, make_blocknum(num_entries+1), num_entries+1, NULL, make_pair_attr(test_limit*2), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(num_entries+1), num_entries+1, NULL, make_pair_attr(test_limit*2), wc);
assert(r==0);
r = toku_cachetable_unpin(f1, make_blocknum(num_entries+1), num_entries+1, CACHETABLE_DIRTY, make_pair_attr(test_limit*2));
assert(r==0);
for (int64_t i = 0; i < num_entries; i++) {
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), wc);
assert(toku_cachefile_count_pinned(f1, 0) == (i+1));
}
for (int64_t i = 0; i < num_entries; i++) {
......
......@@ -63,25 +63,27 @@ cachetable_test (void) {
long s1, s2;
flush_may_occur = FALSE;
check_flush = TRUE;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
for (int i = 0; i < 100000; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
}
for (int i = 0; i < 8; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(1));
}
for (int i = 0; i < 4; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(1));
}
for (int i = 0; i < 2; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(1));
}
flush_may_occur = TRUE;
expected_flushed_key = 4;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc);
flush_may_occur = TRUE;
expected_flushed_key = 5;
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
......
......@@ -100,24 +100,39 @@ cachetable_test (void) {
long s1, s2;
flush_may_occur = FALSE;
for (int i = 0; i < 100000; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(4));
}
for (int i = 0; i < 8; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(4));
}
for (int i = 0; i < 4; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(4));
}
for (int i = 0; i < 2; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, def_pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(4));
}
flush_may_occur = FALSE;
expected_bytes_to_free = 4;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), other_flush, def_pe_est_callback, other_pe_callback, def_cleaner_callback, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = other_flush;
wc.pe_callback = other_pe_callback;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc);
flush_may_occur = TRUE;
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
assert(expected_bytes_to_free == 0);
......
......@@ -114,24 +114,44 @@ cachetable_test (void) {
long s1, s2;
flush_may_occur = FALSE;
for (int i = 0; i < 100000; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(4));
}
for (int i = 0; i < 8; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(4));
}
for (int i = 0; i < 4; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(4));
}
for (int i = 0; i < 2; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(4));
}
flush_may_occur = FALSE;
expected_bytes_to_free = 4;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), other_flush, pe_est_callback, other_pe_callback, def_cleaner_callback, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = other_flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = other_pe_callback;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc);
flush_may_occur = TRUE;
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(8));
......
......@@ -99,25 +99,29 @@ cachetable_test (void) {
long s1, s2;
flush_may_occur = FALSE;
check_flush = TRUE;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
for (int i = 0; i < 100000; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
}
for (int i = 0; i < 8; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(1));
}
for (int i = 0; i < 4; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(1));
}
for (int i = 0; i < 2; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(1));
}
flush_may_occur = TRUE;
expected_flushed_key = 4;
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), flush, pe_est_callback, pe_callback, def_cleaner_callback, NULL);
r = toku_cachetable_put(f1, make_blocknum(5), 5, NULL, make_pair_attr(4), wc);
flush_may_occur = TRUE;
expected_flushed_key = 5;
r = toku_cachetable_unpin(f1, make_blocknum(5), 5, CACHETABLE_CLEAN, make_pair_attr(4));
......
......@@ -18,7 +18,8 @@ cachetable_count_pinned_test (int n) {
for (i=1; i<=n; i++) {
u_int32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
assert(toku_cachefile_count_pinned(f1, 0) == i);
......
......@@ -25,7 +25,8 @@ cachetable_debug_test (int n) {
const int item_size = 1;
u_int32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(item_size), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(item_size), wc);
assert(r == 0);
void *v; int dirty; long long pinned; long pair_size;
......
......@@ -81,6 +81,9 @@ static void cachetable_eviction_full_test (void) {
// let's pin a node multiple times
// and really bring up its clock count
//
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
for (int i = 0; i < 20; i++) {
r = toku_cachetable_get_and_pin(
f1,
......@@ -88,14 +91,10 @@ static void cachetable_eviction_full_test (void) {
fullhash,
&value1,
&size1,
flush,
wc,
fetch,
pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -104,20 +103,18 @@ static void cachetable_eviction_full_test (void) {
}
expect_full_flush = TRUE;
// now pin a different, causing an eviction
wc.flush_callback = def_flush;
wc.pe_est_callback = pe_est_callback;
r = toku_cachetable_get_and_pin(
f1,
make_blocknum(1),
1,
&value2,
&size2,
def_flush,
wc,
fetch,
pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......
......@@ -94,20 +94,20 @@ static void cachetable_eviction_full_test (void) {
// and really bring up its clock count
//
for (int i = 0; i < 20; i++) {
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(
f1,
key,
fullhash,
&value1,
&size1,
flush,
wc,
fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -116,20 +116,19 @@ static void cachetable_eviction_full_test (void) {
}
expect_full_flush = TRUE;
// now pin a different, causing an eviction
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(
f1,
make_blocknum(1),
1,
&value2,
&size2,
def_flush,
wc,
fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......
......@@ -47,20 +47,18 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
for (int i = 0; i < 20; i++) {
void* value;
long size;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin(
f1,
key,
fullhash,
&value,
&size,
flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -74,20 +72,17 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
do_sleep = TRUE;
void* value2;
long size2;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_get_and_pin(
f1,
make_blocknum(1),
1,
&value2,
&size2,
def_flush,
wc,
def_fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -98,9 +93,11 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
void *v = 0;
long size = 0;
// now verify that the block we are trying to evict may be pinned
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(r == TOKUDB_TRY_AGAIN);
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
assert(r == 0 && v == 0 && size == 8);
do_sleep = FALSE;
......
......@@ -51,6 +51,9 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
// let's get and pin this node a bunch of times to drive up the clock count
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
for (int i = 0; i < 20; i++) {
void* value;
long size;
......@@ -60,14 +63,10 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
fullhash,
&value,
&size,
def_flush,
wc,
def_fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -86,14 +85,10 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
1,
&value2,
&size2,
def_flush,
wc,
def_fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -110,14 +105,10 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
fullhash,
&v,
&size,
def_flush,
wc,
def_fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
NULL,
NULL,
NULL
);
......@@ -128,14 +119,10 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
fullhash,
&v,
&size,
def_flush,
wc,
def_fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
NULL,
NULL
);
assert(r == 0 && v == 0 && size == 1);
......
......@@ -19,40 +19,6 @@ cleaner_callback(
return 0;
}
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static void
cachetable_test (void) {
const int test_limit = 400;
......@@ -71,7 +37,9 @@ cachetable_test (void) {
//long s2;
for (int j = 0; j < 50000; j++) {
for (int i = 0; i < 10; i++) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), i, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.cleaner_callback = cleaner_callback;
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), i, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, make_pair_attr(8));
}
r = toku_cachefile_flush(f1);
......
......@@ -4,6 +4,7 @@
static void
test_cachetable_def_flush (int n) {
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
const int test_limit = 2*n;
int r;
CACHETABLE ct;
......@@ -23,12 +24,12 @@ test_cachetable_def_flush (int n) {
for (i=0; i<n; i++) {
u_int32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
r = toku_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
assert(r == 0);
hi = toku_cachetable_hash(f2, make_blocknum(i));
r = toku_cachetable_put(f2, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
r = toku_cachetable_put(f2, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
r = toku_cachetable_unpin(f2, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(1));
assert(r == 0);
......
......@@ -37,30 +37,6 @@ fetch (
return 0;
}
static void
pe_est_callback(
void* UU(brtnode_pv),
long* bytes_freed_estimate,
enum partial_eviction_cost *cost,
void* UU(write_extraargs)
)
{
*bytes_freed_estimate = 0;
*cost = PE_CHEAP;
}
static int
pe_callback (
void *brtnode_pv __attribute__((__unused__)),
PAIR_ATTR bytes_to_free __attribute__((__unused__)),
PAIR_ATTR* bytes_freed,
void* extraargs __attribute__((__unused__))
)
{
*bytes_freed = bytes_to_free;
return 0;
}
static void
cachetable_getandpin_test (int n) {
const int test_limit = 1024*1024;
......@@ -79,7 +55,9 @@ cachetable_getandpin_test (int n) {
u_int32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
void *v; long size;
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), hi, &v, &size, flush, fetch, pe_est_callback, pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), hi, &v, &size, wc, fetch, def_pf_req_callback, def_pf_callback, 0);
assert(r == 0);
assert(size == i);
......
......@@ -34,14 +34,15 @@ run_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
foo = FALSE;
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
r = toku_cachefile_flush(f1); assert(r == 0);
assert(foo);
assert(f1);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
foo = FALSE;
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
......
......@@ -11,22 +11,6 @@
u_int32_t fetch_val = 0;
BOOL pf_req_called;
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
......@@ -100,7 +84,8 @@ cachetable_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, pf_req_callback, pf_callback, NULL);
assert(&fetch_val == v1);
//
// verify that a prefetch of this node will fail
......@@ -109,14 +94,10 @@ cachetable_test (void) {
f1,
make_blocknum(1),
1,
flush,
wc,
fetch,
def_pe_est_callback,
def_pe_callback,
pf_req_callback,
pf_callback,
def_cleaner_callback,
NULL,
NULL,
&doing_prefetch
);
......@@ -127,14 +108,14 @@ cachetable_test (void) {
//
// now get and pin node again, and make sure that partial fetch and fetch are not called
//
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, err_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, pf_req_callback, err_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
//
// now make sure that if we say a partial fetch is required, that we get a partial fetch
// and that read_extraargs properly passed down
//
pf_req_called = FALSE;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, true_pf_req_callback, true_pf_callback, def_cleaner_callback, &fetch_val, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, true_pf_req_callback, true_pf_callback, &fetch_val);
assert(pf_req_called);
assert(s1 == sizeof(fetch_val)+1);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......@@ -149,14 +130,10 @@ cachetable_test (void) {
f1,
make_blocknum(1),
1,
flush,
wc,
fetch,
def_pe_est_callback,
def_pe_callback,
pf_req_callback,
pf_callback,
def_cleaner_callback,
NULL,
NULL,
&doing_prefetch
);
......@@ -166,7 +143,7 @@ cachetable_test (void) {
//
// now verify we can pin it, and NO fetch callback should get called
//
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, err_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, pf_req_callback, err_pf_callback, NULL);
assert(&fetch_val == v1);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......@@ -177,19 +154,15 @@ cachetable_test (void) {
f1,
make_blocknum(1),
1,
flush,
wc,
fetch,
def_pe_est_callback,
def_pe_callback,
true_pf_req_callback,
true_pf_callback,
def_cleaner_callback,
&fetch_val,
NULL,
&doing_prefetch
);
assert(doing_prefetch);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, err_fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, err_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, pf_req_callback, err_pf_callback, NULL);
assert(&fetch_val == v1);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......
......@@ -118,14 +118,15 @@ static void *move_numbers(void *arg) {
less_key.b = less;
u_int32_t less_fullhash = less;
enum cachetable_dirty less_dirty = CACHETABLE_DIRTY;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin_with_dep_pairs(
f1,
less_key,
less,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
0, //num_dependent_pairs
NULL,
......@@ -146,8 +147,7 @@ static void *move_numbers(void *arg) {
greater,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
1, //num_dependent_pairs
&f1,
......@@ -180,8 +180,7 @@ static void *move_numbers(void *arg) {
third,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
1, //num_dependent_pairs
&f1,
......@@ -209,14 +208,15 @@ static void *read_random_numbers(void *arg) {
void* v1;
long s1;
int r1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r1 = toku_cachetable_get_and_pin_nonblocking(
f1,
make_blocknum(rand_key1),
rand_key1,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
NULL
);
......
......@@ -66,6 +66,8 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
const int test_limit = n;
int r;
CACHETABLE ct;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0);
char fname1[] = __FILE__ "test1.dat";
unlink(fname1);
......@@ -78,7 +80,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
{
CACHEKEY key = make_blocknum(n+1);
u_int32_t fullhash = toku_cachetable_hash(f1, key);
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
}
......@@ -87,7 +89,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
for (i=0; i<n; i++) {
CACHEKEY key = make_blocknum(i);
u_int32_t hi = toku_cachetable_hash(f1, key);
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
r = toku_cachetable_put(f1, key, hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
r = toku_cachetable_unpin(f1, key, hi, dirty, make_pair_attr(item_size));
......
......@@ -58,7 +58,9 @@ static void cachetable_prefetch_close_leak_test (void) {
// prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0);
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// close with the prefetch in progress. the close should block until
......
......@@ -64,6 +64,8 @@ static void cachetable_prefetch_full_test (BOOL partial_fetch) {
// if we want to do a test of partial fetch,
// we first put the key into the cachefile so that
// the subsequent prefetch does a partial fetch
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
if (partial_fetch) {
expect_pf = TRUE;
void* value;
......@@ -74,21 +76,17 @@ static void cachetable_prefetch_full_test (BOOL partial_fetch) {
fullhash,
&value,
&size,
flush,
wc,
fetch,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
r = toku_cachetable_unpin(f1, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(1));
}
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// close with the prefetch in progress. the close should block until
......
......@@ -67,12 +67,14 @@ static void cachetable_prefetch_flowcontrol_test (int cachetable_size_limit) {
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
// prefetch keys 0 .. N-1. they should all fit in the cachetable
for (i=0; i<cachetable_size_limit; i++) {
CACHEKEY key = make_blocknum(i);
u_int32_t fullhash = toku_cachetable_hash(f1, key);
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
}
......@@ -83,7 +85,7 @@ static void cachetable_prefetch_flowcontrol_test (int cachetable_size_limit) {
for (i=i; i<2*cachetable_size_limit; i++) {
CACHEKEY key = make_blocknum(i);
u_int32_t fullhash = toku_cachetable_hash(f1, key);
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// sleep(1);
}
......
......@@ -81,6 +81,8 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
do_pf = FALSE;
CACHEKEY key = make_blocknum(0);
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
if (do_partial_fetch) {
expect_pf = TRUE;
void* value;
......@@ -91,14 +93,10 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
fullhash,
&value,
&size,
flush,
wc,
fetch,
def_pe_est_callback,
def_pe_callback,
pf_req_callback,
pf_callback,
def_cleaner_callback,
0,
0
);
assert(r==0);
......@@ -110,16 +108,16 @@ static void cachetable_prefetch_maybegetandpin_test (BOOL do_partial_fetch) {
// prefetch block 0. this will take 2 seconds.
do_pf = TRUE;
r = toku_cachefile_prefetch(f1, key, fullhash, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, 0, 0, NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, pf_req_callback, pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// verify that get_and_pin waits while the prefetch is in progress
void *v = 0;
long size = 0;
do_pf = FALSE;
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, wc, fetch, pf_req_callback, pf_callback, NULL, NULL);
assert(r==TOKUDB_TRY_AGAIN);
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, flush, fetch, def_pe_est_callback, def_pe_callback, pf_req_callback, pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, wc, fetch, pf_req_callback, pf_callback, NULL);
assert(r == 0 && v == 0 && size == 2);
struct timeval tend;
......
......@@ -40,7 +40,8 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
// prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0);
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
r = toku_cachefile_prefetch(f1, key, fullhash, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// verify that maybe_get_and_pin returns an error while the prefetch is in progress
......
......@@ -43,11 +43,12 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
// prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0);
u_int32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
r = toku_cachefile_prefetch(f1, key, fullhash, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// prefetch again. this should do nothing.
r = toku_cachefile_prefetch(f1, key, fullhash, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0, NULL);
r = toku_cachefile_prefetch(f1, key, fullhash, wc, fetch, def_pf_req_callback, def_pf_callback, 0, NULL);
toku_cachetable_verify(ct);
// verify that maybe_get_and_pin returns an error while the prefetch is in progress
......
......@@ -111,14 +111,15 @@ static void move_number_to_child(
CACHEKEY child_key;
child_key.b = child;
u_int32_t child_fullhash = toku_cachetable_hash(f1, child_key);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin_with_dep_pairs(
f1,
child_key,
child_fullhash,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
1, //num_dependent_pairs
&f1,
......@@ -155,14 +156,15 @@ static void *move_numbers(void *arg) {
CACHEKEY parent_key;
parent_key.b = parent;
u_int32_t parent_fullhash = toku_cachetable_hash(f1, parent_key);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin_with_dep_pairs(
f1,
parent_key,
parent_fullhash,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
0, //num_dependent_pairs
NULL,
......@@ -218,14 +220,15 @@ static void merge_and_split_child(
child_key.b = child;
u_int32_t child_fullhash = toku_cachetable_hash(f1, child_key);
enum cachetable_dirty child_dirty = CACHETABLE_CLEAN;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin_with_dep_pairs(
f1,
child_key,
child_fullhash,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
1, //num_dependent_pairs
&f1,
......@@ -258,8 +261,7 @@ static void merge_and_split_child(
other_child_fullhash,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
2, //num_dependent_pairs
cfs,
......@@ -289,8 +291,7 @@ static void merge_and_split_child(
get_data,
data_val,
make_pair_attr(8),
flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback,
NULL, // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
wc,
&other_child,
2, // number of dependent pairs that we may need to checkpoint
cfs,
......@@ -327,14 +328,15 @@ static void *merge_and_split(void *arg) {
CACHEKEY parent_key;
parent_key.b = parent;
u_int32_t parent_fullhash = toku_cachetable_hash(f1, parent_key);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin_with_dep_pairs(
f1,
parent_key,
parent_fullhash,
&v1,
&s1,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
NULL,
wc, fetch, def_pf_req_callback, def_pf_callback,
NULL,
0, //num_dependent_pairs
NULL,
......
......@@ -17,7 +17,8 @@ cachetable_put_test (int n) {
for (i=1; i<=n; i++) {
u_int32_t hi;
hi = toku_cachetable_hash(f1, make_blocknum(i));
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
assert(toku_cachefile_count_pinned(f1, 0) == i);
......
......@@ -100,9 +100,11 @@ static void test_rename (void) {
long nval = random();
if (verbose) printf("n_keys=%d Insert %08" PRIx64 "\n", n_keys, nkey.b);
u_int32_t hnkey = toku_cachetable_hash(f, nkey);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = r_flush;
r = toku_cachetable_put(f, nkey, hnkey,
(void*)nval, make_pair_attr(1),
r_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
wc);
assert(r==0);
test_mutex_lock();
while (n_keys >= KEYLIMIT) {
......@@ -127,7 +129,9 @@ static void test_rename (void) {
void *current_value;
long current_size;
if (verbose) printf("Rename %" PRIx64 " to %" PRIx64 "\n", okey.b, nkey.b);
r = toku_cachetable_get_and_pin(f, okey, toku_cachetable_hash(f, okey), &current_value, &current_size, r_flush, r_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = r_flush;
r = toku_cachetable_get_and_pin(f, okey, toku_cachetable_hash(f, okey), &current_value, &current_size, wc, r_fetch, def_pf_req_callback, def_pf_callback, 0);
if (r == -42) continue;
assert(r==0);
r = toku_cachetable_rename(f, okey, nkey);
......
......@@ -68,7 +68,9 @@ static void writeit (void) {
u_int32_t fullhash = toku_cachetable_hash(f, key);
int j;
for (j=0; j<BLOCKSIZE; j++) ((char*)buf)[j]=(char)((i+j)%256);
r = toku_cachetable_put(f, key, fullhash, buf, make_pair_attr(BLOCKSIZE), f_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0); assert(r==0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = f_flush;
r = toku_cachetable_put(f, key, fullhash, buf, make_pair_attr(BLOCKSIZE), wc); assert(r==0);
r = toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(BLOCKSIZE)); assert(r==0);
}
gettimeofday(&end, 0);
......@@ -89,7 +91,9 @@ static void readit (void) {
for (i=0; i<N; i++) {
CACHEKEY key = make_blocknum(i*BLOCKSIZE);
u_int32_t fullhash = toku_cachetable_hash(f, key);
r=toku_cachetable_get_and_pin(f, key, fullhash, &block, &current_size, f_flush, f_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0); assert(r==0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = f_flush;
r=toku_cachetable_get_and_pin(f, key, fullhash, &block, &current_size, wc, f_fetch, def_pf_req_callback, def_pf_callback, 0); assert(r==0);
r=toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, make_pair_attr(BLOCKSIZE)); assert(r==0);
}
r = toku_cachefile_close(&f, 0, FALSE, ZERO_LSN); assert(r == 0);
......
......@@ -7,39 +7,6 @@
// simple tests for maybe_get_and_pin(_clean)
//
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
//usleep (5*1024*1024);
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static void
cachetable_test (void) {
const int test_limit = 12;
......@@ -50,13 +17,14 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
void* v1;
long s1;
// nothing in cachetable, so this should fail
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(1), 1, &v1);
assert(r==-1);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
// maybe_get_and_pin_clean should succeed, maybe_get_and_pin should fail
......
......@@ -77,8 +77,12 @@ cachetable_test (BOOL write_first, BOOL write_second, BOOL start_checkpoint) {
long s1;
long s2;
long s3;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val1, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val2, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(&val1);
wc.flush_callback = flush;
wc.write_extraargs = &val1;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, &val1);
wc.write_extraargs = &val2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, &val2);
CACHEFILE dependent_cfs[2];
dependent_cfs[0] = f1;
......@@ -105,15 +109,15 @@ cachetable_test (BOOL write_first, BOOL write_second, BOOL start_checkpoint) {
check_me = TRUE;
v1_written = FALSE;
v2_written = FALSE;
wc.write_extraargs = &val3;
r = toku_cachetable_get_and_pin_with_dep_pairs(
f1,
make_blocknum(3),
3,
&v3,
&s3,
flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback,
wc, fetch, def_pf_req_callback, def_pf_callback,
&val3,
NULL,
2, //num_dependent_pairs
dependent_cfs,
dependent_keys,
......
......@@ -33,22 +33,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
//usleep (5*1024*1024);
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static BOOL true_def_pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
return TRUE;
}
......@@ -94,38 +78,40 @@ run_test (void) {
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
//
// test that if we are getting a PAIR for the first time that TOKUDB_TRY_AGAIN is returned
// because the PAIR was not in the cachetable.
//
is_fake_locked = TRUE;
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(r==TOKUDB_TRY_AGAIN);
assert(is_fake_locked);
// now it should succeed
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(r==0);
assert(is_fake_locked);
foo = FALSE;
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
// because node is in use, should return TOKUDB_TRY_AGAIN
assert(is_fake_locked);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(is_fake_locked);
assert(r==TOKUDB_TRY_AGAIN);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
assert(foo);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
// now make sure we get TOKUDB_TRY_AGAIN when a partial fetch is involved
assert(is_fake_locked);
// first make sure value is there
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(is_fake_locked);
assert(r==0);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
// now make sure that we get TOKUDB_TRY_AGAIN for the partial fetch
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, true_def_pf_req_callback, true_def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, true_def_pf_req_callback, true_def_pf_callback, NULL, NULL);
assert(is_fake_locked);
assert(r==TOKUDB_TRY_AGAIN);
......@@ -133,13 +119,13 @@ run_test (void) {
// now test that if there is a checkpoint pending,
// first pin and unpin with dirty
//
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(is_fake_locked);
assert(r==0);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8)); assert(r==0);
// this should mark the PAIR as pending
r = toku_cachetable_begin_checkpoint(ct, NULL); assert(r == 0);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL, NULL);
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL, NULL);
assert(is_fake_locked);
assert(r==TOKUDB_TRY_AGAIN);
my_ydb_unlock();
......
......@@ -34,22 +34,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
}
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static void kibbutz_work(void *fe_v)
{
CACHEFILE f1 = fe_v;
......@@ -75,16 +59,18 @@ run_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
foo = FALSE;
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
assert(foo);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
//now let's do a simple checkpoint test
// first dirty the PAIR
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
// now this should mark the pair for checkpoint
......@@ -95,7 +81,7 @@ run_test (void) {
//
check_me = TRUE;
flush_called = FALSE;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
assert(flush_called);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
......
......@@ -82,9 +82,11 @@ cachetable_test (BOOL write_first, BOOL write_second, BOOL start_checkpoint) {
void* v2;
long s1;
long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val1, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, &val1);
assert(r==0);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, &val2, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, &val2);
assert(r==0);
CACHEFILE dependent_cfs[2];
......@@ -120,11 +122,7 @@ cachetable_test (BOOL write_first, BOOL write_second, BOOL start_checkpoint) {
get_key_and_fullhash,
&val3,
make_pair_attr(8),
flush,
def_pe_est_callback,
def_pe_callback,
def_cleaner_callback,
NULL,
wc,
NULL,
2, //num_dependent_pairs
dependent_cfs,
......
......@@ -3,39 +3,6 @@
#include "includes.h"
#include "test.h"
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
//usleep (5*1024*1024);
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static void remove_key_expect_checkpoint(
CACHEKEY* UU(cachekey),
BOOL for_checkpoint,
......@@ -69,7 +36,8 @@ cachetable_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_begin_checkpoint(ct, NULL); assert(r == 0);
r = toku_cachetable_unpin_and_remove(f1, make_blocknum(1), remove_key_expect_checkpoint, NULL);
r = toku_cachetable_end_checkpoint(
......@@ -82,7 +50,7 @@ cachetable_test (void) {
);
assert(r==0);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin_and_remove(f1, make_blocknum(1), remove_key_expect_no_checkpoint, NULL);
......
......@@ -3,39 +3,6 @@
#include "includes.h"
#include "test.h"
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
void *v __attribute__((__unused__)),
void *e __attribute__((__unused__)),
PAIR_ATTR s __attribute__((__unused__)),
PAIR_ATTR* new_size __attribute__((__unused__)),
BOOL w __attribute__((__unused__)),
BOOL keep __attribute__((__unused__)),
BOOL c __attribute__((__unused__))
) {
/* Do nothing */
if (verbose) { printf("FLUSH: %d\n", (int)k.b); }
//usleep (5*1024*1024);
}
static int
fetch (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
CACHEKEY k __attribute__((__unused__)),
u_int32_t fullhash __attribute__((__unused__)),
void **value __attribute__((__unused__)),
PAIR_ATTR *sizep __attribute__((__unused__)),
int *dirtyp,
void *extraargs __attribute__((__unused__))
) {
*dirtyp = 0;
*value = NULL;
*sizep = make_pair_attr(8);
return 0;
}
static void
cachetable_test (void) {
const int test_limit = 12;
......@@ -51,7 +18,8 @@ cachetable_test (void) {
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
......
This diff is collapsed.
......@@ -163,7 +163,9 @@ static void test_chaining (void) {
int fnum = i%N_FILES;
//printf("%s:%d Add %d\n", __FILE__, __LINE__, i);
u_int32_t fhash = toku_cachetable_hash(f[fnum], make_blocknum(i));
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, make_pair_attr(test_object_size), flush_forchain, def_pe_est_callback, def_pe_callback, def_cleaner_callback, (void*)i);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback((void *)i);
wc.flush_callback = flush_forchain;
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, make_pair_attr(test_object_size), wc);
assert(r==0);
item_becomes_present(ct, f[fnum], make_blocknum(i));
r = toku_cachetable_unpin(f[fnum], make_blocknum(i), fhash, CACHETABLE_CLEAN, make_pair_attr(test_object_size));
......@@ -184,19 +186,17 @@ static void test_chaining (void) {
void *value;
//printf("Touching %d (%lld, %p)\n", whichone, whichkey, whichcf);
u_int32_t fhash = toku_cachetable_hash(whichcf, whichkey);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback((void*)(long)whichkey.b);
wc.flush_callback = flush_forchain;
r = toku_cachetable_get_and_pin(whichcf,
whichkey,
fhash,
&value,
NULL,
flush_forchain,
wc,
fetch_forchain,
def_pe_est_callback,
def_pe_callback,
def_pf_req_callback,
def_pf_callback,
def_cleaner_callback,
(void*)(long)whichkey.b,
(void*)(long)whichkey.b
);
assert(r==0);
......@@ -213,7 +213,9 @@ static void test_chaining (void) {
// if i is a duplicate, cachetable_put will return -1
// printf("%s:%d Add {%ld,%p}\n", __FILE__, __LINE__, i, f[fnum]);
u_int32_t fhash = toku_cachetable_hash(f[fnum], make_blocknum(i));
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, make_pair_attr(test_object_size), flush_forchain, def_pe_est_callback, def_pe_callback, def_cleaner_callback, (void*)i);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback((void *)i);
wc.flush_callback = flush_forchain;
r = toku_cachetable_put(f[fnum], make_blocknum(i), fhash, (void*)i, make_pair_attr(test_object_size), wc);
assert(r==0 || r==-1);
if (r==0) {
item_becomes_present(ct, f[fnum], make_blocknum(i));
......
......@@ -32,6 +32,7 @@ cachetable_unpin_and_remove_test (int n) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
// generate some random keys
CACHEKEY keys[n]; int nkeys = n;
......@@ -42,7 +43,7 @@ cachetable_unpin_and_remove_test (int n) {
// put the keys into the cachetable
for (i=0; i<n; i++) {
u_int32_t hi = toku_cachetable_hash(f1, make_blocknum(keys[i].b));
r = toku_cachetable_put(f1, make_blocknum(keys[i].b), hi, (void *)(long) keys[i].b, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
r = toku_cachetable_put(f1, make_blocknum(keys[i].b), hi, (void *)(long) keys[i].b, make_pair_attr(1),wc);
assert(r == 0);
}
......@@ -96,6 +97,7 @@ cachetable_put_evict_remove_test (int n) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, 0777); assert(r == 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
u_int32_t hi[n];
for (i=0; i<n; i++)
......@@ -103,7 +105,7 @@ cachetable_put_evict_remove_test (int n) {
// put 0, 1, 2, ... should evict 0
for (i=0; i<n; i++) {
r = toku_cachetable_put(f1, make_blocknum(i), hi[i], (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
r = toku_cachetable_put(f1, make_blocknum(i), hi[i], (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
r = toku_cachetable_unpin(f1, make_blocknum(i), hi[i], CACHETABLE_CLEAN, make_pair_attr(1));
assert(r == 0);
......@@ -111,7 +113,7 @@ cachetable_put_evict_remove_test (int n) {
// get 0
void *v; long s;
r = toku_cachetable_get_and_pin(f1, make_blocknum(0), hi[0], &v, &s, def_flush, fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, 0, 0);
r = toku_cachetable_get_and_pin(f1, make_blocknum(0), hi[0], &v, &s, wc, fetch, def_pf_req_callback, def_pf_callback, 0);
assert(r == 0);
// remove 0
......
......@@ -34,11 +34,12 @@ run_test (void) {
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
void* v1;
//void* v2;
long s1;
//long s2;
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
toku_cachetable_unpin(
f1,
make_blocknum(1),
......@@ -49,7 +50,7 @@ run_test (void) {
// now this should mark the pair for checkpoint
r = toku_cachetable_begin_checkpoint(ct, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, def_flush, def_fetch, def_pe_est_callback, def_pe_callback, def_pf_req_callback, def_pf_callback, def_cleaner_callback, NULL, NULL);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, NULL);
toku_pthread_t mytid;
r = toku_pthread_create(&mytid, NULL, run_end_chkpt, NULL);
......
......@@ -17,8 +17,9 @@ cachetable_unpin_test (int n) {
int i;
for (i=1; i<=n; i++) {
u_int32_t hi;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
hi = toku_cachetable_hash(f1, make_blocknum(i));
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), def_flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, 0);
r = toku_cachetable_put(f1, make_blocknum(i), hi, (void *)(long)i, make_pair_attr(1), wc);
assert(r == 0);
assert(toku_cachefile_count_pinned(f1, 0) == i);
......
......@@ -42,7 +42,9 @@ cachetable_test (void) {
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
for (int64_t i = 0; i < num_entries; i++) {
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), flush, def_pe_est_callback, def_pe_callback, def_cleaner_callback, NULL);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
r = toku_cachetable_put(f1, make_blocknum(i), i, NULL, make_pair_attr(1), wc);
int curr_size = __sync_fetch_and_add(&total_size, 1);
assert(curr_size <= test_limit + test_limit/2+1);
r = toku_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, make_pair_attr(4));
......
......@@ -196,6 +196,16 @@ def_cleaner_callback(
return 0;
}
static UU() CACHETABLE_WRITE_CALLBACK def_write_callback(void* write_extraargs) {
CACHETABLE_WRITE_CALLBACK wc;
wc.flush_callback = def_flush;
wc.pe_est_callback = def_pe_est_callback;
wc.pe_callback = def_pe_callback;
wc.cleaner_callback = def_cleaner_callback;
wc.write_extraargs = write_extraargs;
return wc;
}
int verbose=0;
static inline void
......
......@@ -107,19 +107,20 @@ cachetable_test (void) {
long s1;
u_int64_t val1 = 0;
u_int64_t val2 = 0;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
wc.flush_callback = flush;
wc.pe_est_callback = pe_est_callback;
wc.pe_callback = pe_callback;
r = toku_cachetable_get_and_pin(
f1,
make_blocknum(1),
1,
&v1,
&s1,
flush,
wc,
fetch,
pe_est_callback,
pe_callback,
def_pf_req_callback, def_pf_callback, def_cleaner_callback,
&val1,
NULL
def_pf_req_callback, def_pf_callback,
&val1
);
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
CACHEKEY key;
......@@ -130,11 +131,7 @@ cachetable_test (void) {
test_get_key_and_fullhash,
&val2,
make_pair_attr(8),
flush,
pe_est_callback,
pe_callback,
def_cleaner_callback,
NULL, // parameter for flush_callback, pe_est_callback, pe_callback, and cleaner_callback
wc,
NULL,
0, // number of dependent pairs that we may need to checkpoint
NULL, // array of cachefiles of dependent pairs
......
......@@ -4433,10 +4433,10 @@ toku_db_cursor(DB * db, DB_TXN * txn, DBC ** c, u_int32_t flags, int is_temporar
);
}
r = toku_grab_read_lock_on_directory(db, txn);
if (r != 0)
return r;
//r = toku_grab_read_lock_on_directory(db, txn);
//if (r != 0)
// return r;
r = 0;
struct __toku_dbc_external *XMALLOC(eresult); // so the internal stuff is stuck on the end
memset(eresult, 0, sizeof(*eresult));
DBC *result = &eresult->external_part;
......
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