Example #1
0
static void
test_ctree_remove()
{
	struct ctree *t = ctree_new();
	UT_ASSERT(t != NULL);

	Rcounter_malloc = TEST_REMOVE;

	/* remove from empty tree */
	UT_ASSERT(ctree_remove(t, TEST_VAL_A, 0) == 0);

	/* insert 2 valid values */
	UT_ASSERT(ctree_insert(t, TEST_VAL_A, 0) == 0);
	UT_ASSERT(ctree_insert(t, TEST_VAL_B, 0) == 0);

	/* fail to remove equal greater */
	UT_ASSERT(ctree_remove(t, TEST_VAL_C, 0) == 0);

	/* remove accessor */
	UT_ASSERT(ctree_remove(t, TEST_VAL_A, 1) == TEST_VAL_A);

	/* remove root */
	UT_ASSERT(ctree_remove(t, TEST_VAL_B, 1) == TEST_VAL_B);

	ctree_delete(t);
}
Example #2
0
File: bucket.c Project: perone/nvml
/*
 * bucket_get_rm_block_exact -- removes exact match memory block
 */
int
bucket_get_rm_block_exact(struct bucket *b, struct memory_block m)
{
	uint64_t key = CHUNK_KEY_PACK(m.zone_id, m.chunk_id, m.block_off,
			m.size_idx);

	if ((key = ctree_remove(b->tree, key, 1)) == 0)
		return ENOMEM;

	return 0;
}
Example #3
0
/*
 * ctree_delete -- cleanups and frees crit-bit tree instance
 */
void
ctree_delete(struct ctree *t)
{
	while (t->root)
		ctree_remove(t, 0, 0);

	if ((errno = pthread_mutex_destroy(&t->lock)) != 0)
		ERR("!pthread_mutex_destroy");

	Free(t);
}
Example #4
0
/*
 * ctree_delete -- cleanups and frees crit-bit tree instance
 */
void
ctree_delete(struct ctree *t)
{
	while (t->root)
		ctree_remove(t, 0, 0);

	if ((errno = pthread_mutex_destroy(&t->lock)) != 0)
		ERR("!pthread_mutex_destroy");
//#ifndef _EAP_ALLOC_OPTIMIZE
	Free(t);
//#endif
}
Example #5
0
/*
 * bucket_tree_get_rm_block_exact -- (internal) removes exact match memory block
 */
static int
bucket_tree_get_rm_block_exact(struct block_container *bc,
	struct memory_block m)
{
	uint64_t key = CHUNK_KEY_PACK(m.zone_id, m.chunk_id, m.block_off,
			m.size_idx);

	struct block_container_ctree *c = (struct block_container_ctree *)bc;

	if ((key = ctree_remove(c->tree, key, 1)) == 0)
		return ENOMEM;

	return 0;
}
Example #6
0
File: bucket.c Project: perone/nvml
/*
 * bucket_get_rm_block_bestfit --
 *	removes and returns the best-fit memory block for size
 */
int
bucket_get_rm_block_bestfit(struct bucket *b, struct memory_block *m)
{
	uint64_t key = CHUNK_KEY_PACK(m->zone_id, m->chunk_id, m->block_off,
			m->size_idx);

	if ((key = ctree_remove(b->tree, key, 0)) == 0)
		return ENOMEM;

	m->chunk_id = CHUNK_KEY_GET_CHUNK_ID(key);
	m->zone_id = CHUNK_KEY_GET_ZONE_ID(key);
	m->block_off = CHUNK_KEY_GET_BLOCK_OFF(key);
	m->size_idx = CHUNK_KEY_GET_SIZE_IDX(key);


	return 0;
}
Example #7
0
/*
 * bucket_tree_get_rm_block_bestfit -- (internal) removes and returns the
 *	best-fit memory block for size
 */
static int
bucket_tree_get_rm_block_bestfit(struct block_container *bc,
	struct memory_block *m)
{
	uint64_t key = CHUNK_KEY_PACK(m->zone_id, m->chunk_id, m->block_off,
			m->size_idx);

	struct block_container_ctree *c = (struct block_container_ctree *)bc;

	if ((key = ctree_remove(c->tree, key, 0)) == 0)
		return ENOMEM;

	m->chunk_id = CHUNK_KEY_GET_CHUNK_ID(key);
	m->zone_id = CHUNK_KEY_GET_ZONE_ID(key);
	m->block_off = CHUNK_KEY_GET_BLOCK_OFF(key);
	m->size_idx = CHUNK_KEY_GET_SIZE_IDX(key);

	return 0;
}
Example #8
0
/*
 * pmemobj_close -- close a transactional memory pool
 */
void
pmemobj_close(PMEMobjpool *pop)
{
	LOG(3, "pop %p", pop);

	_pobj_cache_invalidate++;

	if (cuckoo_remove(pools_ht, pop->uuid_lo) != pop) {
		ERR("cuckoo_remove");
	}

	if (ctree_remove(pools_tree, (uint64_t)pop, 1) != (uint64_t)pop) {
		ERR("ctree_remove");
	}

	if (_pobj_cached_pool.pop == pop) {
		_pobj_cached_pool.pop = NULL;
		_pobj_cached_pool.uuid_lo = 0;
	}

	pmemobj_cleanup(pop);
}