Commit e34e06c1 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:3738], make dsn into a struct

git-svn-id: file:///svn/toku/tokudb@32906 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0166e268
...@@ -531,7 +531,7 @@ rebalance_brtnode_leaf(BRTNODE node) ...@@ -531,7 +531,7 @@ rebalance_brtnode_leaf(BRTNODE node)
for (int i = 0; i < node->n_children; i++) { for (int i = 0; i < node->n_children; i++) {
DSN curr_dsn = BLB_MAX_DSN_APPLIED(node,i); DSN curr_dsn = BLB_MAX_DSN_APPLIED(node,i);
MSN curr_msn = BLB_MAX_MSN_APPLIED(node,i); MSN curr_msn = BLB_MAX_MSN_APPLIED(node,i);
min_dsn = (curr_dsn < min_dsn) ? curr_dsn : min_dsn; min_dsn = (curr_dsn.dsn < min_dsn.dsn) ? curr_dsn : min_dsn;
max_msn = (curr_msn.msn > max_msn.msn) ? curr_msn : max_msn; max_msn = (curr_msn.msn > max_msn.msn) ? curr_msn : max_msn;
} }
...@@ -813,7 +813,7 @@ BASEMENTNODE toku_create_empty_bn(void) { ...@@ -813,7 +813,7 @@ BASEMENTNODE toku_create_empty_bn(void) {
BASEMENTNODE toku_create_empty_bn_no_buffer(void) { BASEMENTNODE toku_create_empty_bn_no_buffer(void) {
BASEMENTNODE XMALLOC(bn); BASEMENTNODE XMALLOC(bn);
bn->max_dsn_applied = 0; bn->max_dsn_applied.dsn = 0;
bn->max_msn_applied.msn = 0; bn->max_msn_applied.msn = 0;
bn->buffer = NULL; bn->buffer = NULL;
bn->n_bytes_in_buffer = 0; bn->n_bytes_in_buffer = 0;
...@@ -1005,7 +1005,7 @@ setup_available_brtnode_partition(BRTNODE node, int i) { ...@@ -1005,7 +1005,7 @@ setup_available_brtnode_partition(BRTNODE node, int i) {
if (node->height == 0) { if (node->height == 0) {
set_BLB(node, i, toku_create_empty_bn()); set_BLB(node, i, toku_create_empty_bn());
BLB_MAX_MSN_APPLIED(node,i) = node->max_msn_applied_to_node_on_disk; BLB_MAX_MSN_APPLIED(node,i) = node->max_msn_applied_to_node_on_disk;
BLB_MAX_DSN_APPLIED(node,i) = 0; BLB_MAX_DSN_APPLIED(node,i).dsn = 0;
} }
else { else {
set_BNC(node, i, toku_create_empty_nl()); set_BNC(node, i, toku_create_empty_nl());
...@@ -1681,7 +1681,7 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) { ...@@ -1681,7 +1681,7 @@ deserialize_brtheader (int fd, struct rbuf *rb, struct brt_header **brth) {
h->dirty=0; h->dirty=0;
h->panic = 0; h->panic = 0;
h->panic_string = 0; h->panic_string = 0;
h->curr_dsn = MIN_DSN+1; h->curr_dsn.dsn = MIN_DSN.dsn+1;
toku_list_init(&h->live_brts); toku_list_init(&h->live_brts);
toku_list_init(&h->zombie_brts); toku_list_init(&h->zombie_brts);
toku_list_init(&h->checkpoint_before_commit_link); toku_list_init(&h->checkpoint_before_commit_link);
......
...@@ -149,9 +149,9 @@ toku_assert_entire_node_in_memory(BRTNODE node) { ...@@ -149,9 +149,9 @@ toku_assert_entire_node_in_memory(BRTNODE node) {
// //
static void static void
set_new_DSN_for_node(BRTNODE node, BRT t) { set_new_DSN_for_node(BRTNODE node, BRT t) {
assert(t->h->curr_dsn > MIN_DSN); assert(t->h->curr_dsn.dsn > MIN_DSN.dsn);
node->dsn = t->h->curr_dsn; node->dsn = t->h->curr_dsn;
t->h->curr_dsn++; t->h->curr_dsn.dsn++;
} }
static u_int32_t static u_int32_t
...@@ -293,7 +293,7 @@ int toku_pin_brtnode_if_clean( ...@@ -293,7 +293,7 @@ int toku_pin_brtnode_if_clean(
); // this one doesn't need to use the toku_pin_brtnode function because it doesn't bring anything in, so it cannot create a non-up-to-date leaf node. ); // this one doesn't need to use the toku_pin_brtnode function because it doesn't bring anything in, so it cannot create a non-up-to-date leaf node.
if (r==0) { if (r==0) {
BRTNODE node = node_v; BRTNODE node = node_v;
if (node->dsn == INVALID_DSN) { if (node->dsn.dsn == INVALID_DSN.dsn) {
set_new_DSN_for_node(node, brt); set_new_DSN_for_node(node, brt);
} }
maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds); maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds);
...@@ -324,7 +324,7 @@ int toku_pin_brtnode (BRT brt, BLOCKNUM blocknum, u_int32_t fullhash, ...@@ -324,7 +324,7 @@ int toku_pin_brtnode (BRT brt, BLOCKNUM blocknum, u_int32_t fullhash,
unlockers); unlockers);
if (r==0) { if (r==0) {
BRTNODE node = node_v; BRTNODE node = node_v;
if (node->dsn == INVALID_DSN) { if (node->dsn.dsn == INVALID_DSN.dsn) {
set_new_DSN_for_node(node, brt); set_new_DSN_for_node(node, brt);
} }
maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds); maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds);
...@@ -358,7 +358,7 @@ void toku_pin_brtnode_holding_lock (BRT brt, BLOCKNUM blocknum, u_int32_t fullha ...@@ -358,7 +358,7 @@ void toku_pin_brtnode_holding_lock (BRT brt, BLOCKNUM blocknum, u_int32_t fullha
); );
assert(r==0); assert(r==0);
BRTNODE node = node_v; BRTNODE node = node_v;
if (node->dsn == INVALID_DSN) { if (node->dsn.dsn == INVALID_DSN.dsn) {
set_new_DSN_for_node(node, brt); set_new_DSN_for_node(node, brt);
} }
maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds); maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds);
...@@ -1002,7 +1002,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r ...@@ -1002,7 +1002,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r
invariant(msna.msn == msnb.msn); invariant(msna.msn == msnb.msn);
newroot->max_msn_applied_to_node_on_disk = msna; newroot->max_msn_applied_to_node_on_disk = msna;
} }
newroot->dsn = (nodea->dsn > nodeb->dsn) ? nodea->dsn : nodeb->dsn; newroot->dsn = (nodea->dsn.dsn > nodeb->dsn.dsn) ? nodea->dsn : nodeb->dsn;
BP_STATE(newroot,0) = PT_AVAIL; BP_STATE(newroot,0) = PT_AVAIL;
BP_STATE(newroot,1) = PT_AVAIL; BP_STATE(newroot,1) = PT_AVAIL;
newroot->dirty = 1; newroot->dirty = 1;
...@@ -2399,7 +2399,7 @@ maybe_merge_pinned_nodes (BRTNODE parent, int childnum_of_parent, struct kv_pair ...@@ -2399,7 +2399,7 @@ maybe_merge_pinned_nodes (BRTNODE parent, int childnum_of_parent, struct kv_pair
invariant(msn_max.msn <= parent->max_msn_applied_to_node_on_disk.msn); // parent msn must be >= children's msn invariant(msn_max.msn <= parent->max_msn_applied_to_node_on_disk.msn); // parent msn must be >= children's msn
} }
} }
dsn_max = (a->dsn > b->dsn) ? a->dsn : b->dsn; dsn_max = (a->dsn.dsn > b->dsn.dsn) ? a->dsn : b->dsn;
if (a->height == 0) { if (a->height == 0) {
maybe_merge_pinned_leaf_nodes(parent, childnum_of_parent, a, b, parent_splitk, did_merge, did_rebalance, splitk); maybe_merge_pinned_leaf_nodes(parent, childnum_of_parent, a, b, parent_splitk, did_merge, did_rebalance, splitk);
} else { } else {
...@@ -2615,7 +2615,7 @@ static void assert_leaf_up_to_date(BRTNODE node) { ...@@ -2615,7 +2615,7 @@ static void assert_leaf_up_to_date(BRTNODE node) {
assert(node->height == 0); assert(node->height == 0);
toku_assert_entire_node_in_memory(node); toku_assert_entire_node_in_memory(node);
for (int i=0; i < node->n_children; i++) { for (int i=0; i < node->n_children; i++) {
assert(BLB_MAX_DSN_APPLIED(node, i) >= MIN_DSN); assert(BLB_MAX_DSN_APPLIED(node, i).dsn >= MIN_DSN.dsn);
} }
} }
...@@ -3668,7 +3668,7 @@ brt_alloc_init_header(BRT t, TOKUTXN txn) { ...@@ -3668,7 +3668,7 @@ brt_alloc_init_header(BRT t, TOKUTXN txn) {
memset(&t->h->descriptor, 0, sizeof(t->h->descriptor)); memset(&t->h->descriptor, 0, sizeof(t->h->descriptor));
t->h->curr_dsn = MIN_DSN + 1; // start at MIN_DSN + 1, as MIN_DSN is reserved for basement nodes t->h->curr_dsn.dsn = MIN_DSN.dsn + 1; // start at MIN_DSN + 1, as MIN_DSN is reserved for basement nodes
r = brt_init_header(t, txn); r = brt_init_header(t, txn);
if (r != 0) goto died2; if (r != 0) goto died2;
...@@ -5179,7 +5179,7 @@ partition_requires_msg_application(BRTNODE node, int childnum, ANCESTORS ancesto ...@@ -5179,7 +5179,7 @@ partition_requires_msg_application(BRTNODE node, int childnum, ANCESTORS ancesto
curr_ancestors = curr_ancestors->next curr_ancestors = curr_ancestors->next
) )
{ {
if (curr_ancestors->node->dsn > BLB_MAX_DSN_APPLIED(node,childnum)) { if (curr_ancestors->node->dsn.dsn > BLB_MAX_DSN_APPLIED(node,childnum).dsn) {
requires_msg_application = TRUE; requires_msg_application = TRUE;
break; break;
} }
...@@ -5227,7 +5227,7 @@ maybe_apply_ancestors_messages_to_node (BRT t, BRTNODE node, ANCESTORS ancestors ...@@ -5227,7 +5227,7 @@ maybe_apply_ancestors_messages_to_node (BRT t, BRTNODE node, ANCESTORS ancestors
curr_ancestors->childnum, curr_ancestors->childnum,
&curr_bounds &curr_bounds
); );
curr_bn->max_dsn_applied = (curr_ancestors->node->dsn > curr_bn->max_dsn_applied) curr_bn->max_dsn_applied = (curr_ancestors->node->dsn.dsn > curr_bn->max_dsn_applied.dsn)
? curr_ancestors->node->dsn ? curr_ancestors->node->dsn
: curr_bn->max_dsn_applied; : curr_bn->max_dsn_applied;
curr_ancestors= curr_ancestors->next; curr_ancestors= curr_ancestors->next;
...@@ -5266,7 +5266,7 @@ brt_search_basement_node( ...@@ -5266,7 +5266,7 @@ brt_search_basement_node(
BRT_CURSOR brtcursor BRT_CURSOR brtcursor
) )
{ {
assert(bn->max_dsn_applied >= MIN_DSN); assert(bn->max_dsn_applied.dsn >= MIN_DSN.dsn);
// Now we have to convert from brt_search_t to the heaviside function with a direction. What a pain... // Now we have to convert from brt_search_t to the heaviside function with a direction. What a pain...
......
...@@ -60,10 +60,10 @@ typedef struct __toku_msn { u_int64_t msn; } MSN; ...@@ -60,10 +60,10 @@ typedef struct __toku_msn { u_int64_t msn; } MSN;
#define MIN_MSN ((MSN){(u_int64_t)1000*1000*1000}) // first 1B values reserved for messages created before Dr. No (for upgrade) #define MIN_MSN ((MSN){(u_int64_t)1000*1000*1000}) // first 1B values reserved for messages created before Dr. No (for upgrade)
#define MAX_MSN ((MSN){UINT64_MAX}) #define MAX_MSN ((MSN){UINT64_MAX})
typedef int64_t DSN; // DESERIALIZATION sequence number typedef struct __toku_dsn { int64_t dsn; } DSN; // DESERIALIZATION sequence number
#define INVALID_DSN -1 #define INVALID_DSN ((DSN){-1})
#define MIN_DSN 0 #define MIN_DSN ((DSN){0})
#define MAX_DSN INT64_MAX #define MAX_DSN ((DSN){INT64_MAX})
/* At the brt layer, a FILENUM uniquely identifies an open file. /* At the brt layer, a FILENUM uniquely identifies an open file.
* At the ydb layer, a DICTIONARY_ID uniquely identifies an open dictionary. * At the ydb layer, a DICTIONARY_ID uniquely identifies an open dictionary.
......
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