Exemplo n.º 1
0
/*  write trigger wb*/
void test_get_refer_inode()
{
	char *uri = "local:///tmp/testenv/testfs";
	struct back_storage *storage = init_storage_handler(uri);
	int ret = 0;
	uint32_t segment_size = 0;
	uint32_t block_size = 0;
	uint64_t max_fs_size = 0;
	uint32_t is_compress = 0;
	ret = read_fs_meta(storage, &segment_size, &block_size, &max_fs_size, \
			&is_compress);
	g_assert(ret == 0);
	GHashTable *ss_hashtable = \
				   g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
	ret = load_all_snapshot(storage, "snapshot.txt", ss_hashtable);
	printf("snapshot loaded\n"); 
	g_assert(ret == 0);
	GList *ss_list = NULL;
	ret = sort_all_snapshot(ss_hashtable, &ss_list);
	printf("snapshot sorted\n"); 
	g_assert(ss_list != NULL);
	g_assert(ret == 0);
	int i;
	for (i = 0;i < 9;i++) {
		struct inode *inode = NULL;
		char *up_sname;
		ret = get_refer_inode_between_snapshots(storage, i, ss_list, \
				&inode, &up_sname);
		printf("segno :%d ret:%d\n", i, ret);
	}
}
Exemplo n.º 2
0
/*  write trigger wb*/
void test_seg_usage_calc()
{
    char * uri = "local:///tmp/testenv/testfs";
    struct back_storage *storage = init_storage_handler(uri);
    uint32_t segment_size = 0;
    uint32_t block_size = 0;
    uint64_t max_fs_size = 0;
    int ret = read_fs_meta(storage,&segment_size, &block_size,&max_fs_size);
    g_assert(ret == 0);
    GHashTable   * ss_hashtable = g_hash_table_new_full(g_str_hash,g_str_equal,NULL,NULL);
    ret = load_all_snapshot(storage,"snapshot.txt",ss_hashtable);
    printf("snapshot loaded\n"); 
    g_assert(ret == 0);
    GList* ss_list = NULL;
    ret = sort_all_snapshot(ss_hashtable,&ss_list);
    printf("snapshot sorted\n"); 
    g_assert(ss_list !=NULL);
    g_assert(ret == 0);
    int i;
    for(i=13;i<17;i++){
        struct inode * inode=NULL;
        char *up_sname;
        ret = get_refer_inode_between_snapshots(storage,i,ss_list,&inode,&up_sname);
        printf("segno :%d ret:%d\n",i,ret);
        if(ret == 0){
           printf("seg is in snapshots\n");
           SEG_USAGE_T seg_usage;
           memset(&seg_usage,0,sizeof(SEG_USAGE_T));
           ret = seg_usage_calc(storage,block_size,i,inode,&seg_usage);
           g_assert(ret ==0);
           char textbuf[4096];
           memset(textbuf,4096,0);
           ret = seg_usage2text(&seg_usage,textbuf);
           g_assert(ret > 0);
           printf("textbuf is :%s\n",textbuf);
        }
        if(ret == 1){
           printf("seg is on snapshot,do nothing\n");
        }
        if(ret == 2){
           printf("seg is above snapshot,maybe need migrate\n");
        }
    }

}