Ejemplo n.º 1
0
int ofi_mr_erase(struct ofi_util_mr * in_mr_h, uint64_t in_key)
{
    void * itr;
    struct fi_mr_attr * item;

    if (!in_mr_h)
        return -FI_EINVAL;

    itr = rbtFind(in_mr_h->map_handle, &in_key);

    if (!itr)
        return -FI_ENOKEY;

    /*release memory */
    rbtKeyValue(in_mr_h->map_handle, itr, (void **)&in_key,
                                (void **) &item);

    assert(item);

    free((void *)item->mr_iov);
    free(item);

    rbtErase(in_mr_h->map_handle, itr);

    return 0;
}
Ejemplo n.º 2
0
/**
 * 从freelist中获取一个cache
 */
static tex_node_p get_free_node()
{
	tex_node_p ret = NULL;
	tex_node_p tex_node = NULL;
	int i = 0;
	if(free_tex_list == NULL){
		//没有剩余的cache,从树中释放一半的cache
		//root = rbtRoot();
		delete_count = 0;
		rbtInorder(rb,rb->root, deleteNodeProc);
		for(i =0;i<delete_count;i++){
			tex_node = (tex_node_p)(deleted_node[i]->val.node);
			tex_node->next =  free_tex_list;
			free_tex_list = tex_node;
			rbtErase(rb,deleted_node[i]);
		}
	}

	if(free_tex_list){
		ret = free_tex_list;
		free_tex_list = free_tex_list->next;
	}

	return ret;
}
Ejemplo n.º 3
0
static int ofi_mr_rbt_storage_erase(struct ofi_mr_storage *storage,
				    struct ofi_mr_entry *entry)
{
	RbtIterator iter = rbtFind(storage->storage, &entry->iov);
	assert(iter);
	return (rbtErase((RbtHandle)storage->storage, iter) != RBT_STATUS_OK) ?
	       -FI_EAVAIL : 0;
}
Ejemplo n.º 4
0
static inline void psmx_mr_release_key(struct psmx_fid_domain *domain, uint64_t key)
{
	RbtIterator it;

	fastlock_acquire(&domain->mr_lock);
	it = rbtFind(domain->mr_map, (void *)key);
	if (it)
		rbtErase(domain->mr_map, it);
	fastlock_release(&domain->mr_lock);
}
Ejemplo n.º 5
0
int  tex_cache_free(int imgid)
{
	KeyType key = imgid;
	NodeType *p;
	tex_node_p tex_node;

	if ((p = rbtFind(rb,key)) != NULL) {
		tex_node = (tex_node_p)(p->val.node);
		tex_node->next =  free_tex_list;
		free_tex_list = tex_node;
		rbtErase(rb,p);
		return 1;
	}
	return 0;
}
Ejemplo n.º 6
0
int ofi_mr_remove(struct ofi_mr_map *map, uint64_t key)
{
	struct fi_mr_attr *attr;
	void *itr, *key_ptr;

	itr = rbtFind(map->rbtree, &key);
	if (!itr)
		return -FI_ENOKEY;

	rbtKeyValue(map->rbtree, itr, &key_ptr, (void **) &attr);
	rbtErase(map->rbtree, itr);
	free(attr);

	return 0;
}
Ejemplo n.º 7
0
static void psmx_ns_map_del(int service, psm_epid_t name_in)
{
	RbtIterator it;
	void *key;
	psm_epid_t name;

        it = rbtFind(psmx_ns_map, (void *)(uintptr_t)service);
        if (it) {
		rbtKeyValue(psmx_ns_map, it, &key, (void **)&name);
		if (name != name_in) {
			FI_WARN(&psmx_prov, FI_LOG_CORE,
				"failed to delete address for service %u: "
				"expecting <%lx>, got <%lx>.\n",
				service, name_in, name);
			return;
		}
                rbtErase(psmx_ns_map, it);
	}
}
Ejemplo n.º 8
0
void tex_cache_clear()
{
	tex_node_p tex_node = NULL;
	int i = 0;
	int delete_max_orig = delete_max;

	delete_count = 0;
	delete_max = node_size;

	rbtInorder(rb,rb->root, deleteNodeProc);
	delete_max = delete_max_orig;

	for(i =0;i<delete_count;i++){
		tex_node = (tex_node_p)(deleted_node[i]->val.node);
		tex_node->next =  free_tex_list;
		free_tex_list = tex_node;
		rbtErase(rb,deleted_node[i]);
	}
}
Ejemplo n.º 9
0
int delete_nkconfig(char *dropkey, int evenifcloned)
{
	RbtHandle handle;
	void *k1, *k2;

	handle = rbtFind(rbconf, dropkey);
	if (handle == rbtEnd(rbconf)) return 0;

	if (!evenifcloned) {
		/* Check if this record has any clones attached to it */
		char *hostname, *p;

		hostname = strdup(dropkey);
		p = strchr(hostname, '|'); if (p) *p = '\0';

		handle = rbtBegin(rbconf);

		while (handle != rbtEnd(rbconf)) {
			void *k1, *k2;
			char *key, *ptr;

			rbtKeyValue(rbconf, handle, &k1, &k2);
			key = (char *)k1; ptr = (char *)k2;
			if ((*(key + strlen(key) - 1) == '=') && (strcmp(hostname, ptr) == 0)) {
				xfree(hostname);
				return 1;
			}

			handle = rbtNext(rbconf, handle);
		}

		xfree(hostname);
	}

	handle = rbtFind(rbconf, dropkey);
	if (handle != rbtEnd(rbconf)) {
		rbtKeyValue(rbconf, handle, &k1, &k2);
		rbtErase(rbconf, handle);
		flushrec(k1, k2);
	}

	return 0;
}
Ejemplo n.º 10
0
void dropclone_nkconfig(char *drop)
{
	RbtHandle handle;
	char *key;
	void *k1, *k2;
	char *dropkey, *dropsrc;

	key = (char *)malloc(strlen(drop) + 2);
	sprintf(key, "%s=", drop);
	handle = rbtFind(rbconf, key);
	if (handle == rbtEnd(rbconf)) return;

	rbtKeyValue(rbconf, handle, &k1, &k2);
	dropkey = k1; dropsrc = k2;
	rbtErase(rbconf, handle);
	xfree(dropkey); xfree(dropsrc);

	xfree(key);
}
Ejemplo n.º 11
0
static int util_ns_map_del(struct util_ns *ns, void *service_in,
			   void *name_in)
{
	RbtIterator it;
	int ret = -FI_ENOENT;
	void *service, *name;

        it = rbtFind(ns->ns_map, service_in);
        if (it) {
		rbtKeyValue(ns->ns_map, it, &service, &name);
		if (memcmp(name, name_in, ns->name_len))
			return ret;
		free(service);
		free(name);
		rbtErase(ns->ns_map, it);
		ret = FI_SUCCESS;
	}

	return ret;
}
Ejemplo n.º 12
0
static int sock_mr_close(struct fid *fid)
{
	struct sock_domain *dom;
	struct sock_mr *mr;
	RbtIterator it;
	RbtStatus res;
	uint64_t mr_key;

	mr = container_of(fid, struct sock_mr, mr_fid.fid);
	dom = mr->domain;
	mr_key = mr->key;

	fastlock_acquire(&dom->lock);
	it = rbtFind(dom->mr_heap, &mr_key);
	if (!it || ((res = rbtErase(dom->mr_heap, it)) != RBT_STATUS_OK))
		SOCK_LOG_ERROR("Invalid mr\n");

	fastlock_release(&dom->lock);
	atomic_dec(&dom->ref);
	free(mr);
	return 0;
}