From 1ead590aecacbd86b90cb78a9bba5b08a3007513 Mon Sep 17 00:00:00 2001 From: Zardosht Kasheff Date: Tue, 16 Apr 2013 23:59:59 -0400 Subject: [PATCH] [t:4281], grab fdlock around reading of fd in bring_node_fully_into_memory git-svn-id: file:///svn/toku/tokudb@37884 c7de825b-a66e-492c-adef-691d508d4ae1 --- newbrt/brt.c | 26 +++++++++++++++++--------- newbrt/cachetable.c | 4 ---- newbrt/cachetable.h | 4 ---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/newbrt/brt.c b/newbrt/brt.c index f8201dbefcd..7c1c8c6ff7b 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -144,13 +144,18 @@ toku_brt_header_suppress_rollbacks(struct brt_header *h, TOKUTXN txn) { h->root_that_created_or_locked_when_empty = rootid; } - +static bool is_entire_node_in_memory(BRTNODE node) { + for (int i = 0; i < node->n_children; i++) { + if(BP_STATE(node,i) != PT_AVAIL) { + return false; + } + } + return true; +} void toku_assert_entire_node_in_memory(BRTNODE node) { - for (int i = 0; i < node->n_children; i++) { - assert(BP_STATE(node,i) == PT_AVAIL); - } + assert(is_entire_node_in_memory(node)); } static u_int32_t @@ -1941,11 +1946,14 @@ toku_bnc_flush_to_child( void bring_node_fully_into_memory(BRTNODE node, struct brt_header* h) { - struct brtnode_fetch_extra bfe; - PAIR_ATTR attr; - int fd = toku_cachefile_fd(h->cf); - fill_bfe_for_full_read(&bfe, h); - toku_brtnode_pf_callback(node, &bfe, fd, &attr); + if (!is_entire_node_in_memory(node)) { + struct brtnode_fetch_extra bfe; + PAIR_ATTR attr; + int fd = toku_cachefile_get_and_pin_fd(h->cf); + fill_bfe_for_full_read(&bfe, h); + toku_brtnode_pf_callback(node, &bfe, fd, &attr); + toku_cachefile_unpin_fd(h->cf); + } } static void diff --git a/newbrt/cachetable.c b/newbrt/cachetable.c index 54197b82944..54f5d2065e2 100644 --- a/newbrt/cachetable.c +++ b/newbrt/cachetable.c @@ -471,10 +471,6 @@ cachefile_refup (CACHEFILE cf) { cf->refcount++; } -int toku_cachefile_fd(CACHEFILE cf) { - return cf->fd; -} - // What cachefile goes with particular iname (iname relative to env)? // The transaction that is adding the reference might not have a reference // to the brt, therefore the cachefile might be closing. diff --git a/newbrt/cachetable.h b/newbrt/cachetable.h index 98b55697489..3b65a8fd633 100644 --- a/newbrt/cachetable.h +++ b/newbrt/cachetable.h @@ -60,10 +60,6 @@ int toku_cachefile_of_iname_in_env (CACHETABLE ct, const char *iname_in_env, CAC // Return the filename char * toku_cachefile_fname_in_cwd (CACHEFILE cf); -// return the fd -int toku_cachefile_fd(CACHEFILE cf); - - // TODO: #1510 Add comments on how these behave int toku_cachetable_begin_checkpoint (CACHETABLE ct, TOKULOGGER); int toku_cachetable_end_checkpoint(CACHETABLE ct, TOKULOGGER logger,