Ejemplo n.º 1
0
static void* lru_restore_thread(void *arg) {
	struct lruCache *cache;
	if (destor.simulation_level >= SIMULATION_RESTORE)
		cache = new_lru_cache(destor.restore_cache[1], free_container_meta,
				lookup_fingerprint_in_container_meta);
	else
		cache = new_lru_cache(destor.restore_cache[1], free_container,
				lookup_fingerprint_in_container);

	struct chunk* c;
	while ((c = sync_queue_pop(restore_recipe_queue))) {

		if (CHECK_CHUNK(c, CHUNK_FILE_START) || CHECK_CHUNK(c, CHUNK_FILE_END)) {
			sync_queue_push(restore_chunk_queue, c);
			continue;
		}

		TIMER_DECLARE(1);
		TIMER_BEGIN(1);

		if (destor.simulation_level >= SIMULATION_RESTORE) {
			struct containerMeta *cm = lru_cache_lookup(cache, &c->fp);
			if (!cm) {
				VERBOSE("Restore cache: container %lld is missed", c->id);
				cm = retrieve_container_meta_by_id(c->id);
				assert(lookup_fingerprint_in_container_meta(cm, &c->fp));
				lru_cache_insert(cache, cm, NULL, NULL);
				jcr.read_container_num++;
			}

			TIMER_END(1, jcr.read_chunk_time);
		} else {
			struct container *con = lru_cache_lookup(cache, &c->fp);
			if (!con) {
				VERBOSE("Restore cache: container %lld is missed", c->id);
				con = retrieve_container_by_id(c->id);
				lru_cache_insert(cache, con, NULL, NULL);
				jcr.read_container_num++;
			}
			struct chunk *rc = get_chunk_in_container(con, &c->fp);
			assert(rc);
			TIMER_END(1, jcr.read_chunk_time);
			sync_queue_push(restore_chunk_queue, rc);
		}

		free_chunk(c);
	}

	sync_queue_term(restore_chunk_queue);

	free_lru_cache(cache);

	return NULL;
}
Ejemplo n.º 2
0
Container* container_cache_lookup(ContainerCache *cc, Fingerprint *finger) {
	Container *container = 0;
	GSequence *container_list = g_hash_table_lookup(cc->map, finger);
	if (container_list) {
		container = g_sequence_get(g_sequence_get_begin_iter(container_list));
		/*container = g_sequence_get(g_sequence_search(container_list, &tmp, container_cmp_des, NULL));*/
		if (container) {
			if (!lru_cache_lookup(cc->lru_cache, container_equal, container)) {
				printf("%s, %d: inconsistency between map and cache.\n",
						__FILE__, __LINE__);
			}
		}
	}
	return container;
}
Ejemplo n.º 3
0
int64_t fingerprint_cache_lookup(fingerprint *fp){
	switch(destor.index_category[1]){
		case INDEX_CATEGORY_PHYSICAL_LOCALITY:{
			struct containerMeta* cm = lru_cache_lookup(lru_queue, fp);
			if (cm)
				return cm->id;
			break;
		}
		case INDEX_CATEGORY_LOGICAL_LOCALITY:{
			struct segmentRecipe* sr = lru_cache_lookup(lru_queue, fp);
			if(sr){
				struct chunkPointer* cp = g_hash_table_lookup(sr->kvpairs, fp);
				if(cp->id <= TEMPORARY_ID){
					WARNING("expect > TEMPORARY_ID, but being %lld", cp->id);
					assert(cp->id > TEMPORARY_ID);
				}
				return cp->id;
			}
			break;
		}
	}

	return TEMPORARY_ID;
}
Ejemplo n.º 4
0
/*
 * Maintain a LRU cache internally to simulate recovery process when backing-up.
 */
void restore_aware_update(containerid id, int32_t chunklen) {
	monitor.total_size += chunklen + CONTAINER_META_ENTRY;

	struct containerRecord* record = lru_cache_lookup(monitor.cache, &id);
	if (!record) {
		record = (struct containerRecord*) malloc(
				sizeof(struct containerRecord));
		record->cid = id;
		lru_cache_insert(monitor.cache, record, NULL, NULL);

		monitor.ccf++;
	}

	monitor.ocf = (monitor.total_size + CONTAINER_SIZE - 1) / CONTAINER_SIZE;
	monitor.cfl = monitor.ocf / (double) monitor.ccf;
}
Ejemplo n.º 5
0
Container* container_cache_lookup_special(ContainerCache *cc,
		Fingerprint *finger, ContainerId container_id) {
	Container tmp;
	tmp.id = container_id;
	Container *container = 0;
	GSequence *container_list = g_hash_table_lookup(cc->map, finger);
	if (container_list) {
		/*container = g_sequence_get(g_sequence_get_begin_iter(container_list));*/
		GSequenceIter *iter = g_sequence_lookup(container_list, &tmp,
				container_cmp_des, NULL);
		if (iter) {
			container = g_sequence_get(iter);
			if (container) {
				if (!lru_cache_lookup(cc->lru_cache, container_equal,
						container)) {
					printf("%s, %d: inconsistency between map and cache.\n",
							__FILE__, __LINE__);
				}
			}
		}
	}
	return container;
}
Ejemplo n.º 6
0
static struct giga_directory* shard_cache_lookup(shard_cache_t* dircache,
                                                 DIR_handle_t handle) {
    return lru_cache_lookup(&(dircache->shards[shard_cache_get_shard(handle)]),
                            handle);
}