Beispiel #1
0
int main(int argc, char *argv[])
{
    u64 duuid = 1;
    pthread_t racer_thread;
    int err = 0;
    
    hvfs_info(mdsl, "MDSL GC Unit Test ...\n");

    /* got the uuid from user */
    if (argc < 2) {
        hvfs_err(mdsl, "Usage: %s dir_uuid\n", argv[0]);
        return EINVAL;
    } else {
        duuid = atol(argv[1]);
    }
    
    mdsl_init();
    hmo.site_id = HVFS_MDSL(0);
    mdsl_verify();

    preload_dir(duuid);
    /* start a racer */
    err = pthread_create(&racer_thread, NULL, &racer, (void *)duuid);
    if (err)
        goto out_clean;

    sleep(5);
    err = mdsl_gc_md(duuid);
    if (err) {
        hvfs_err(mdsl, "mdsl_gc_md(%lx) failed w/ %d\n",
                 duuid, err);
        goto out_clean;
    }

    racer_stop = 1;
    pthread_join(racer_thread, NULL);
    
out_clean:
    mdsl_destroy();

    return err;
}
Beispiel #2
0
static inline
u64 HVFS_TYPE_SEL(int type, int id)
{
    u64 site_id = -1UL;

    switch (type) {
    case TYPE_MDS:
        site_id = HVFS_MDS(id);
        break;
    case TYPE_CLIENT:
        site_id = HVFS_CLIENT(id);
        break;
    case TYPE_MDSL:
        site_id = HVFS_MDSL(id);
        break;
    case TYPE_RING:
        site_id = HVFS_RING(id);
        break;
    default:;
    }

    return site_id;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    struct xnet_type_ops ops = {
        .buf_alloc = __mds_buf_alloc,
        .buf_free = NULL,
        .recv_handler = mds_spool_dispatch,
        .dispatcher = mds_fe_dispatch,
    };
    int err = 0;
    int self, sport = -1, i, j;
    int memonly, memlimit, mode, plot_method;
    char *value;
    char *ring_ip = NULL;
    char profiling_fname[256];
    
    hvfs_info(xnet, "MDS Unit Testing...\n");
    hvfs_info(xnet, "Mode is 0/1 (no ring/with ring)\n");

    if (argc < 2) {
        hvfs_err(xnet, "Self ID is not provided.\n");
        err = EINVAL;
        return err;
    } else {
        self = atoi(argv[1]);
        hvfs_info(xnet, "Self type+ID is mds:%d.\n", self);
        if (argc == 4) {
            ring_ip = argv[2];
            sport = atoi(argv[3]);
        } else if (argc == 3)
            ring_ip = argv[2];
    }

    value = getenv("memonly");
    if (value) {
        memonly = atoi(value);
    } else
        memonly = 1;

    value = getenv("memlimit");
    if (value) {
        memlimit = atoi(value);
    } else
        memlimit = 0;

    value = getenv("mode");
    if (value) {
        mode = atoi(value);
    } else 
        mode = 0;

    value = getenv("fsid");
    if (value) {
        fsid = atoi(value);
    } else
        fsid = 0;

    value = getenv("plot");
    if (value) {
        plot_method = atoi(value);
    } else
        plot_method = MDS_PROF_PLOT;

    st_init();
    mds_pre_init();
    hmo.prof.xnet = &g_xnet_prof;
    hmo.conf.itbid_check = 1;
    hmo.conf.prof_plot = plot_method;
    hmo.conf.option |= HVFS_MDS_NOSCRUB;
    hmo.cb_branch_init = mds_cb_branch_init;
    hmo.cb_branch_destroy = mds_cb_branch_destroy;

    mds_init(11);

    /* set the uuid base! */
    hmi.uuid_base = (u64)self << 45;

    for (i = 0; i < 4; i++) {
        for (j = 0; j < 4; j++) {
            xnet_update_ipaddr(HVFS_TYPE(i, j), 1, &ipaddr[i],
                               (short *)(&port[i][j]));
        }
    }

    xnet_update_ipaddr(HVFS_CLIENT(12), 1, &ipaddr[4], (short *)(&port[4][0]));
    xnet_update_ipaddr(HVFS_MDS(4), 1, &ipaddr[0], (short *)(&port[4][1]));

    /* prepare the ring address */
    if (!ring_ip) {
        xnet_update_ipaddr(HVFS_RING(0), 1, &ipaddr[3],
                           (short *)(&port[3][0]));
        if (sport == -1)
            sport = port[TYPE_MDS][self];
    } else {
        xnet_update_ipaddr(HVFS_RING(0), 1, &ring_ip,
                           (short *)(&port[3][0]));
        if (sport == -1)
            sport = port[TYPE_MDS][0];
    }
    
    /* setup the profiling file */
    memset(profiling_fname, 0, sizeof(profiling_fname));
    sprintf(profiling_fname, "./CP-BACK-mds.%d", self);
    hmo.conf.pf_file = fopen(profiling_fname, "w+");
    if (!hmo.conf.pf_file) {
        hvfs_err(xnet, "fopen() profiling file %s faield %d\n",
                 profiling_fname, errno);
        return EINVAL;
    }

    self = HVFS_MDS(self);

    hmo.xc = xnet_register_type(0, sport, self, &ops);
    if (IS_ERR(hmo.xc)) {
        err = PTR_ERR(hmo.xc);
        return err;
    }
    hmo.site_id = self;

    if (mode == 0) {
        hmi.gdt_salt = 0;
        hvfs_info(xnet, "Select GDT salt to %lx\n", hmi.gdt_salt);
        hmi.root_uuid = 1;
        hmi.root_salt = 0xdfeadb0;
        hvfs_info(xnet, "Select root salt to %lx\n", hmi.root_salt);
        
#if 0
        ring_add(&hmo.chring[CH_RING_MDS], HVFS_MDS(0));
        ring_add(&hmo.chring[CH_RING_MDS], HVFS_MDS(1));
        ring_add(&hmo.chring[CH_RING_MDS], HVFS_MDS(2));
        ring_add(&hmo.chring[CH_RING_MDS], HVFS_MDS(3));
#else
        ring_add(&hmo.chring[CH_RING_MDS], HVFS_MDS(4));
#endif
        ring_add(&hmo.chring[CH_RING_MDSL], HVFS_MDSL(0));
        ring_add(&hmo.chring[CH_RING_MDSL], HVFS_MDSL(1));

        ring_resort_nolock(hmo.chring[CH_RING_MDS]);
        ring_resort_nolock(hmo.chring[CH_RING_MDSL]);

        ring_dump(hmo.chring[CH_RING_MDS]);
        ring_dump(hmo.chring[CH_RING_MDSL]);
        
        /* insert the GDT DH */
        dh_insert(hmi.gdt_uuid, hmi.gdt_uuid, hmi.gdt_salt);
        bitmap_insert(0, 0);
    } else {
        hmo.cb_exit = mds_cb_exit;
        hmo.cb_hb = mds_cb_hb;
        hmo.cb_ring_update = mds_cb_ring_update;

        /* use ring info to init the mds */
        err = r2cli_do_reg(self, HVFS_RING(0), fsid, 0);
        if (err) {
            hvfs_err(xnet, "reg self %x w/ r2 %x failed w/ %d\n",
                     self, HVFS_RING(0), err);
            goto out;
        }
        hvfs_info(xnet, "HMI gdt uuid %ld salt %lx txg %ld\n", 
                  hmi.gdt_uuid, hmi.gdt_salt,
                  atomic64_read(&hmi.mi_txg));
    }
    
    err = mds_verify();
    if (err) {
        hvfs_err(xnet, "Verify MDS configration failed!\n");
        goto out;
    }

//    SET_TRACING_FLAG(xnet, HVFS_DEBUG);
//    SET_TRACING_FLAG(mds, HVFS_DEBUG | HVFS_VERBOSE);

    hvfs_info(xnet, "MDS is UP for serving requests now.\n");

    msg_wait();

    xnet_unregister_type(hmo.xc);

    st_destroy();
    mds_destroy();

    return 0;
out:
    st_destroy();
    mds_destroy();

    return err;
}