Example #1
0
int cache_init()
{

#if 0
    int i = 0;

    dircache = (struct giga_directory*)malloc(sizeof(struct giga_directory));
    if (!dircache) {
        logMessage(LOG_FATAL, __func__, "malloc_err: %s", strerror(errno));
        exit(1);
    }

    dircache->handle = ROOT_DIR_ID;
    int zeroth_srv = 0; //FIXME: how do you get zeroth server info?
    giga_init_mapping(&dircache->mapping, -1, dircache->handle, zeroth_srv, giga_options_t.num_servers);
    dircache->refcount = 1;
    dircache->split_flag = 0;
    pthread_mutex_init(&dircache->split_mtx, NULL);
    //for (i=0; i < (int)sizeof(dir->partition_size); i++)
    logMessage(CACHE_LOG, __func__, "init %d  partitions ...", MAX_NUM);
    for (i=0; i < MAX_NUM; i++) {
        dircache->partition_size[i] = 0;
        pthread_mutex_init(&dircache->partition_mtx[i], NULL);
    }
    logMessage(LOG_TRACE, __func__, "Cache_CREATE: dir(%d)", dircache->handle);
#endif

    shard_cache_init(&my_dircache, DEFAULT_DIR_CACHE_SIZE);

    fuse_cache = NULL;
    fuse_cache_insert("/", ROOT_DIR_ID);

    return 0;
}
Example #2
0
static 
struct giga_directory* new_directory(DIR_handle_t *handle)
{
    struct giga_directory *dir = malloc(sizeof(struct giga_directory));
    if (!dir) {
        logMessage(LOG_FATAL, __func__, "malloc_err: %s", strerror(errno));
        return NULL;
    }

    memcpy(&dir->handle, handle, sizeof(DIR_handle_t));
    
    int zeroth_srv = 0; //FIXME: how do you get zeroth server info?
    
    // FIXME: what should flag be?
    giga_init_mapping(&dir->mapping, -1, zeroth_srv, giga_options_t.num_servers);
    dir->refcount = 1;

    HASH_ADD(hh, dircache, handle, sizeof(DIR_handle_t), dir);

    //TODO: get biubitmap from disk???
    //fill_bitmap(&(dir->mapping), handle);
   
    logMessage(LOG_TRACE, __func__, "Cache_CREATE: dir(%d)", *handle);

    return dir;
}
Example #3
0
struct giga_directory* new_cache_entry(DIR_handle_t *handle, int srv_id)
{
    int i = 0;

    struct giga_directory *d = (struct giga_directory*)malloc(sizeof(struct giga_directory));
    if (d == NULL) {
        logMessage(LOG_FATAL, __func__, "malloc_err: %s", strerror(errno));
        exit(1);
    }

    d->handle = *handle;
    giga_init_mapping(&d->mapping, -1, d->handle, srv_id, giga_options_t.num_servers);

    //d->refcount = 1;
    d->split_flag = 0;
    pthread_mutex_init(&d->split_mtx, NULL);

    logMessage(CACHE_LOG, __func__, "init %d  partitions ...", MAX_NUM);
    for (i=0; i < MAX_NUM; i++) {
        d->partition_size[i] = 0;
        pthread_mutex_init(&d->partition_mtx[i], NULL);
    }

    logMessage(CACHE_LOG, __func__, "Cache_CREATE: dir(%d)", d->handle);

    return d;
}