Commit 6c211758 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Merge 1767 into main line (including 1768 and 1627 fixes) and delete 1767...

Merge 1767 into main line (including 1768 and 1627 fixes) and delete 1767 branch.  Fixes #1767.  Refs #1768, 1627.

git-svn-id: file:///svn/toku/tokudb@12140 c7de825b-a66e-492c-adef-691d508d4ae1
parent e191dd01
...@@ -29,11 +29,10 @@ int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) { ...@@ -29,11 +29,10 @@ int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) {
void test_db(void) { void test_db(void) {
DbEnv env(DB_CXX_NO_EXCEPTIONS); DbEnv env(DB_CXX_NO_EXCEPTIONS);
env.open(NULL, DB_PRIVATE, 0666); int r = env.open(NULL, DB_CREATE|DB_PRIVATE, 0666);
assert(r==0);
Db db(&env, 0); Db db(&env, 0);
int r;
r = db.set_bt_compare(cmp); assert(r == 0); r = db.set_bt_compare(cmp); assert(r == 0);
r = db.remove("DoesNotExist.db", NULL, 0); assert(r == ENOENT); r = db.remove("DoesNotExist.db", NULL, 0); assert(r == ENOENT);
// The db is closed // The db is closed
......
...@@ -12,7 +12,7 @@ int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) { ...@@ -12,7 +12,7 @@ int cmp(DB *db, const DBT *dbt1, const DBT *dbt2) {
void test_db(void) { void test_db(void) {
DbEnv env(0); DbEnv env(0);
env.open(NULL, DB_PRIVATE, 0666); env.open(NULL, DB_CREATE|DB_PRIVATE, 0666);
Db db(&env, 0); Db db(&env, 0);
int r; int r;
......
...@@ -327,7 +327,7 @@ enum brt_layout_version_e { ...@@ -327,7 +327,7 @@ enum brt_layout_version_e {
}; };
void toku_brtheader_free (struct brt_header *h); void toku_brtheader_free (struct brt_header *h);
int toku_brtheader_close (CACHEFILE cachefile, void *header_v, char **error_string); int toku_brtheader_close (CACHEFILE cachefile, void *header_v, char **error_string, LSN);
int toku_brtheader_begin_checkpoint (CACHEFILE cachefile, LSN checkpoint_lsn, void *header_v); int toku_brtheader_begin_checkpoint (CACHEFILE cachefile, LSN checkpoint_lsn, void *header_v);
int toku_brtheader_checkpoint (CACHEFILE cachefile, void *header_v); int toku_brtheader_checkpoint (CACHEFILE cachefile, void *header_v);
int toku_brtheader_end_checkpoint (CACHEFILE cachefile, void *header_v); int toku_brtheader_end_checkpoint (CACHEFILE cachefile, void *header_v);
......
...@@ -628,6 +628,7 @@ brtheader_copy_for_checkpoint(struct brt_header *h, LSN checkpoint_lsn) { ...@@ -628,6 +628,7 @@ brtheader_copy_for_checkpoint(struct brt_header *h, LSN checkpoint_lsn) {
struct brt_header* XMALLOC(ch); struct brt_header* XMALLOC(ch);
*ch = *h; //Do a shallow copy *ch = *h; //Do a shallow copy
ch->type = BRTHEADER_CHECKPOINT_INPROGRESS; //Different type ch->type = BRTHEADER_CHECKPOINT_INPROGRESS; //Different type
//printf("checkpoint_lsn=%" PRIu64 "\n", checkpoint_lsn.lsn);
ch->checkpoint_lsn = checkpoint_lsn; ch->checkpoint_lsn = checkpoint_lsn;
ch->panic_string = NULL; ch->panic_string = NULL;
...@@ -2976,7 +2977,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre ...@@ -2976,7 +2977,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre
BOOL did_create = FALSE; BOOL did_create = FALSE;
r = brt_open_file(t, fname, is_create, &fd, &did_create); r = brt_open_file(t, fname, is_create, &fd, &did_create);
if (r != 0) goto died00; if (r != 0) goto died00;
r=toku_cachetable_openfd(&t->cf, cachetable, fd, fname); r=toku_cachetable_openfd(&t->cf, cachetable, fd, fname_in_env);
if (r != 0) goto died00; if (r != 0) goto died00;
if (did_create) { if (did_create) {
mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO; mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
...@@ -2989,7 +2990,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre ...@@ -2989,7 +2990,7 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, int is_cre
} }
if (r!=0) { if (r!=0) {
died_after_open: died_after_open:
toku_cachefile_close(&t->cf, toku_txn_logger(txn), 0); toku_cachefile_close(&t->cf, toku_txn_logger(txn), 0, ZERO_LSN);
goto died00; goto died00;
} }
assert(t->nodesize>0); assert(t->nodesize>0);
...@@ -3198,7 +3199,7 @@ toku_brtheader_end_checkpoint (CACHEFILE cachefile, void *header_v) { ...@@ -3198,7 +3199,7 @@ toku_brtheader_end_checkpoint (CACHEFILE cachefile, void *header_v) {
} }
int int
toku_brtheader_close (CACHEFILE cachefile, void *header_v, char **malloced_error_string) toku_brtheader_close (CACHEFILE cachefile, void *header_v, char **malloced_error_string, LSN lsn)
{ {
struct brt_header *h = header_v; struct brt_header *h = header_v;
assert(h->type == BRTHEADER_CURRENT); assert(h->type == BRTHEADER_CURRENT);
...@@ -3208,9 +3209,9 @@ toku_brtheader_close (CACHEFILE cachefile, void *header_v, char **malloced_error ...@@ -3208,9 +3209,9 @@ toku_brtheader_close (CACHEFILE cachefile, void *header_v, char **malloced_error
toku_brtheader_unlock(h); toku_brtheader_unlock(h);
int r = 0; int r = 0;
if (h->dirty) { // this is the only place this bit is tested (in currentheader) if (h->dirty) { // this is the only place this bit is tested (in currentheader)
//TODO: #1627 put meaningful LSN in for begin_checkpoint
int r2; int r2;
r2 = toku_brtheader_begin_checkpoint(cachefile, ZERO_LSN, header_v); //assert(lsn.lsn!=0);
r2 = toku_brtheader_begin_checkpoint(cachefile, lsn, header_v);
if (r==0) r = r2; if (r==0) r = r2;
r2 = toku_brtheader_checkpoint(cachefile, h); r2 = toku_brtheader_checkpoint(cachefile, h);
if (r==0) r = r2; if (r==0) r = r2;
...@@ -3283,10 +3284,10 @@ int toku_close_brt (BRT brt, TOKULOGGER logger, char **error_string) { ...@@ -3283,10 +3284,10 @@ int toku_close_brt (BRT brt, TOKULOGGER logger, char **error_string) {
brtheader_note_brt_close(brt); brtheader_note_brt_close(brt);
if (brt->cf) { if (brt->cf) {
LSN lsn = ZERO_LSN; // if there is no logger, we use zero for the lsn
if (logger) { if (logger) {
assert(brt->fname); assert(brt->fname);
BYTESTRING bs = {.len=strlen(brt->fname), .data=brt->fname}; BYTESTRING bs = {.len=strlen(brt->fname), .data=brt->fname};
LSN lsn;
r = toku_log_brtclose(logger, &lsn, 1, bs, toku_cachefile_filenum(brt->cf)); // flush the log on close, otherwise it might not make it out. r = toku_log_brtclose(logger, &lsn, 1, bs, toku_cachefile_filenum(brt->cf)); // flush the log on close, otherwise it might not make it out.
if (r!=0) return r; if (r!=0) return r;
} }
...@@ -3295,7 +3296,7 @@ int toku_close_brt (BRT brt, TOKULOGGER logger, char **error_string) { ...@@ -3295,7 +3296,7 @@ int toku_close_brt (BRT brt, TOKULOGGER logger, char **error_string) {
//printf("%s:%d closing cachetable\n", __FILE__, __LINE__); //printf("%s:%d closing cachetable\n", __FILE__, __LINE__);
// printf("%s:%d brt=%p ,brt->h=%p\n", __FILE__, __LINE__, brt, brt->h); // printf("%s:%d brt=%p ,brt->h=%p\n", __FILE__, __LINE__, brt, brt->h);
if (error_string) assert(*error_string == 0); if (error_string) assert(*error_string == 0);
r = toku_cachefile_close(&brt->cf, logger, error_string); r = toku_cachefile_close(&brt->cf, logger, error_string, lsn);
if (r==0 && error_string) assert(*error_string == 0); if (r==0 && error_string) assert(*error_string == 0);
} }
if (brt->fname) toku_free(brt->fname); if (brt->fname) toku_free(brt->fname);
......
...@@ -188,10 +188,10 @@ struct cachefile { ...@@ -188,10 +188,10 @@ struct cachefile {
CACHETABLE cachetable; CACHETABLE cachetable;
struct fileid fileid; struct fileid fileid;
FILENUM filenum; FILENUM filenum;
char *fname; char *fname_relative_to_env; /* Used for logging */
void *userdata; void *userdata;
int (*close_userdata)(CACHEFILE cf, void *userdata, char **error_string); // when closing the last reference to a cachefile, first call this function. int (*close_userdata)(CACHEFILE cf, void *userdata, char **error_string, LSN); // when closing the last reference to a cachefile, first call this function.
int (*begin_checkpoint_userdata)(CACHEFILE cf, LSN lsn_of_checkpoint, void *userdata); // before checkpointing cachefiles call this function. int (*begin_checkpoint_userdata)(CACHEFILE cf, LSN lsn_of_checkpoint, void *userdata); // before checkpointing cachefiles call this function.
int (*checkpoint_userdata)(CACHEFILE cf, void *userdata); // when checkpointing a cachefile, call this function. int (*checkpoint_userdata)(CACHEFILE cf, void *userdata); // when checkpointing a cachefile, call this function.
int (*end_checkpoint_userdata)(CACHEFILE cf, void *userdata); // after checkpointing cachefiles call this function. int (*end_checkpoint_userdata)(CACHEFILE cf, void *userdata); // after checkpointing cachefiles call this function.
...@@ -267,11 +267,11 @@ int toku_cachefile_of_filenum (CACHETABLE ct, FILENUM filenum, CACHEFILE *cf) { ...@@ -267,11 +267,11 @@ int toku_cachefile_of_filenum (CACHETABLE ct, FILENUM filenum, CACHEFILE *cf) {
static FILENUM next_filenum_to_use={0}; static FILENUM next_filenum_to_use={0};
static void cachefile_init_filenum(CACHEFILE cf, int fd, const char *fname, struct fileid fileid) \ static void cachefile_init_filenum(CACHEFILE cf, int fd, const char *fname_relative_to_env, struct fileid fileid) \
{ {
cf->fd = fd; cf->fd = fd;
cf->fileid = fileid; cf->fileid = fileid;
cf->fname = fname ? toku_strdup(fname) : 0; cf->fname_relative_to_env = fname_relative_to_env ? toku_strdup(fname_relative_to_env) : 0;
} }
// //
// Increment the reference count // Increment the reference count
...@@ -283,7 +283,7 @@ cachefile_refup (CACHEFILE cf) { ...@@ -283,7 +283,7 @@ cachefile_refup (CACHEFILE cf) {
// If something goes wrong, close the fd. After this, the caller shouldn't close the fd, but instead should close the cachefile. // If something goes wrong, close the fd. After this, the caller shouldn't close the fd, but instead should close the cachefile.
int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char *fname) { int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char *fname_relative_to_env) {
int r; int r;
CACHEFILE extant; CACHEFILE extant;
struct fileid fileid; struct fileid fileid;
...@@ -327,7 +327,7 @@ int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char ...@@ -327,7 +327,7 @@ int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char
CACHEFILE XCALLOC(newcf); CACHEFILE XCALLOC(newcf);
newcf->cachetable = ct; newcf->cachetable = ct;
newcf->filenum.fileid = next_filenum_to_use.fileid++; newcf->filenum.fileid = next_filenum_to_use.fileid++;
cachefile_init_filenum(newcf, fd, fname, fileid); cachefile_init_filenum(newcf, fd, fname_relative_to_env, fileid);
newcf->refcount = 1; newcf->refcount = 1;
newcf->next = ct->cachefiles; newcf->next = ct->cachefiles;
ct->cachefiles = newcf; ct->cachefiles = newcf;
...@@ -345,10 +345,10 @@ int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char ...@@ -345,10 +345,10 @@ int toku_cachetable_openfd (CACHEFILE *cfptr, CACHETABLE ct, int fd, const char
} }
//TEST_ONLY_FUNCTION //TEST_ONLY_FUNCTION
int toku_cachetable_openf (CACHEFILE *cfptr, CACHETABLE ct, const char *fname, int flags, mode_t mode) { int toku_cachetable_openf (CACHEFILE *cfptr, CACHETABLE ct, const char *fname, const char *fname_relative_to_env, int flags, mode_t mode) {
int fd = open(fname, flags+O_BINARY, mode); int fd = open(fname, flags+O_BINARY, mode);
if (fd<0) return errno; if (fd<0) return errno;
return toku_cachetable_openfd (cfptr, ct, fd, fname); return toku_cachetable_openfd (cfptr, ct, fd, fname_relative_to_env);
} }
WORKQUEUE toku_cachetable_get_workqueue(CACHETABLE ct) { WORKQUEUE toku_cachetable_get_workqueue(CACHETABLE ct) {
...@@ -361,14 +361,14 @@ void toku_cachefile_get_workqueue_load (CACHEFILE cf, int *n_in_queue, int *n_th ...@@ -361,14 +361,14 @@ void toku_cachefile_get_workqueue_load (CACHEFILE cf, int *n_in_queue, int *n_th
*n_threads = threadpool_get_current_threads(ct->threadpool); *n_threads = threadpool_get_current_threads(ct->threadpool);
} }
int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname) { int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname_relative_to_env) {
int r; int r;
struct fileid fileid; struct fileid fileid;
r=toku_os_get_unique_file_id(fd, &fileid); r=toku_os_get_unique_file_id(fd, &fileid);
if (r != 0) { if (r != 0) {
r=errno; close(fd); return r; r=errno; close(fd); return r;
} }
if (cf->close_userdata && (r = cf->close_userdata(cf, cf->userdata, 0))) { if (cf->close_userdata && (r = cf->close_userdata(cf, cf->userdata, 0, ZERO_LSN))) {
return r; return r;
} }
cf->close_userdata = NULL; cf->close_userdata = NULL;
...@@ -379,11 +379,11 @@ int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname) { ...@@ -379,11 +379,11 @@ int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname) {
close(cf->fd); close(cf->fd);
cf->fd = -1; cf->fd = -1;
if (cf->fname) { if (cf->fname_relative_to_env) {
toku_free(cf->fname); toku_free(cf->fname_relative_to_env);
cf->fname = 0; cf->fname_relative_to_env = 0;
} }
cachefile_init_filenum(cf, fd, fname, fileid); cachefile_init_filenum(cf, fd, fname_relative_to_env, fileid);
return 0; return 0;
} }
...@@ -393,13 +393,13 @@ int toku_cachefile_fd (CACHEFILE cf) { ...@@ -393,13 +393,13 @@ int toku_cachefile_fd (CACHEFILE cf) {
BOOL BOOL
toku_cachefile_is_dev_null (CACHEFILE cf) { toku_cachefile_is_dev_null (CACHEFILE cf) {
return cf->fname==NULL; return cf->fname_relative_to_env==NULL;
} }
int int
toku_cachefile_truncate (CACHEFILE cf, toku_off_t new_size) { toku_cachefile_truncate (CACHEFILE cf, toku_off_t new_size) {
int r; int r;
if (cf->fname==NULL) r = 0; //Don't truncate /dev/null if (cf->fname_relative_to_env==NULL) r = 0; //Don't truncate /dev/null
else { else {
r = ftruncate(cf->fd, new_size); r = ftruncate(cf->fd, new_size);
if (r != 0) if (r != 0)
...@@ -420,7 +420,7 @@ static CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) { ...@@ -420,7 +420,7 @@ static CACHEFILE remove_cf_from_list (CACHEFILE cf, CACHEFILE list) {
static int cachetable_flush_cachefile (CACHETABLE, CACHEFILE cf); static int cachetable_flush_cachefile (CACHETABLE, CACHEFILE cf);
int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string) { int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string, LSN lsn) {
CACHEFILE cf = *cfp; CACHEFILE cf = *cfp;
CACHETABLE ct = cf->cachetable; CACHETABLE ct = cf->cachetable;
...@@ -451,7 +451,7 @@ int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string ...@@ -451,7 +451,7 @@ int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string
int rd = toku_pthread_cond_destroy(&cf->openfd_wait); int rd = toku_pthread_cond_destroy(&cf->openfd_wait);
assert(rd == 0); assert(rd == 0);
} }
if (cf->fname) toku_free(cf->fname); if (cf->fname_relative_to_env) toku_free(cf->fname_relative_to_env);
int r2 = close(cf->fd); int r2 = close(cf->fd);
if (r2!=0) fprintf(stderr, "%s:%d During error handling, could not close file r=%d errno=%d\n", __FILE__, __LINE__, r2, errno); if (r2!=0) fprintf(stderr, "%s:%d During error handling, could not close file r=%d errno=%d\n", __FILE__, __LINE__, r2, errno);
//assert(r == 0); //assert(r == 0);
...@@ -460,7 +460,7 @@ int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string ...@@ -460,7 +460,7 @@ int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string
cachetable_unlock(ct); cachetable_unlock(ct);
return r; return r;
} }
if (cf->close_userdata && (r = cf->close_userdata(cf, cf->userdata, error_string))) { if (cf->close_userdata && (r = cf->close_userdata(cf, cf->userdata, error_string, lsn))) {
goto error; goto error;
} }
cf->close_userdata = NULL; cf->close_userdata = NULL;
...@@ -490,7 +490,8 @@ int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string ...@@ -490,7 +490,8 @@ int toku_cachefile_close (CACHEFILE *cfp, TOKULOGGER logger, char **error_string
//BYTESTRING bs = {.len=strlen(cf->fname), .data=cf->fname}; //BYTESTRING bs = {.len=strlen(cf->fname), .data=cf->fname};
//r = toku_log_cfclose(logger, 0, 0, bs, cf->filenum); //r = toku_log_cfclose(logger, 0, 0, bs, cf->filenum);
} }
if (cf->fname) toku_free(cf->fname);
if (cf->fname_relative_to_env) toku_free(cf->fname_relative_to_env);
toku_free(cf); toku_free(cf);
*cfp=NULL; *cfp=NULL;
return r; return r;
...@@ -1575,7 +1576,7 @@ toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER logger) { ...@@ -1575,7 +1576,7 @@ toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER logger) {
if (logger) { if (logger) {
// The checkpoint must be performed after the lock is acquired. // The checkpoint must be performed after the lock is acquired.
{ {
LSN begin_lsn; LSN begin_lsn; // we'll need to store the lsn of the checkpoint begin in all the trees that are checkpointed.
int r = toku_log_begin_checkpoint(logger, &begin_lsn, 0); int r = toku_log_begin_checkpoint(logger, &begin_lsn, 0);
ct->lsn_of_checkpoint_in_progress = begin_lsn; ct->lsn_of_checkpoint_in_progress = begin_lsn;
assert(r==0); assert(r==0);
...@@ -1590,8 +1591,8 @@ toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER logger) { ...@@ -1590,8 +1591,8 @@ toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER logger) {
//Must loop through ALL open files (even if not included in checkpoint). //Must loop through ALL open files (even if not included in checkpoint).
CACHEFILE cf; CACHEFILE cf;
for (cf = ct->cachefiles; cf; cf=cf->next) { for (cf = ct->cachefiles; cf; cf=cf->next) {
BYTESTRING bs = { strlen(cf->fname), // don't include the NUL BYTESTRING bs = { strlen(cf->fname_relative_to_env), // don't include the NUL
cf->fname }; cf->fname_relative_to_env };
int r = toku_log_fassociate(logger, NULL, 0, cf->filenum, bs); int r = toku_log_fassociate(logger, NULL, 0, cf->filenum, bs);
assert(r==0); assert(r==0);
} }
...@@ -1700,7 +1701,7 @@ toku_cachetable_end_checkpoint(CACHETABLE ct, TOKULOGGER logger, char **error_st ...@@ -1700,7 +1701,7 @@ toku_cachetable_end_checkpoint(CACHETABLE ct, TOKULOGGER logger, char **error_st
ct->cachefiles_in_checkpoint = cf->next_in_checkpoint; ct->cachefiles_in_checkpoint = cf->next_in_checkpoint;
cf->next_in_checkpoint = NULL; cf->next_in_checkpoint = NULL;
cf->for_checkpoint = FALSE; cf->for_checkpoint = FALSE;
int r = toku_cachefile_close(&cf, logger, error_string); int r = toku_cachefile_close(&cf, logger, error_string, ct->lsn_of_checkpoint_in_progress);
if (r!=0) { if (r!=0) {
retval = r; retval = r;
goto panic; goto panic;
...@@ -1855,7 +1856,7 @@ int toku_cachetable_get_key_state (CACHETABLE ct, CACHEKEY key, CACHEFILE cf, vo ...@@ -1855,7 +1856,7 @@ int toku_cachetable_get_key_state (CACHETABLE ct, CACHEKEY key, CACHEFILE cf, vo
void void
toku_cachefile_set_userdata (CACHEFILE cf, toku_cachefile_set_userdata (CACHEFILE cf,
void *userdata, void *userdata,
int (*close_userdata)(CACHEFILE, void*, char**), int (*close_userdata)(CACHEFILE, void*, char**, LSN),
int (*checkpoint_userdata)(CACHEFILE, void*), int (*checkpoint_userdata)(CACHEFILE, void*),
int (*begin_checkpoint_userdata)(CACHEFILE, LSN, void*), int (*begin_checkpoint_userdata)(CACHEFILE, LSN, void*),
int (*end_checkpoint_userdata)(CACHEFILE, void*)) { int (*end_checkpoint_userdata)(CACHEFILE, void*)) {
...@@ -1874,7 +1875,7 @@ int ...@@ -1874,7 +1875,7 @@ int
toku_cachefile_fsync(CACHEFILE cf) { toku_cachefile_fsync(CACHEFILE cf) {
int r; int r;
if (cf->fname==NULL) r = 0; //Don't fsync /dev/null if (cf->fname_relative_to_env==NULL) r = 0; //Don't fsync /dev/null
else r = fsync(cf->fd); else r = fsync(cf->fd);
return r; return r;
} }
...@@ -1888,9 +1889,9 @@ int toku_cachefile_redirect_nullfd (CACHEFILE cf) { ...@@ -1888,9 +1889,9 @@ int toku_cachefile_redirect_nullfd (CACHEFILE cf) {
toku_os_get_unique_file_id(null_fd, &fileid); toku_os_get_unique_file_id(null_fd, &fileid);
close(cf->fd); close(cf->fd);
cf->fd = null_fd; cf->fd = null_fd;
if (cf->fname) { if (cf->fname_relative_to_env) {
toku_free(cf->fname); toku_free(cf->fname_relative_to_env);
cf->fname = 0; cf->fname_relative_to_env = 0;
} }
cachefile_init_filenum(cf, null_fd, NULL, fileid); cachefile_init_filenum(cf, null_fd, NULL, fileid);
return 0; return 0;
......
...@@ -63,10 +63,10 @@ void toku_cachetable_minicron_shutdown(CACHETABLE ct); ...@@ -63,10 +63,10 @@ void toku_cachetable_minicron_shutdown(CACHETABLE ct);
int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */ int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */
// Open a file and bind the file to a new cachefile object. // Open a file and bind the file to a new cachefile object.
int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname*/, int flags, mode_t mode); int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname*/, const char */*fname_relative_to_env*/,int flags, mode_t mode);
// Bind a file to a new cachefile object. // Bind a file to a new cachefile object.
int toku_cachetable_openfd (CACHEFILE *,CACHETABLE, int /*fd*/, const char */*fname (used for logging)*/); int toku_cachetable_openfd (CACHEFILE *,CACHETABLE, int /*fd*/, const char *fname_relative_to_env /*(used for logging)*/);
// Get access to the asynchronous work queue // Get access to the asynchronous work queue
// Returns: a pointer to the work queue // Returns: a pointer to the work queue
...@@ -87,7 +87,7 @@ typedef void (*CACHETABLE_FLUSH_CALLBACK)(CACHEFILE, CACHEKEY key, void *value, ...@@ -87,7 +87,7 @@ typedef void (*CACHETABLE_FLUSH_CALLBACK)(CACHEFILE, CACHEKEY key, void *value,
// associated with the key are returned. // associated with the key are returned.
typedef int (*CACHETABLE_FETCH_CALLBACK)(CACHEFILE, CACHEKEY key, u_int32_t fullhash, void **value, long *sizep, void *extraargs, LSN *written_lsn); typedef int (*CACHETABLE_FETCH_CALLBACK)(CACHEFILE, CACHEKEY key, u_int32_t fullhash, void **value, long *sizep, void *extraargs, LSN *written_lsn);
void toku_cachefile_set_userdata(CACHEFILE cf, void *userdata, int (*close_userdata)(CACHEFILE, void*, char **/*error_string*/), int (*checkpoint_userdata)(CACHEFILE, void*), int (*begin_checkpoint_userdata)(CACHEFILE, LSN, void*), int (*end_checkpoint_userdata)(CACHEFILE, void*)); void toku_cachefile_set_userdata(CACHEFILE cf, void *userdata, int (*close_userdata)(CACHEFILE, void*, char **/*error_string*/, LSN), int (*checkpoint_userdata)(CACHEFILE, void*), int (*begin_checkpoint_userdata)(CACHEFILE, LSN, void*), int (*end_checkpoint_userdata)(CACHEFILE, void*));
// Effect: Store some cachefile-specific user data. When the last reference to a cachefile is closed, we call close_userdata(). // Effect: Store some cachefile-specific user data. When the last reference to a cachefile is closed, we call close_userdata().
// Before starting a checkpoint, we call checkpoint_prepare_userdata(). // Before starting a checkpoint, we call checkpoint_prepare_userdata().
// When the cachefile needs to be checkpointed, we call checkpoint_userdata(). // When the cachefile needs to be checkpointed, we call checkpoint_userdata().
...@@ -165,7 +165,7 @@ int toku_cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newke ...@@ -165,7 +165,7 @@ int toku_cachetable_rename (CACHEFILE cachefile, CACHEKEY oldkey, CACHEKEY newke
// close function does not return until all of the objects are evicted. The cachefile // close function does not return until all of the objects are evicted. The cachefile
// object is freed. // object is freed.
// Returns: 0 if success, otherwise returns an error number. // Returns: 0 if success, otherwise returns an error number.
int toku_cachefile_close (CACHEFILE*, TOKULOGGER, char **error_string); int toku_cachefile_close (CACHEFILE*, TOKULOGGER, char **error_string, LSN);
// Flush the cachefile. // Flush the cachefile.
// Effect: Flush everything owned by the cachefile from the cachetable. All dirty // Effect: Flush everything owned by the cachefile from the cachetable. All dirty
...@@ -184,7 +184,7 @@ int toku_cachefile_fd (CACHEFILE); ...@@ -184,7 +184,7 @@ int toku_cachefile_fd (CACHEFILE);
// Set the cachefile's fd and fname. // Set the cachefile's fd and fname.
// Effect: Bind the cachefile to a new fd and fname. The old fd is closed. // Effect: Bind the cachefile to a new fd and fname. The old fd is closed.
// Returns: 0 if success, otherwise an error number // Returns: 0 if success, otherwise an error number
int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname); int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname_relative_to_env);
// Equivalent to toku_cachefile_set_fd to /dev/null but without // Equivalent to toku_cachefile_set_fd to /dev/null but without
// closing the user data. // closing the user data.
......
...@@ -80,7 +80,7 @@ struct tokulogger { ...@@ -80,7 +80,7 @@ struct tokulogger {
}; };
int toku_logger_find_next_unused_log_file(const char *directory, long long *result); int toku_logger_find_next_unused_log_file(const char *directory, long long *result);
int toku_logger_find_logfiles (const char *directory, char ***resultp); int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_logfiles);
struct brtcachefile_pair { struct brtcachefile_pair {
BRT brt; BRT brt;
......
...@@ -58,7 +58,9 @@ logfilenamecompare (const void *ap, const void *bp) { ...@@ -58,7 +58,9 @@ logfilenamecompare (const void *ap, const void *bp) {
return strcmp(a,b); return strcmp(a,b);
} }
int toku_logger_find_logfiles (const char *directory, char ***resultp) { // Return the log files in sorted order
// Return a null_terminated array of strings, and also return the number of strings in the array.
int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_logfiles) {
int result_limit=2; int result_limit=2;
int n_results=0; int n_results=0;
char **MALLOC_N(result_limit, result); char **MALLOC_N(result_limit, result);
...@@ -85,6 +87,7 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp) { ...@@ -85,6 +87,7 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp) {
// Return them in increasing order. // Return them in increasing order.
qsort(result, n_results, sizeof(result[0]), logfilenamecompare); qsort(result, n_results, sizeof(result[0]), logfilenamecompare);
*resultp = result; *resultp = result;
*n_logfiles = n_results;
result[n_results]=0; // make a trailing null result[n_results]=0; // make a trailing null
return d ? closedir(d) : 0; return d ? closedir(d) : 0;
} }
...@@ -953,7 +956,8 @@ int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags) { ...@@ -953,7 +956,8 @@ int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags) {
int all_n_logs; int all_n_logs;
int i; int i;
char **all_logs; char **all_logs;
int r = toku_logger_find_logfiles (logger->directory, &all_logs); int n_logfiles;
int r = toku_logger_find_logfiles (logger->directory, &all_logs, &n_logfiles);
if (r!=0) return r; if (r!=0) return r;
for (i=0; all_logs[i]; i++); for (i=0; all_logs[i]; i++);
......
...@@ -364,6 +364,24 @@ generate_log_reader (void) { ...@@ -364,6 +364,24 @@ generate_log_reader (void) {
fprintf(cf, " };\n"); fprintf(cf, " };\n");
fprintf(cf, " return DB_BADFORMAT;\n"); // Should read past the record using the len field. fprintf(cf, " return DB_BADFORMAT;\n"); // Should read past the record using the len field.
fprintf(cf, "}\n\n"); fprintf(cf, "}\n\n");
fprintf2(cf, hf, "// Return 0 if there is something to read, return -1 if nothing to read, abort if an error.\n");
fprintf2(cf, hf, "int toku_log_fread_backward (FILE *infile, struct log_entry *le)");
fprintf(hf, ";\n");
fprintf(cf, "{\n");
fprintf(cf, " {\n long pos = ftell(infile);\n if (pos<=12) return -1;\n }\n");
fprintf(cf, " int r = fseek(infile, -4, SEEK_CUR); assert(r==0);\n");
//fprintf(cf, " if (r!=0) return errno;\n");
fprintf(cf, " u_int32_t len;\n");
fprintf(cf, " r = toku_fread_u_int32_t_nocrclen(infile, &len); assert(r==0);\n");
//fprintf(cf, " if (r!=0) return r;\n");
fprintf(cf, " r = fseek(infile, -(int)len, SEEK_CUR) ; assert(r==0);\n");
//fprintf(cf, " if (r!=0) return errno;\n");
fprintf(cf, " r = toku_log_fread(infile, le); assert(r==0);\n");
//fprintf(cf, " if (r!=0) return r;\n");
fprintf(cf, " r = fseek(infile, -(int)len, SEEK_CUR); assert(r==0);\n");
//fprintf(cf, " if (r!=0) return errno;\n");
fprintf(cf, " return 0;\n");
fprintf(cf, "}\n");
} }
static void static void
......
This diff is collapsed.
...@@ -105,7 +105,7 @@ static void checkpoint_pending(void) { ...@@ -105,7 +105,7 @@ static void checkpoint_pending(void) {
r = toku_create_cachetable(&ct, test_limit*sizeof(int), ZERO_LSN, NULL_LOGGER); assert(r == 0); r = toku_create_cachetable(&ct, test_limit*sizeof(int), ZERO_LSN, NULL_LOGGER); assert(r == 0);
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&cf, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// Insert items into the cachetable. All dirty. // Insert items into the cachetable. All dirty.
int i; int i;
...@@ -147,7 +147,7 @@ static void checkpoint_pending(void) { ...@@ -147,7 +147,7 @@ static void checkpoint_pending(void) {
assert(r == 0); assert(r == 0);
assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0); assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0);
r = toku_cachefile_close(&cf, NULL_LOGGER, 0); assert(r == 0 && cf == 0); r = toku_cachefile_close(&cf, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && cf == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -48,7 +48,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) { ...@@ -48,7 +48,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// insert items into the cachetable. all should be dirty // insert items into the cachetable. all should be dirty
int i; int i;
...@@ -112,7 +112,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) { ...@@ -112,7 +112,7 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
assert(r == 0); assert(r == 0);
assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0); assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -35,7 +35,7 @@ cachetable_count_pinned_test (int n) { ...@@ -35,7 +35,7 @@ cachetable_count_pinned_test (int n) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i; int i;
for (i=1; i<=n; i++) { for (i=1; i<=n; i++) {
...@@ -66,7 +66,7 @@ cachetable_count_pinned_test (int n) { ...@@ -66,7 +66,7 @@ cachetable_count_pinned_test (int n) {
assert(toku_cachefile_count_pinned(f1, 1) == 0); assert(toku_cachefile_count_pinned(f1, 1) == 0);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -35,7 +35,7 @@ cachetable_debug_test (int n) { ...@@ -35,7 +35,7 @@ cachetable_debug_test (int n) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int num_entries, hash_size; long size_current, size_limit; int num_entries, hash_size; long size_current, size_limit;
toku_cachetable_get_state(ct, &num_entries, &hash_size, &size_current, &size_limit); toku_cachetable_get_state(ct, &num_entries, &hash_size, &size_current, &size_limit);
...@@ -74,7 +74,7 @@ cachetable_debug_test (int n) { ...@@ -74,7 +74,7 @@ cachetable_debug_test (int n) {
if (verbose) toku_cachetable_print_hash_histogram(); if (verbose) toku_cachetable_print_hash_histogram();
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -11,7 +11,7 @@ cachetable_fd_test (void) { ...@@ -11,7 +11,7 @@ cachetable_fd_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE cf; CACHEFILE cf;
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&cf, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int fd1 = toku_cachefile_fd(cf); assert(fd1 >= 0); int fd1 = toku_cachefile_fd(cf); assert(fd1 >= 0);
...@@ -39,7 +39,7 @@ cachetable_fd_test (void) { ...@@ -39,7 +39,7 @@ cachetable_fd_test (void) {
r = toku_cachefile_of_filenum(ct, fn, &newcf); r = toku_cachefile_of_filenum(ct, fn, &newcf);
assert(r == ENOENT); assert(r == ENOENT);
r = toku_cachefile_close(&cf, NULL_LOGGER, 0); assert(r == 0 && cf == 0); r = toku_cachefile_close(&cf, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && cf == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -35,12 +35,12 @@ test_cachetable_flush (int n) { ...@@ -35,12 +35,12 @@ test_cachetable_flush (int n) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
char fname2[] = __FILE__ "test2.dat"; char fname2[] = __FILE__ "test2.dat";
unlink(fname2); unlink(fname2);
CACHEFILE f2; CACHEFILE f2;
r = toku_cachetable_openf(&f2, ct, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f2, ct, fname2, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// insert keys 0..n-1 // insert keys 0..n-1
int i; int i;
...@@ -93,8 +93,8 @@ test_cachetable_flush (int n) { ...@@ -93,8 +93,8 @@ test_cachetable_flush (int n) {
assert(r == 0); assert(r == 0);
} }
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachefile_close(&f2, NULL_LOGGER, 0); assert(r == 0 && f2 == 0); r = toku_cachefile_close(&f2, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f2 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -44,7 +44,7 @@ cachetable_getandpin_test (int n) { ...@@ -44,7 +44,7 @@ cachetable_getandpin_test (int n) {
char fname1[] = __FILE__ "test_getandpin.dat"; char fname1[] = __FILE__ "test_getandpin.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i; int i;
...@@ -71,7 +71,7 @@ cachetable_getandpin_test (int n) { ...@@ -71,7 +71,7 @@ cachetable_getandpin_test (int n) {
} }
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -42,7 +42,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir ...@@ -42,7 +42,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// prefetch block n+1. this will take 10 seconds. // prefetch block n+1. this will take 10 seconds.
{ {
...@@ -112,7 +112,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir ...@@ -112,7 +112,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
assert(r == 0); assert(r == 0);
assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0); assert(n_flush == 0 && n_write_me == 0 && n_keep_me == 0);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -47,7 +47,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -47,7 +47,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// prefetch block 0. this will take 10 seconds. // prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0); CACHEKEY key = make_blocknum(0);
...@@ -57,7 +57,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -57,7 +57,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
// close with the prefetch in progress. the close should block until // close with the prefetch in progress. the close should block until
// all of the reads and writes are complete. // all of the reads and writes are complete.
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -48,7 +48,7 @@ static void cachetable_prefetch_close_leak_test (void) { ...@@ -48,7 +48,7 @@ static void cachetable_prefetch_close_leak_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// prefetch block 0. this will take 10 seconds. // prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0); CACHEKEY key = make_blocknum(0);
...@@ -58,7 +58,7 @@ static void cachetable_prefetch_close_leak_test (void) { ...@@ -58,7 +58,7 @@ static void cachetable_prefetch_close_leak_test (void) {
// close with the prefetch in progress. the close should block until // close with the prefetch in progress. the close should block until
// all of the reads and writes are complete. // all of the reads and writes are complete.
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -47,7 +47,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -47,7 +47,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// prefetch block 0. this will take 10 seconds. // prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0); CACHEKEY key = make_blocknum(0);
...@@ -57,7 +57,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -57,7 +57,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
// close with the prefetch in progress. the close should block until // close with the prefetch in progress. the close should block until
// all of the reads and writes are complete. // all of the reads and writes are complete.
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -50,7 +50,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -50,7 +50,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
struct timeval tstart; struct timeval tstart;
gettimeofday(&tstart, NULL); gettimeofday(&tstart, NULL);
...@@ -74,7 +74,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -74,7 +74,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -50,7 +50,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -50,7 +50,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
struct timeval tstart; struct timeval tstart;
gettimeofday(&tstart, NULL); gettimeofday(&tstart, NULL);
...@@ -78,7 +78,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -78,7 +78,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
assert(r == 0); assert(r == 0);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -44,7 +44,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -44,7 +44,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// prefetch block 0. this will take 10 seconds. // prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0); CACHEKEY key = make_blocknum(0);
...@@ -68,7 +68,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -68,7 +68,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
assert(r == 0); assert(r == 0);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -48,7 +48,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -48,7 +48,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
// prefetch block 0. this will take 10 seconds. // prefetch block 0. this will take 10 seconds.
CACHEKEY key = make_blocknum(0); CACHEKEY key = make_blocknum(0);
...@@ -79,7 +79,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) { ...@@ -79,7 +79,7 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
assert(r == 0); assert(r == 0);
toku_cachetable_verify(ct); toku_cachetable_verify(ct);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -35,7 +35,7 @@ cachetable_put_test (int n) { ...@@ -35,7 +35,7 @@ cachetable_put_test (int n) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i; int i;
for (i=1; i<=n; i++) { for (i=1; i<=n; i++) {
...@@ -78,7 +78,7 @@ cachetable_put_test (int n) { ...@@ -78,7 +78,7 @@ cachetable_put_test (int n) {
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, 1); r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, 1);
assert(r != 0); assert(r != 0);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -88,7 +88,7 @@ static void test_rename (void) { ...@@ -88,7 +88,7 @@ static void test_rename (void) {
const char fname[] = __FILE__ "rename.dat"; const char fname[] = __FILE__ "rename.dat";
r=toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); r=toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
unlink(fname); unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r==0); assert(r==0);
for (i=0; i<TRIALLIMIT; i++) { for (i=0; i<TRIALLIMIT; i++) {
int ra = random()%3; int ra = random()%3;
...@@ -159,7 +159,7 @@ static void test_rename (void) { ...@@ -159,7 +159,7 @@ static void test_rename (void) {
r = toku_cachetable_rename(f, okey, nkey); r = toku_cachetable_rename(f, okey, nkey);
assert(r != 0); assert(r != 0);
r = toku_cachefile_close(&f, 0, 0); r = toku_cachefile_close(&f, 0, 0, ZERO_LSN);
assert(r == 0); assert(r == 0);
r = toku_cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
......
...@@ -49,7 +49,7 @@ CACHEFILE f; ...@@ -49,7 +49,7 @@ CACHEFILE f;
static void open_file (void ) { static void open_file (void ) {
int r; int r;
r = toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_create_cachetable(&t, KEYLIMIT, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
} }
static void writeit (void) { static void writeit (void) {
...@@ -85,7 +85,7 @@ static void readit (void) { ...@@ -85,7 +85,7 @@ static void readit (void) {
r=toku_cachetable_get_and_pin(f, key, fullhash, &block, &current_size, f_flush, f_fetch, 0); assert(r==0); r=toku_cachetable_get_and_pin(f, key, fullhash, &block, &current_size, f_flush, f_fetch, 0); assert(r==0);
r=toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, BLOCKSIZE); assert(r==0); r=toku_cachetable_unpin(f, key, fullhash, CACHETABLE_CLEAN, BLOCKSIZE); assert(r==0);
} }
r = toku_cachefile_close(&f, 0, 0); assert(r == 0); r = toku_cachefile_close(&f, 0, 0, ZERO_LSN); assert(r == 0);
r = toku_cachetable_close(&t); assert(r == 0); r = toku_cachetable_close(&t); assert(r == 0);
gettimeofday(&end, 0); gettimeofday(&end, 0);
toku_os_get_process_times(&end_usertime, &end_systime); toku_os_get_process_times(&end_usertime, &end_systime);
......
...@@ -173,7 +173,7 @@ static void test0 (void) { ...@@ -173,7 +173,7 @@ static void test0 (void) {
r=toku_create_cachetable(&t, 5, ZERO_LSN, NULL_LOGGER); r=toku_create_cachetable(&t, 5, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r==0); assert(r==0);
TOKULOGGER logger = toku_cachefile_logger(f); TOKULOGGER logger = toku_cachefile_logger(f);
...@@ -288,7 +288,7 @@ static void test0 (void) { ...@@ -288,7 +288,7 @@ static void test0 (void) {
expectN(7); expectN(7);
expectN(6); expectN(6);
expectN(1); expectN(1);
r=toku_cachefile_close(&f, 0, 0); r=toku_cachefile_close(&f, 0, 0, ZERO_LSN);
assert(r==0); assert(r==0);
r=toku_cachetable_close(&t); r=toku_cachetable_close(&t);
assert(r==0); assert(r==0);
...@@ -327,7 +327,7 @@ static void test_nested_pin (void) { ...@@ -327,7 +327,7 @@ static void test_nested_pin (void) {
r = toku_create_cachetable(&t, 1, ZERO_LSN, NULL_LOGGER); r = toku_create_cachetable(&t, 1, ZERO_LSN, NULL_LOGGER);
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r==0); assert(r==0);
expect_f = f; expect_f = f;
...@@ -354,7 +354,7 @@ static void test_nested_pin (void) { ...@@ -354,7 +354,7 @@ static void test_nested_pin (void) {
r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, CACHETABLE_CLEAN, test_object_size); r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, CACHETABLE_CLEAN, test_object_size);
assert(r==0); assert(r==0);
// toku_os_usleep(1*1000000); // toku_os_usleep(1*1000000);
r = toku_cachefile_close(&f, 0, 0); assert(r==0); r = toku_cachefile_close(&f, 0, 0, ZERO_LSN); assert(r==0);
r = toku_cachetable_close(&t); assert(r==0); r = toku_cachetable_close(&t); assert(r==0);
} }
...@@ -399,10 +399,10 @@ static void test_multi_filehandles (void) { ...@@ -399,10 +399,10 @@ static void test_multi_filehandles (void) {
unlink(fname2); unlink(fname2);
r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER); assert(r==0); r = toku_create_cachetable(&t, 4, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_cachetable_openf(&f1, t, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); r = toku_cachetable_openf(&f1, t, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
r = link(fname1, fname2); assert(r==0); r = link(fname1, fname2); assert(r==0);
r = toku_cachetable_openf(&f2, t, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); r = toku_cachetable_openf(&f2, t, fname2, fname2, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
r = toku_cachetable_openf(&f3, t, fname3, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); r = toku_cachetable_openf(&f3, t, fname3, fname3, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
assert(f1==f2); assert(f1==f2);
assert(f1!=f3); assert(f1!=f3);
...@@ -419,14 +419,14 @@ static void test_multi_filehandles (void) { ...@@ -419,14 +419,14 @@ static void test_multi_filehandles (void) {
r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0); r = toku_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0);
r = toku_cachetable_unpin(f1, make_blocknum(2), toku_cachetable_hash(f1, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0); r = toku_cachetable_unpin(f1, make_blocknum(2), toku_cachetable_hash(f1, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0);
r = toku_cachefile_close(&f1, 0, 0); assert(r==0); r = toku_cachefile_close(&f1, 0, 0, ZERO_LSN); assert(r==0);
r = toku_cachetable_unpin(f2, make_blocknum(1), toku_cachetable_hash(f2, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0); r = toku_cachetable_unpin(f2, make_blocknum(1), toku_cachetable_hash(f2, make_blocknum(1)), CACHETABLE_CLEAN, 0); assert(r==0);
r = toku_cachetable_unpin(f2, make_blocknum(2), toku_cachetable_hash(f2, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0); r = toku_cachetable_unpin(f2, make_blocknum(2), toku_cachetable_hash(f2, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0);
r = toku_cachefile_close(&f2, 0, 0); assert(r==0); r = toku_cachefile_close(&f2, 0, 0, ZERO_LSN); assert(r==0);
r = toku_cachetable_unpin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0); r = toku_cachetable_unpin(f3, make_blocknum(2), toku_cachetable_hash(f3, make_blocknum(2)), CACHETABLE_CLEAN, 0); assert(r==0);
r = toku_cachefile_close(&f3, 0, 0); assert(r==0); r = toku_cachefile_close(&f3, 0, 0, ZERO_LSN); assert(r==0);
r = toku_cachetable_close(&t); assert(r==0); r = toku_cachetable_close(&t); assert(r==0);
} }
...@@ -466,7 +466,7 @@ static void test_dirty() { ...@@ -466,7 +466,7 @@ static void test_dirty() {
char *fname = __FILE__ "test.dat"; char *fname = __FILE__ "test.dat";
unlink(fname); unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0); assert(r == 0);
key = make_blocknum(1); value = (void*)1; key = make_blocknum(1); value = (void*)1;
...@@ -548,7 +548,7 @@ static void test_dirty() { ...@@ -548,7 +548,7 @@ static void test_dirty() {
assert(dirty == 1); assert(dirty == 1);
assert(pinned == 0); assert(pinned == 0);
r = toku_cachefile_close(&f, 0, 0); r = toku_cachefile_close(&f, 0, 0, ZERO_LSN);
assert(r == 0); assert(r == 0);
r = toku_cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
...@@ -592,7 +592,7 @@ static void test_size_resize() { ...@@ -592,7 +592,7 @@ static void test_size_resize() {
char *fname = __FILE__ "test.dat"; char *fname = __FILE__ "test.dat";
unlink(fname); unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0); assert(r == 0);
CACHEKEY key = make_blocknum(42); CACHEKEY key = make_blocknum(42);
...@@ -625,7 +625,7 @@ static void test_size_resize() { ...@@ -625,7 +625,7 @@ static void test_size_resize() {
r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, new_size); r = toku_cachetable_unpin(f, key, hkey, CACHETABLE_CLEAN, new_size);
assert(r == 0); assert(r == 0);
r = toku_cachefile_close(&f, 0, 0); r = toku_cachefile_close(&f, 0, 0, ZERO_LSN);
assert(r == 0); assert(r == 0);
r = toku_cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
...@@ -647,7 +647,7 @@ static void test_size_flush() { ...@@ -647,7 +647,7 @@ static void test_size_flush() {
char *fname = __FILE__ "test.dat"; char *fname = __FILE__ "test.dat";
unlink(fname); unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); r = toku_cachetable_openf(&f, t, fname, fname, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
assert(r == 0); assert(r == 0);
/* put 2*n keys into the table, ensure flushes occur in key order */ /* put 2*n keys into the table, ensure flushes occur in key order */
...@@ -693,7 +693,7 @@ static void test_size_flush() { ...@@ -693,7 +693,7 @@ static void test_size_flush() {
assert(r == 0); assert(r == 0);
} }
r = toku_cachefile_close(&f, 0, 0); r = toku_cachefile_close(&f, 0, 0, ZERO_LSN);
assert(r == 0); assert(r == 0);
r = toku_cachetable_close(&t); r = toku_cachetable_close(&t);
assert(r == 0); assert(r == 0);
......
...@@ -156,7 +156,7 @@ static void test_chaining (void) { ...@@ -156,7 +156,7 @@ static void test_chaining (void) {
r = snprintf(fname[i], FILENAME_LEN, __FILE__ ".%ld.dat", i); r = snprintf(fname[i], FILENAME_LEN, __FILE__ ".%ld.dat", i);
assert(r>0 && r<FILENAME_LEN); assert(r>0 && r<FILENAME_LEN);
unlink(fname[i]); unlink(fname[i]);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); r = toku_cachetable_openf(&f[i], ct, fname[i], fname[i], O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
} }
for (i=0; i<N_PRESENT_LIMIT; i++) { for (i=0; i<N_PRESENT_LIMIT; i++) {
int fnum = i%N_FILES; int fnum = i%N_FILES;
...@@ -227,13 +227,13 @@ static void test_chaining (void) { ...@@ -227,13 +227,13 @@ static void test_chaining (void) {
//printf("Close %d (%p), now n_present=%d\n", i, f[i], n_present); //printf("Close %d (%p), now n_present=%d\n", i, f[i], n_present);
//print_ints(); //print_ints();
CACHEFILE oldcf=f[i]; CACHEFILE oldcf=f[i];
r = toku_cachefile_close(&f[i], 0, 0); assert(r==0); r = toku_cachefile_close(&f[i], 0, 0, ZERO_LSN); assert(r==0);
file_is_not_present(oldcf); file_is_not_present(oldcf);
r = toku_cachetable_openf(&f[i], ct, fname[i], O_RDWR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0); r = toku_cachetable_openf(&f[i], ct, fname[i], fname[i], O_RDWR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r==0);
} }
} }
for (i=0; i<N_FILES; i++) { for (i=0; i<N_FILES; i++) {
r = toku_cachefile_close(&f[i], 0, 0); assert(r==0); r = toku_cachefile_close(&f[i], 0, 0, ZERO_LSN); assert(r==0);
} }
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
......
...@@ -35,7 +35,7 @@ cachetable_unpin_test (int n) { ...@@ -35,7 +35,7 @@ cachetable_unpin_test (int n) {
char fname1[] = __FILE__ "test1.dat"; char fname1[] = __FILE__ "test1.dat";
unlink(fname1); unlink(fname1);
CACHEFILE f1; CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_cachetable_openf(&f1, ct, fname1, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
int i; int i;
for (i=1; i<=n; i++) { for (i=1; i<=n; i++) {
...@@ -68,7 +68,7 @@ cachetable_unpin_test (int n) { ...@@ -68,7 +68,7 @@ cachetable_unpin_test (int n) {
r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, 1); r = toku_cachetable_unpin(f1, k, toku_cachetable_hash(f1, k), CACHETABLE_CLEAN, 1);
assert(r != 0); assert(r != 0);
r = toku_cachefile_close(&f1, NULL_LOGGER, 0); assert(r == 0 && f1 == 0); r = toku_cachefile_close(&f1, NULL_LOGGER, 0, ZERO_LSN); assert(r == 0 && f1 == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0); r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
} }
......
...@@ -9,6 +9,10 @@ DB_TXN *null_txn=0; ...@@ -9,6 +9,10 @@ DB_TXN *null_txn=0;
void do_test1753 (int do_create_on_reopen) { void do_test1753 (int do_create_on_reopen) {
if (IS_TDB==0 && DB_VERSION_MAJOR==4 && DB_VERSION_MINOR<7 && do_create_on_reopen==0) {
return; // do_create_on_reopen==0 segfaults in 4.6
}
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
int r; int r;
......
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