Commit 6fbe5cbf authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

close[t:4908]

cachefile openfd_mutex is gone

also clarified an error condition in ft_open


git-svn-id: file:///svn/toku/tokudb@43730 c7de825b-a66e-492c-adef-691d508d4ae1
parent 701bfc99
...@@ -195,7 +195,6 @@ static inline void ctpair_destroy(PAIR p) { ...@@ -195,7 +195,6 @@ static inline void ctpair_destroy(PAIR p) {
// The cachetable is as close to an ENV as we get. // The cachetable is as close to an ENV as we get.
// There are 3 locks, must be taken in this order // There are 3 locks, must be taken in this order
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held // TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
// openfd_mutex
// cachetable_mutex // cachetable_mutex
// cachefiles_mutex // cachefiles_mutex
struct cachetable { struct cachetable {
...@@ -238,8 +237,6 @@ struct cachetable { ...@@ -238,8 +237,6 @@ struct cachetable {
// minimum period of 1s so if you want // minimum period of 1s so if you want
// more frequent cleaner runs you must // more frequent cleaner runs you must
// use this) // use this)
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
toku_mutex_t openfd_mutex; // make toku_cachetable_openfd() single-threaded
char *env_dir; char *env_dir;
// variables for engine status // variables for engine status
...@@ -516,8 +513,6 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_l ...@@ -516,8 +513,6 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_l
toku_init_workers(&ct->wq, &ct->threadpool, 1); toku_init_workers(&ct->wq, &ct->threadpool, 1);
toku_init_workers(&ct->checkpoint_wq, &ct->checkpoint_threadpool, 8); toku_init_workers(&ct->checkpoint_wq, &ct->checkpoint_threadpool, 8);
ct->mutex = workqueue_lock_ref(&ct->wq); ct->mutex = workqueue_lock_ref(&ct->wq);
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
toku_mutex_init(&ct->openfd_mutex, NULL);
toku_mutex_init(&ct->cachefiles_mutex, 0); toku_mutex_init(&ct->cachefiles_mutex, 0);
ct->kibbutz = toku_kibbutz_create(toku_os_get_number_active_processors()); ct->kibbutz = toku_kibbutz_create(toku_os_get_number_active_processors());
...@@ -620,7 +615,6 @@ toku_cachetable_reserve_filenum(CACHETABLE ct) { ...@@ -620,7 +615,6 @@ toku_cachetable_reserve_filenum(CACHETABLE ct) {
CACHEFILE extant; CACHEFILE extant;
FILENUM filenum; FILENUM filenum;
invariant(ct); invariant(ct);
toku_mutex_lock(&ct->openfd_mutex); // purpose is to make this function single-threaded
cachetable_lock(ct); cachetable_lock(ct);
cachefiles_lock(ct); cachefiles_lock(ct);
try_again: try_again:
...@@ -634,7 +628,6 @@ toku_cachetable_reserve_filenum(CACHETABLE ct) { ...@@ -634,7 +628,6 @@ toku_cachetable_reserve_filenum(CACHETABLE ct) {
next_filenum_to_use.fileid++; next_filenum_to_use.fileid++;
cachefiles_unlock(ct); cachefiles_unlock(ct);
cachetable_unlock(ct); cachetable_unlock(ct);
toku_mutex_unlock(&ct->openfd_mutex); // purpose is to make this function single-threaded
return filenum; return filenum;
} }
...@@ -651,8 +644,6 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd ...@@ -651,8 +644,6 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
r=errno; close(fd); // no change for t:2444 r=errno; close(fd); // no change for t:2444
return r; return r;
} }
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
toku_mutex_lock(&ct->openfd_mutex); // purpose is to make this function single-threaded
cachetable_lock(ct); cachetable_lock(ct);
cachefiles_lock(ct); cachefiles_lock(ct);
for (extant = ct->cachefiles; extant; extant=extant->next) { for (extant = ct->cachefiles; extant; extant=extant->next) {
...@@ -695,8 +686,6 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd ...@@ -695,8 +686,6 @@ int toku_cachetable_openfd_with_filenum (CACHEFILE *cfptr, CACHETABLE ct, int fd
} }
exit: exit:
cachefiles_unlock(ct); cachefiles_unlock(ct);
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
toku_mutex_unlock(&ct->openfd_mutex);
cachetable_unlock(ct); cachetable_unlock(ct);
return r; return r;
} }
...@@ -3083,8 +3072,6 @@ toku_cachetable_close (CACHETABLE *ctp) { ...@@ -3083,8 +3072,6 @@ toku_cachetable_close (CACHETABLE *ctp) {
} }
assert(ct->size_evicting == 0); assert(ct->size_evicting == 0);
rwlock_destroy(&ct->pending_lock); rwlock_destroy(&ct->pending_lock);
// TODO: review the removal of this mutex, since it is only ever held when the ydb lock is held
toku_mutex_destroy(&ct->openfd_mutex);
cachetable_unlock(ct); cachetable_unlock(ct);
toku_destroy_workers(&ct->wq, &ct->threadpool); toku_destroy_workers(&ct->wq, &ct->threadpool);
toku_destroy_workers(&ct->checkpoint_wq, &ct->checkpoint_threadpool); toku_destroy_workers(&ct->checkpoint_wq, &ct->checkpoint_threadpool);
......
...@@ -3277,26 +3277,24 @@ ft_handle_open(FT_HANDLE t, const char *fname_in_env, int is_create, int only_cr ...@@ -3277,26 +3277,24 @@ ft_handle_open(FT_HANDLE t, const char *fname_in_env, int is_create, int only_cr
if (fname_in_cwd) { if (fname_in_cwd) {
toku_free(fname_in_cwd); toku_free(fname_in_cwd);
} }
if (r) { if (r != 0 && cf) {
if (cf) { if (t->h) {
if (t->h) { // we only call toku_ft_note_ft_handle_open
// we only call toku_ft_note_ft_handle_open // when the function succeeds, so if we are here,
// when the function succeeds, so if we are here, // then that means we have a reference to the header
// then that means we have a reference to the header // but we have not linked it to this brt. So,
// but we have not linked it to this brt. So, // we can simply try to remove the header.
// we can simply try to remove the header. // We don't need to unlink this brt from the header
// We don't need to unlink this brt from the header if (!toku_ft_needed(t->h)) {
if (!toku_ft_needed(t->h)) { //Close immediately.
//Close immediately. char *error_string = NULL;
char *error_string = NULL; r = toku_remove_ft(t->h, &error_string, false, ZERO_LSN);
r = toku_remove_ft(t->h, &error_string, false, ZERO_LSN); lazy_assert_zero(r);
lazy_assert_zero(r);
}
}
else {
toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN);
} }
} }
else {
toku_cachefile_close(&cf, 0, FALSE, ZERO_LSN);
}
} }
return r; return 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