Commit c21fa483 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

merge more of 1735 to main. addresses #1735

git-svn-id: file:///svn/toku/tokudb@11732 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4fab4cc5
......@@ -1158,6 +1158,33 @@ int toku_cachetable_maybe_get_and_pin (CACHEFILE cachefile, CACHEKEY key, u_int3
return r;
}
int toku_cachetable_maybe_get_and_pin_clean (CACHEFILE cachefile, CACHEKEY key, u_int32_t fullhash, void**value) {
CACHETABLE ct = cachefile->cachetable;
PAIR p;
int count = 0;
int r = -1;
cachetable_lock(ct);
for (p=ct->table[fullhash&(ct->table_size-1)]; p; p=p->hash_chain) {
count++;
if (p->key.b==key.b && p->cachefile==cachefile && p->state == CTPAIR_IDLE) {
if (p->checkpoint_pending) {
goto finish;
}
*value = p->value;
rwlock_read_lock(&p->rwlock, ct->mutex);
lru_touch(ct,p);
r = 0;
//printf("%s:%d cachetable_maybe_get_and_pin(%lld)--> %p\n", __FILE__, __LINE__, key, *value);
break;
}
}
finish:
note_hash_count(count);
cachetable_unlock(ct);
return r;
}
int toku_cachetable_unpin(CACHEFILE cachefile, CACHEKEY key, u_int32_t fullhash, enum cachetable_dirty dirty, long size) {
CACHETABLE ct = cachefile->cachetable;
......
......@@ -124,6 +124,9 @@ int toku_cachetable_get_and_pin(CACHEFILE, CACHEKEY, u_int32_t /*fullhash*/,
// void**. If the item is not in memory, then return a nonzero error number.
int toku_cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, u_int32_t /*fullhash*/, void**);
// Like maybe get and pin, but may pin a clean pair.
int toku_cachetable_maybe_get_and_pin_clean (CACHEFILE, CACHEKEY, u_int32_t /*fullhash*/, void**);
// cachetable pair clean or dirty WRT external memory
enum cachetable_dirty {
CACHETABLE_CLEAN=0, // the cached object is clean WRT the cachefile
......
......@@ -56,7 +56,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
int i;
for (i=1; i>=0; i++) {
void *v;
r = toku_cachetable_maybe_get_and_pin(f1, key, fullhash, &v);
r = toku_cachetable_maybe_get_and_pin_clean(f1, key, fullhash, &v);
if (r == 0) break;
toku_pthread_yield();
}
......
......@@ -64,7 +64,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
int i;
for (i=1; i>=0; i++) {
void *v;
r = toku_cachetable_maybe_get_and_pin(f1, key, fullhash, &v);
r = toku_cachetable_maybe_get_and_pin_clean(f1, key, fullhash, &v);
if (r == 0) break;
toku_pthread_yield();
}
......
......@@ -414,7 +414,7 @@ static void test_multi_filehandles (void) {
assert((unsigned long)v==125);
r = toku_cachetable_get_and_pin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), &v, NULL, null_flush, add222_fetch, (void*)222); assert(r==0);
assert((unsigned long)v==224);
r = toku_cachetable_maybe_get_and_pin(f1, make_blocknum(2), toku_cachetable_hash(f1, make_blocknum(2)), &v); assert(r==0);
r = toku_cachetable_maybe_get_and_pin_clean(f1, make_blocknum(2), toku_cachetable_hash(f1, make_blocknum(2)), &v); assert(r==0);
assert((unsigned long)v==125);
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0);
......
......@@ -67,7 +67,7 @@ BDB_DONTRUN_TESTS = \
keyrange-dupsort \
keyrange-dupsort-unflat \
manyfiles \
stat64 \
stat64 stat64_flatten \
test938c \
test1324 \
helgrind1 \
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
// test the stat64 function on flat databases
#include "test.h"
#include <db.h>
#include <sys/stat.h>
static void
test_stat64 (unsigned int N)
{
test_stat64 (unsigned int N) {
if (verbose) printf("%s:%d\n", __FUNCTION__, __LINE__);
system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
......@@ -17,7 +21,7 @@ test_stat64 (unsigned int N)
DB_TXN *txn;
r = db_env_create(&env, 0); CKERR(r);
r = env->set_cachesize(env, 0, 10000000, 1);
r = env->set_cachesize(env, 0, 10*1000000, 1);
r = env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
......@@ -28,11 +32,14 @@ test_stat64 (unsigned int N)
}
r=env->txn_begin(env, 0, &txn, 0); CKERR(r);
// insert sequential keys into the databases
unsigned int i;
u_int64_t dsize=0;
for (i=0; i<N; i++) {
char hello[30], there[30];
snprintf(hello, sizeof(hello), "hello%d", i);
snprintf(hello, sizeof(hello), "hello%8d", i);
snprintf(there, sizeof(there), "there%d", i);
DBT key, val;
r=db->put(db, txn,
......
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