static Oc_bpt_node* node_alloc(Oc_wu *wu_p) { Oc_bpt_test_node *tnode_p; Oc_bpt_node *node_p; // simple checking for ref-counts g_refcnt++; if (wu_p->po_id != 0) if (oc_bpt_test_utl_random_number(2) == 0) oc_crt_yield_task(); tnode_p = (struct Oc_bpt_test_node*) wrap_malloc(sizeof(Oc_bpt_test_node)); memset(tnode_p, 0, sizeof(Oc_bpt_test_node)); oc_crt_init_rw_lock(&tnode_p->node.lock); tnode_p->node.data = (char*) wrap_malloc(NODE_SIZE); tnode_p->node.disk_addr = oc_bpt_test_fs_alloc(); tnode_p->magic = MAGIC; // add the node into the virtual-disk vd_node_insert(tnode_p); node_p = &tnode_p->node; // Lock the node oc_utl_trk_crt_lock_write(wu_p, &node_p->lock); return node_p; }
void oc_bpt_init_state_b(struct Oc_wu *wu_pi, Oc_bpt_state *state_po, Oc_bpt_cfg *cfg_p, uint64 tid) { oc_bpt_trace_wu_lvl(3, OC_EV_BPT_INIT_STATE, wu_pi, "tid=%Lu", tid); memset(state_po, 0, sizeof(Oc_bpt_state)); oc_crt_init_rw_lock(&state_po->lock); state_po->cfg_p = cfg_p; state_po->tid = tid; }
static Oc_bpt_test_node *tnode_clone(Oc_bpt_test_node *tnode_p) { Oc_bpt_test_node *new_tnode_p; new_tnode_p = (Oc_bpt_test_node *) wrap_malloc(sizeof(Oc_bpt_test_state)); memset(new_tnode_p, 0, sizeof(Oc_bpt_test_state)); new_tnode_p->node.disk_addr = tnode_p->node.disk_addr; new_tnode_p->node.data = wrap_malloc(NODE_SIZE); memcpy(new_tnode_p->node.data, tnode_p->node.data, NODE_SIZE); oc_crt_init_rw_lock(&new_tnode_p->node.lock); new_tnode_p->magic = MAGIC; return new_tnode_p; }
Oc_xt_node* oc_xt_test_nd_alloc(Oc_wu *wu_p) { Oc_xt_test_node *tnode_p; // simple checking for ref-counts g_refcnt++; if (wu_p->po_id != 0) if (random_choose(2) == 0) oc_crt_yield_task(); tnode_p = (struct Oc_xt_test_node*) wrap_malloc(sizeof(Oc_xt_test_node)); memset(tnode_p, 0, sizeof(Oc_xt_test_node)); oc_crt_init_rw_lock(&tnode_p->node.lock); tnode_p->node.data = (char*) wrap_malloc(OC_XT_TEST_ND_SIZE); tnode_p->node.disk_addr = fs_alloc(); tnode_p->magic = MAGIC; // add the node into the virtual-disk vd_node_insert(tnode_p); return &tnode_p->node; }