Ejemplo n.º 1
0
void oc_xt_test_nd_dealloc(Oc_wu *wu_p, uint64 addr)
{
    Oc_xt_test_node *tnode_p;
    char *data;
    
    if (wu_p->po_id != 0)
        if (random_choose(2) == 0)
            oc_crt_yield_task();

    // extract the node fromt the table prior to removal
    tnode_p = vd_node_lookup(addr);
    
    // remove the node from the virtual-disk
    vd_node_remove(addr);

    oc_utl_assert(tnode_p);
    oc_utl_assert(tnode_p->node.data);
    oc_utl_assert(tnode_p->magic == MAGIC);

    // mess up the node so that errors will occur on illegal accesses
    tnode_p->magic = -1;
    data = tnode_p->node.data;
    tnode_p->node.data = NULL;
    tnode_p->node.lock.counter = 100;
    tnode_p->node.disk_addr = 0;
    
    free(data);
    free(tnode_p);
}
Ejemplo n.º 2
0
static void node_dealloc(Oc_wu *wu_p, uint64 addr)
{
    if (wu_p->po_id != 0)
        if (oc_bpt_test_utl_random_number(2) == 0)
            oc_crt_yield_task();

    oc_bpt_test_fs_dealloc(addr);
    
    if (oc_bpt_test_fs_get_refcount(wu_p, addr) == 0)
    {
        // Free the block only if it's ref-count is zero
        Oc_bpt_test_node *tnode_p;
        char *data;
        
        // extract the node from the table prior to removal
        tnode_p = vd_node_lookup(addr);
        
        // remove the node from the virtual-disk
        vd_node_remove(addr);
        
        oc_utl_assert(tnode_p);
        oc_utl_assert(tnode_p->node.data);
        oc_utl_assert(tnode_p->magic == MAGIC);
        
        // mess up the node so that errors will occur on illegal accesses
        tnode_p->magic = -1;
        data = tnode_p->node.data;
        tnode_p->node.data = NULL;
        tnode_p->node.disk_addr = 0;
        
        free(data);
        free(tnode_p);
    }
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
Oc_xt_node* oc_xt_test_nd_get(Oc_wu *wu_p, uint64 addr)
{
    Oc_xt_test_node *tnode_p;
    
    oc_utl_assert(addr != 0);

    if (wu_p->po_id != 0)
        if (random_choose(2) == 0)
            oc_crt_yield_task();

    g_refcnt++;
    tnode_p = vd_node_lookup(addr);
    if (NULL == tnode_p) {
        printf("error, did not find a b-tree node at address=%Lu po=%lu\n",
               addr, wu_p->po_id);
        oc_utl_assert(0);
    }
    oc_utl_assert(MAGIC == tnode_p->magic);
    return &tnode_p->node;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
static void data_release(Oc_wu *wu_p, struct Oc_bpt_data *data)
{
    if (wu_p->po_id != 0)
        if (oc_bpt_test_utl_random_number(3) == 0)
            oc_crt_yield_task();
}