Esempio n. 1
0
static void node_mark_dirty(Oc_wu *wu_p,
                            Oc_bpt_node *node_p,
                            bool multi_refs) 
{
    if (!multi_refs) {
        uint64 new_addr;
        Oc_bpt_test_node *tnode_p;
        
        /* Try to emulate what the mark-dirty operation actually does.
         * Move the page from its current disk-address to a new one.
         *
         * There is one exception: never move the root node. 
         */
        if (oc_bpt_nd_is_root(NULL, node_p))
            return;
        
        if (1) {
            if (oc_bpt_test_utl_random_number(4) != 0)
                return;
            
            // This is a non-root node, move it
            new_addr = oc_bpt_test_fs_alloc();
            oc_bpt_test_fs_dealloc(node_p->disk_addr);

            tnode_p = vd_node_lookup(node_p->disk_addr);
            vd_node_remove(node_p->disk_addr);
            node_p->disk_addr = new_addr;
            vd_node_insert(tnode_p);
        }
    }
    else {
        /* This page is referenced by multiple clones. We
         * can't move it; we need to leave the old page where
         * it was. 
         */
        Oc_bpt_test_node *tnode_p, *old_tnode_p;;

        tnode_p = vd_node_lookup(node_p->disk_addr);
        old_tnode_p = tnode_clone(tnode_p);

        // move the page to a new address
        vd_node_remove(tnode_p->node.disk_addr);
        tnode_p->node.disk_addr = oc_bpt_test_fs_alloc();
        vd_node_insert(tnode_p);
        
        // Place a copy of the page in the old disk-address
        vd_node_insert(old_tnode_p);

        // reduce the FS ref-count on the old address.
        oc_bpt_test_fs_dealloc(old_tnode_p->node.disk_addr);
    }
}
Esempio n. 2
0
void oc_xt_test_nd_mark_dirty(Oc_wu *wu_p, Oc_xt_node *node_p)
{
    Oc_xt_test_node *tnode_p;
    uint64 new_addr;
    
    if (random_choose(4) != 0)
        return;

    /* Try to emulate what the mark-dirty operation actually does.
     * Move the page from its current disk-address to a new one.
     *
     * There is one exception: never move the root node. 
     */
    if (oc_xt_nd_is_root(NULL, node_p))
        return;

    // This is a non-root node, move it
    new_addr = fs_alloc();
//    printf("po_id=%d, moving address %Lu->%Lu\n", wu_p->po_id, node_p->lba, new_addr);
//    fflush(stdout);
    
    tnode_p = vd_node_lookup(node_p->disk_addr);
    vd_node_remove(node_p->disk_addr);
    node_p->disk_addr = new_addr;
    vd_node_insert(tnode_p);
}
Esempio 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;
}
Esempio n. 4
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;
}