? src/client/sysint/.sys-io.sm.swp ? src/common/lockhash Index: include/pvfs2-types.h =================================================================== RCS file: /projects/cvsroot/pvfs2/include/pvfs2-types.h,v retrieving revision 1.145 diff -u -a -p -r1.145 pvfs2-types.h --- include/pvfs2-types.h 18 Oct 2007 15:55:01 -0000 1.145 +++ include/pvfs2-types.h 6 Nov 2007 16:08:00 -0000 @@ -222,13 +222,14 @@ typedef struct PVFS_sys_layout_s } PVFS_sys_layout; /* predefined special values for types */ -#define PVFS_HANDLE_NULL ((PVFS_handle)0) -#define PVFS_FS_ID_NULL ((PVFS_fs_id)0) -#define PVFS_OP_NULL ((id_gen_t)0) -#define PVFS_ITERATE_START (INT32_MAX - 1) -#define PVFS_ITERATE_END (INT32_MAX - 2) -#define PVFS_READDIR_START PVFS_ITERATE_START -#define PVFS_READDIR_END PVFS_ITERATE_END +#define PVFS_HANDLE_NULL ((PVFS_handle)0) +#define PVFS_FS_ID_NULL ((PVFS_fs_id)0) +#define PVFS_OP_NULL ((id_gen_t)0) +#define PVFS_BMI_ADDR_NULL ((PVFS_BMI_addr_t)0) +#define PVFS_ITERATE_START (INT32_MAX - 1) +#define PVFS_ITERATE_END (INT32_MAX - 2) +#define PVFS_READDIR_START PVFS_ITERATE_START +#define PVFS_READDIR_END PVFS_ITERATE_END #ifndef O_LARGEFILE #define O_LARGEFILE 0 Index: src/apps/kernel/linux/pvfs2-client-core.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/apps/kernel/linux/pvfs2-client-core.c,v retrieving revision 1.89 diff -u -a -p -r1.89 pvfs2-client-core.c --- src/apps/kernel/linux/pvfs2-client-core.c 8 Oct 2007 22:32:50 -0000 1.89 +++ src/apps/kernel/linux/pvfs2-client-core.c 6 Nov 2007 16:08:00 -0000 @@ -2298,7 +2298,7 @@ static inline void package_downcall_memb PVFS_BMI_addr_t tmp_addr; if (BMI_addr_lookup(&tmp_addr, - vfs_request->mntent->the_pvfs_config_server) == 0) + vfs_request->mntent->the_pvfs_config_server, 0) == 0) { if (BMI_set_info( tmp_addr, BMI_FORCEFUL_CANCEL_MODE, NULL) == 0) Index: src/client/sysint/sys-io.sm =================================================================== RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-io.sm,v retrieving revision 1.158 diff -u -a -p -r1.158 sys-io.sm --- src/client/sysint/sys-io.sm 30 Aug 2007 00:13:42 -0000 1.158 +++ src/client/sysint/sys-io.sm 6 Nov 2007 16:08:00 -0000 @@ -931,6 +931,7 @@ static PINT_sm_action io_datafile_comple /* if recv failed, probably have to do the send again too */ cur_ctx->msg_send_has_been_posted = 0; cur_ctx->msg_recv_has_been_posted = 0; + BMI_endpoint_fail_current_addr(cur_ctx->msg.svr_addr); goto check_next_step; } @@ -1038,6 +1039,7 @@ static PINT_sm_action io_datafile_comple "%s: flow failed, retrying from msgpair\n", __func__); cur_ctx->msg_send_has_been_posted = 0; cur_ctx->msg_recv_has_been_posted = 0; + BMI_endpoint_fail_current_addr(cur_ctx->msg.svr_addr); } else { @@ -1077,6 +1079,7 @@ static PINT_sm_action io_datafile_comple "%s: write-ack failed, retrying from msgpair\n", __func__); cur_ctx->msg_send_has_been_posted = 0; cur_ctx->msg_recv_has_been_posted = 0; + BMI_endpoint_fail_current_addr(cur_ctx->msg.svr_addr); } else { Index: src/common/id-generator/id-generator.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/id-generator/id-generator.c,v retrieving revision 1.9 diff -u -a -p -r1.9 id-generator.c --- src/common/id-generator/id-generator.c 20 Aug 2007 01:39:56 -0000 1.9 +++ src/common/id-generator/id-generator.c 6 Nov 2007 16:08:00 -0000 @@ -13,6 +13,7 @@ #define DEFAULT_ID_GEN_SAFE_TABLE_SIZE 997 static gen_mutex_t s_id_gen_safe_mutex = GEN_MUTEX_INITIALIZER; +static int s_id_gen_safe_init_count = 0; static int hash_key(void *key, int table_size); static int hash_key_compare(void *key, struct qlist_head *link); @@ -43,12 +44,14 @@ int id_gen_safe_initialize() return -PVFS_ENOMEM; } } + s_id_gen_safe_init_count++; return 0; } int id_gen_safe_finalize() { - if(ID_GEN_SAFE_INITIALIZED()) + s_id_gen_safe_init_count--; + if(s_id_gen_safe_init_count == 0 && ID_GEN_SAFE_INITIALIZED()) { gen_mutex_lock(&s_id_gen_safe_mutex); qhash_destroy_and_finalize(s_id_gen_safe_table, id_gen_safe_t, hash_link, free); Index: src/common/misc/msgpairarray.sm =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/misc/msgpairarray.sm,v retrieving revision 1.44 diff -u -a -p -r1.44 msgpairarray.sm --- src/common/misc/msgpairarray.sm 30 Aug 2007 00:13:43 -0000 1.44 +++ src/common/misc/msgpairarray.sm 6 Nov 2007 16:08:00 -0000 @@ -637,6 +637,8 @@ static PINT_sm_action msgpairarray_compl js_p->error_code = MSGPAIRS_RETRY; } + BMI_endpoint_fail_current_addr(msg_p->svr_addr); + } else { char s[1024]; server_config = PINT_server_config_mgr_get_config(msg_p->fs_id); Index: src/common/quickhash/quickhash.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/quickhash/quickhash.h,v retrieving revision 1.14 diff -u -a -p -r1.14 quickhash.h --- src/common/quickhash/quickhash.h 30 Aug 2007 00:13:43 -0000 1.14 +++ src/common/quickhash/quickhash.h 6 Nov 2007 16:08:00 -0000 @@ -25,6 +25,7 @@ #else #include +#include #include "../quicklist/quicklist.h" #define qhash_malloc(x) malloc(x) @@ -288,6 +289,66 @@ static inline struct qhash_head *qhash_s qhash_finalize(_oldtable); \ \ } while(0) + +/* http://www.cris.com/~Ttwang/tech/inthash.htm */ +static inline int quickhash_32bit_hash(void *k, int table_size) +{ + int32_t key = *(int32_t *)k; + key = ~key + (key << 15); /* key = (key << 15) - key - 1; */ + key = key ^ (key >> 12); + key = key + (key << 2); + key = key ^ (key >> 4); + key = key * 2057; /* key = (key + (key << 3)) + (key << 11); */ + key = key ^ (key >> 16); + + return (int) (key & (table_size - 1)); +} + +static inline int quickhash_64bit_hash(void *k, int table_size) +{ + uint64_t key = *(uint64_t *)k; + + key = (~key) + (key << 18); /* key = (key << 18) - key - 1; */ + key = key ^ (key >> 31); + key = key * 21; /* key = (key + (key << 2)) + (key << 4); */ + key = key ^ (key >> 11); + key = key + (key << 6); + key = key ^ (key >> 22); + + return (int) (key & ((uint64_t)(table_size - 1))); +} + +/** + * derived from an algorithm found in Aho, Sethi and Ullman's + * {Compilers: Principles, Techniques and Tools}, published by Addison-Wesley. + * This algorithm comes from P.J. Weinberger's C compiler. + */ +static inline int quickhash_string_hash(void *k, int table_size) +{ + const char *str = (char *)k; + uint32_t h, g; + + while(*str) + { + h = (h << 4) + *str++; + if((g = (h & 0xF0UL))) + { + h ^= g >> 24; + h ^= g; + } + } + + return (int)(h & ((uint64_t)(table_size - 1))); +} + +static inline int quickhash_voidp_hash(void *key, int tablesize) +{ +#if PVFS2_SIZEOF_VOIDP == 32 + return (int)(((int)key) & (table_size - 1)); +#else + return quickhash_64bit_hash(key, tablesize); +#endif +} #endif /* QUICKHASH_H */ Index: src/io/bmi/bmi-addr.c =================================================================== RCS file: src/io/bmi/bmi-addr.c diff -N src/io/bmi/bmi-addr.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/io/bmi/bmi-addr.c 6 Nov 2007 16:08:00 -0000 @@ -0,0 +1,785 @@ +/* + * (C) 2001 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +#include +#include +#include +#include + +#include "bmi-addr.h" +#include "gossip.h" +#include "id-generator.h" +#include "src/common/quickhash/quickhash.h" +#include "gen-locks.h" +#include "str-utils.h" +#include "pvfs2-internal.h" + +struct bmi_endpoint_ref_s; + +struct bmi_addr_ref_s +{ + char *addr_string; + struct bmi_method_addr *method_addr; + struct bmi_endpoint_ref_s *endpoint_ref; + struct qhash_head strlink; + struct qhash_head methlink; +}; + +struct bmi_endpoint_ref_s +{ + char *endpoint_string; + PVFS_BMI_addr_t bmi_endpoint; + struct bmi_addr_ref_s *addrs; + int count; + int current; + struct qlist_head link; + int refcount; +}; + +struct bmi_addr_map_s +{ + struct qhash_table *addr_table; + struct qhash_table *method_table; + struct qlist_head refs; + gen_mutex_t mutex; +}; + +static int bmi_addr_ref_compare(void *key, struct qhash_head *link); +static int bmi_method_addr_compare(void *key, struct qhash_head *link); + +/** + * Construct a new bmi address mapping table. This just initializes and + * returns an opaque reference to an empty structure. All proceeding bmi_addr + * calls take a reference to this structure. + * + * @return the new address map reference. + */ +bmi_addr_map_p bmi_addr_map_new(int expected_addr_count) +{ + struct bmi_addr_map_s *map; + + id_gen_safe_initialize(); + + map = (struct bmi_addr_map_s *) malloc(sizeof(struct bmi_addr_map_s)); + if(!map) + { + return NULL; + } + + /* construct tables with a fill factor of 80%. This table + * holds all unique address references */ + map->addr_table = qhash_init(bmi_addr_ref_compare, + quickhash_string_hash, + (int)(expected_addr_count * 1.2)); + if(!map->addr_table) + { + free(map); + return NULL; + } + + map->method_table = qhash_init(bmi_method_addr_compare, + quickhash_voidp_hash, + (int)(expected_addr_count * 1.2)); + if(!map->method_table) + { + qhash_finalize(map->addr_table); + free(map); + return NULL; + } + + INIT_QLIST_HEAD(&map->refs); + + gen_mutex_init(&map->mutex); + + return map; +} + +/** + * Destroy the mapping table that manages BMI addresses. This + * call removes all entries for bmi addresses, and then does teardown + * of the actual structure. Any references to BMI addrs managed + * by this map will be invalid after this call. In most cases there + * won't be any outstanding references to BMI addrs before calling destroy, + * but because BMI address references are handed to users, its possible + * that there may be. The references are stored in the safe id-gen interface, + * so those invalid references can be caught in later functions. + * + * @param map The mapping table to destroy + * + * @return 0 on success, -BMI_error on failure. + */ +int bmi_addr_map_destroy(bmi_addr_map_p map) +{ + struct bmi_endpoint_ref_s *ref, *tmpref; + int ret; + + gen_mutex_lock(&map->mutex); + + qhash_finalize(map->addr_table); + qhash_finalize(map->method_table); + + qlist_for_each_entry_safe(ref, tmpref, &map->refs, link) + { + gen_mutex_unlock(&map->mutex); + ret = bmi_addr_map_remove(map, ref->bmi_endpoint); + gen_mutex_lock(&map->mutex); + if(ret < 0) + { + return ret; + } + } + + gen_mutex_unlock(&map->mutex); + gen_mutex_destroy(&map->mutex); + + id_gen_safe_finalize(); + + return 0; +} + +/** + * Add a new endpoint to the mapping table. This splits the address + * string into seperate addresses that refer to the same endpoint, + * and adds them as part of the same BMI address. Separate addresses that + * refer to the same endpoint might be for different protocols, or failover + * addresses. The BMI address reference returned by this function will + * point to the first address (leftmost) specified in the comma separated + * address list. Calls to + * @ref bmi_addr_current_id,bmi_addr_current_method_addr + * will return values based on this first address. + * The BMI address reference can be changed to point to the next address + * in the list using the @ref bmi_addr_next function. + * + * @param map the initializing mapping table reference + * @param addrs_string comma separated list of complete addresses + * (://:[]:) referring to the same endpoint. + * @param new_addr an opaque bmi addr reference for the new endpoint. + * + * @return 0 on success, negative -BMI_error on error. + */ +int bmi_addr_add_endpoint(bmi_addr_map_p map, + const char *addrs_string, + PVFS_BMI_addr_t *new_addr) +{ + struct bmi_endpoint_ref_s *newref; + struct bmi_method_ops *ops; + struct bmi_method_ops *prev_ops = NULL; + int addrcount; + char **addrs = NULL; + int i, j, n, ret; + PVFS_BMI_addr_t found_addr; + char *proto; + + assert(addrs_string != NULL); + addrcount = PINT_split_string_list(&addrs, addrs_string); + if(0 == addrcount) + { + gossip_err("%s: No addresses found in address string: %s\n", + __func__, addrs_string); + return -BMI_EINVAL; + } + + /* look for a pre-existing endpoint */ + for(i = 0; i < addrcount; ++i) + { + found_addr = bmi_addr_id_search(map, addrs[i]); + if(found_addr) + { + break; + } + } + + if(found_addr) + { + newref = id_gen_safe_lookup(found_addr); + + /* add all the new addresses to pre-existing endpoint */ + for(i = 0; i < addrcount; ++i) + { + for(j = 0; j < newref->count; ++j) + { + if(!strcmp(newref->addrs[j].addr_string, addrs[i])) + { + break; + } + } + + if(j == newref->count) + { + /* couldn't find the address in the pre-existing endpoint + * reference, so we add it. + */ + newref->addrs = realloc( + newref->addrs, + (newref->count + 1) * sizeof(struct bmi_addr_ref_s)); + if(!newref->addrs) + { + PINT_free_string_list(addrs, addrcount); + + for(n = 0; newref->count; ++n) + { + qhash_search_and_remove( + map->addr_table, newref->addrs[n].addr_string); + qhash_search_and_remove( + map->method_table, newref->addrs[n].method_addr); + qlist_del(&(newref->link)); + return -BMI_ENOMEM; + } + } + newref->addrs[j].addr_string = addrs[i]; + + /* grab the characters of the address string + * that specify the protocol + */ + ops = bmi_method_find(addrs[i]); + if(!ops) + { + /* try to activate and get the method again */ + ret = bmi_method_activate_from_addr(addrs[i]); + if(ret < 0) + { + return ret; + } + ops = bmi_method_find(addrs[i]); + } + + if(!ops) + { + gossip_err( + "%s: failed to find a BMI method for the protocol: %s\n", + __func__, proto); + free(proto); + PINT_free_string_list(addrs, addrcount); + free(newref); + return -PVFS_EINVAL; + } + + if(prev_ops && prev_ops != ops) + { + gossip_err("%s: can't add multiple addresses for the same " + "endpoint on different protocols: " + "new proto: %s, old proto: %s\n", + __func__, ops->method_name, prev_ops->method_name); + return -PVFS_EINVAL; + } + prev_ops = ops; + + newref->addrs[j].method_addr = ops->method_addr_lookup(addrs[i]); + newref->addrs[j].endpoint_ref = newref; + newref->count++; + + /* now add the address to the hashtable keyed + * on the address string + */ + gen_mutex_lock(&map->mutex); + qhash_add(map->addr_table, + newref->addrs[j].addr_string, + &newref->addrs[j].strlink); + qhash_add(map->method_table, + newref->addrs[j].method_addr, + &newref->addrs[j].methlink); + gen_mutex_unlock(&map->mutex); + } + } + } + + /* haven't seen any of these addresses before, add a new endpoint */ + newref = malloc(sizeof(struct bmi_addr_ref_s)); + if(!newref) + { + PINT_free_string_list(addrs, addrcount); + return -BMI_ENOMEM; + } + memset(newref, 0, sizeof(struct bmi_addr_ref_s)); + + newref->count = addrcount; + newref->addrs = malloc(sizeof(struct bmi_addr_ref_s) * addrcount); + if(!newref->addrs) + { + PINT_free_string_list(addrs, addrcount); + free(newref); + return -BMI_ENOMEM; + } + + for(i = 0; i < addrcount; ++i) + { + /* we don't strdup here because we can reuse the allocated pointer + * from the split call */ + newref->addrs[i].addr_string = addrs[i]; + + /* grab the characters of the address string that specify the protocol + */ + ops = bmi_method_find(addrs[i]); + if(!ops) + { + /* try to activate and get the method again */ + ret = bmi_method_activate_from_addr(addrs[i]); + if(ret < 0) + { + return ret; + } + ops = bmi_method_find(addrs[i]); + } + + if(!ops) + { + gossip_err("%s: failed to find a BMI method for the protocol: %s\n", + __func__, proto); + free(proto); + PINT_free_string_list(addrs, addrcount); + free(newref); + return -PVFS_EINVAL; + } + + if(prev_ops && prev_ops != ops) + { + gossip_err("%s: can't add multiple addresses for the same " + "endpoint on different protocols: " + "new proto: %s, old proto: %s\n", + __func__, ops->method_name, prev_ops->method_name); + return -PVFS_EINVAL; + } + prev_ops = ops; + + newref->addrs[i].method_addr = ops->method_addr_lookup(addrs[i]); + newref->addrs[i].endpoint_ref = newref; + } + + /* get rid of the array of address strings from the split */ + free(addrs); + + /* add the endpoint reference to the list of references */ + gen_mutex_lock(&map->mutex); + qlist_add(&(newref->link), &map->refs); + + /* now add each of the endpoint's addresses to the hashtable keyed + * on the address string + */ + for(i = 0; i < addrcount; ++i) + { + qhash_add(map->addr_table, + newref->addrs[i].addr_string, + &newref->addrs[i].strlink); + qhash_add(map->method_table, + newref->addrs[i].method_addr, + &newref->addrs[i].methlink); + } + gen_mutex_unlock(&map->mutex); + + id_gen_safe_register(&newref->bmi_endpoint, newref); + *new_addr = newref->bmi_endpoint; + return 0; +} + +/** + * Add a pre-created method addr to the mapping table. + * + * @param map the initialized mapping table reference + * @param addrs_string comma separated list of complete addresses + * (://:[]:) referring to the same endpoint. + * @param new_addr an opaque bmi addr reference for the new endpoint. + * + * @return 0 on success, negative -BMI_error on error. + */ +int bmi_addr_add_method(bmi_addr_map_p map, + bmi_method_addr_p method_addr, + PVFS_BMI_addr_t *new_addr) +{ + int ret = 0; + struct bmi_endpoint_ref_s *newref; + + newref = malloc(sizeof(struct bmi_addr_ref_s)); + if(!newref) + { + return -BMI_ENOMEM; + } + memset(newref, 0, sizeof(struct bmi_addr_ref_s)); + + newref->count = 1; + newref->addrs = malloc(sizeof(struct bmi_addr_ref_s)); + if(!newref->addrs) + { + free(newref); + return -BMI_ENOMEM; + } + + newref->addrs[0].method_addr = method_addr; + newref->addrs[0].endpoint_ref = newref; + + /* add the endpoint reference to the list of references */ + gen_mutex_lock(&map->mutex); + qlist_add(&(newref->link), &map->refs); + gen_mutex_unlock(&map->mutex); + + ret = id_gen_safe_register(&newref->bmi_endpoint, newref); + *new_addr = newref->bmi_endpoint; + return ret; +} + +/** + * Search for a BMI address based on the address string + * (://:[:]). The reference count is incremented + * if a valid BMI address is returned. The @ref bmi_addr_release function + * should be called when the address is no longer in use. + * + * @param map The map that manages all the addresses. + * @param addr_string The address string to lookup. + * @param addr The output parameter for the BMI address if one is found. + * string. + * + * @return the BMI address on success, PVFS_BMI_ADDR_NULL if not found. + */ +PVFS_BMI_addr_t bmi_addr_id_search(bmi_addr_map_p map, + const char *addr_string) +{ + struct bmi_addr_ref_s *ref; + struct qhash_head *link; + + gen_mutex_lock(&map->mutex); + link = qhash_search(map->addr_table, (char *)addr_string); + gen_mutex_unlock(&map->mutex); + if(!link) + { + return -BMI_ENOENT; + } + + ref = qhash_entry(link, struct bmi_addr_ref_s, strlink); + + return ref->endpoint_ref->bmi_endpoint; +} + +/** + * Search for a BMI address based on the method address pointer. + * The reference count is incremented if a valid BMI address is returned. + * The @ref bmi_addr_release function should be called when the address + * is no longer in use. + * + * @param map The map that manages all the addresses. + * @param method_addr The method address pointer to lookup. + * @param addr The output parameter for the BMI address if one is found. + * + * @return the BMI address on success, PVFS_BMI_ADDR_NULL if not found. + */ +PVFS_BMI_addr_t bmi_addr_method_search(bmi_addr_map_p map, + bmi_method_addr_p method_addr) +{ + struct bmi_addr_ref_s *ref; + struct qhash_head *link; + + gen_mutex_lock(&map->mutex); + link = qhash_search(map->addr_table, method_addr); + gen_mutex_unlock(&map->mutex); + if(!link) + { + return PVFS_BMI_ADDR_NULL; + } + + ref = qhash_entry(link, struct bmi_addr_ref_s, methlink); + return ref->endpoint_ref->bmi_endpoint; +} + +/** + * Remove the BMI address and all its contents from the mapping table. + * + * @param map The mapping table to remove the address from + * @param addr The BMI address to remove + * + * @return 0 on success, -BMI_error on error. If the address is not + * found in the mapping table, -BMI_ENOENT is returned. + */ +int bmi_addr_map_remove(bmi_addr_map_p map, PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + struct qhash_head *strlink; + struct qhash_head *methlink; + int i; + + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + if(!ref) + { + return -BMI_EINVAL; + } + + id_gen_safe_unregister(addr); + + gen_mutex_lock(&map->mutex); + for(i = 0; i < ref->count; ++i) + { + strlink = qhash_search_and_remove( + map->addr_table, ref->addrs[i].addr_string); + if(!strlink) + { + /* The address string isn't in the hashtable! */ + return -BMI_EINVAL; + } + + methlink = qhash_search_and_remove( + map->method_table, ref->addrs[i].method_addr); + if(!methlink) + { + /* The method address isn't in the hashtable! */ + return -BMI_EINVAL; + } + + qlist_del(&ref->link); + } + gen_mutex_unlock(&map->mutex); + + for(i = 0; i < ref->count; ++i) + { + free(ref->addrs[i].addr_string); + } + free(ref->addrs); + free(ref); + + return 0; +} + +/** + * Get the id string of the current address pointed to by the + * BMI address reference. + * + * @param map The map maintaining the BMI address reference + * @param addr The BMI address reference to get the id string of + * + * @return The current id string of the address. If no address was found + * in the map, NULL is returned. The string returned from this function + * does not need to be freed by the caller. It remains in scope until + * the entire BMI address reference is removed from the mapping table. + */ +inline char * +bmi_addr_current_id(PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + if(!ref) + { + return NULL; + } + + return ref->addrs[ref->current].addr_string; + +} + +/** + * Get the method address of the current address pointed to by the + * BMI address reference. + * + * @param map The map maintaining the BMI address reference + * @param addr The BMI address reference to get the method address of + * + * @return The current method address of the BMI address. + * If no address was found + * in the map, NULL is returned. The method address returned from this function + * does not need to be freed by the caller. It remains in scope until + * the entire BMI address reference is removed from the mapping table. + */ +inline struct bmi_method_addr * +bmi_addr_current_method_addr(PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + if(!ref) + { + return NULL; + } + + return ref->addrs[ref->current].method_addr; +} + +int bmi_addr_refcount_increment(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + if(!ref) + { + return -BMI_EINVAL; + } + ref->refcount++; + return 0; +} + +int bmi_addr_refcount_decrement(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + if(!ref) + { + return -BMI_EINVAL; + } + + if(--ref->refcount == 0) + { + bmi_addr_drop_endpoint(addr_map, addr, 0); + } + return 0; +} + +static int bmi_addr_refcount(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + assert(ref != 0); + + return ref->refcount; +} + +/** + * Shift the current address this BMI address refers to the next + * address in the list. Future calls to @ref bmi_addr_current_id, + * bmi_addr_current_method_address will + * return updated values based on the new current address. + * + * This list of addresses is circular. Once the last address in the + * list is reached by this function, the BMI address is updated to + * refer to the first address in the list. We drop the previous address + * to prevent multiple connections for the same endpoint. + * + * @param map The mapping table maintaining the address + * @param addr The BMI address reference to update + * + * @return 0 on success, -BMI_error on failure. + */ +int bmi_addr_next(bmi_addr_map_p map, PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref; + ref = (struct bmi_endpoint_ref_s *)id_gen_safe_lookup(addr); + if(!ref) + { + return -BMI_EINVAL; + } + + bmi_addr_drop_current_addr(map, addr); + ref->current = ref->current + 1 % ref->count; + return 0; +} + +/* bmi_addr_drop + * + * Destroys a complete BMI address, including asking the method to clean up + * its portion. Will query the method for permission before proceeding + * + * NOTE: must be called with ref list mutex held + * + * Returns 0 on successful drop of the addr, or -PVFS_EINVAL if the reference + * count for the address is non-zero. + */ +int bmi_addr_drop_endpoint(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr, + int force) +{ + struct method_drop_addr_query query; + query.response = 0; + query.addr = bmi_addr_current_method_addr(addr); + int ret = 0; + + /* check that refcount of endpoint is zero. If non-zero, + * we just return EINVAL. This may not be an error, but can + * be checked by the caller. + */ + if(bmi_addr_refcount(addr_map, addr) != 0) + { + return -PVFS_EINVAL; + } + + if(force) + { + /* don't ask the method if the connection is dead, drop anyway */ + query.addr->ops->set_info(BMI_DROP_ADDR, query.addr); + bmi_addr_map_remove(addr_map, addr); + return 0; + } + + /* reference count is zero; ask module if it wants us to discard + * the address; TCP will tell us to drop addresses for which the + * socket has died with no possibility of reconnect + */ + ret = query.addr->ops->get_info(BMI_DROP_ADDR_QUERY, &query); + if(ret == 0 && query.response == 1) + { + /* kill the address */ + gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, + "[BMI CONTROL]: %s: bmi discarding address: %llu\n", + __func__, llu(addr)); + /* NOTE: this triggers request to module to free underlying + * resources if it wants to + */ + if (query.addr) + { + query.addr->ops->set_info(BMI_DROP_ADDR, query.addr); + } + bmi_addr_map_remove(addr_map, addr); + } + return 0; +} + +int bmi_addr_drop_current_addr(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr) +{ + struct bmi_endpoint_ref_s *ref = id_gen_safe_lookup(addr); + struct bmi_addr_ref_s *addr_ref = &ref->addrs[ref->current]; + + if(!ref) + { + return -PVFS_EINVAL; + } + + /* kill the address */ + gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, + "[BMI CONTROL]: %s: bmi discarding address: %s\n", + __func__, addr_ref->addr_string); + /* NOTE: this triggers request to module to free underlying + * resources if it wants to + */ + addr_ref->method_addr->ops->set_info(BMI_DROP_ADDR, addr_ref->method_addr); + + return 0; +} + +struct bmi_method_ops *bmi_addr_get_method(PVFS_BMI_addr_t addr) +{ + struct bmi_method_addr *meth_addr; + + meth_addr = bmi_addr_current_method_addr(addr); + if(meth_addr) + { + return meth_addr->ops; + } + return NULL; +} + +static int bmi_addr_ref_compare(void *key, struct qhash_head *link) +{ + const char *str = (char *)key; + struct bmi_addr_ref_s *ref = + qhash_entry(link, struct bmi_addr_ref_s, strlink); + + if(!strcmp(ref->addr_string, str)) + { + return 1; + } + return 0; +} + +static int bmi_method_addr_compare(void *key, struct qhash_head *link) +{ + struct bmi_method_addr *meth_addr = (struct bmi_method_addr *)key; + struct bmi_addr_ref_s *addr_ref = + qhash_entry(link, struct bmi_addr_ref_s, methlink); + + if(addr_ref->method_addr == meth_addr) + { + return 1; + } + return 0; +} + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */ Index: src/io/bmi/bmi-addr.h =================================================================== RCS file: src/io/bmi/bmi-addr.h diff -N src/io/bmi/bmi-addr.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/io/bmi/bmi-addr.h 6 Nov 2007 16:08:00 -0000 @@ -0,0 +1,68 @@ +/* + * (C) 2001 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + + +/* + * Header for address mapping from strings and method address structs to + * BMI address pointers. + */ + +#ifndef __BMI_ADDR_H +#define __BMI_ADDR_H + +#include "bmi-types.h" +#include "bmi-method-support.h" +#include "quicklist.h" + +typedef struct bmi_addr_map_s *bmi_addr_map_p; + +bmi_addr_map_p bmi_addr_map_new(int expected_addr_count); + +int bmi_addr_map_destroy(bmi_addr_map_p map); + +int bmi_addr_add_endpoint(bmi_addr_map_p map, + const char *addrs_string, + PVFS_BMI_addr_t *new_addr); + +int bmi_addr_add_method(bmi_addr_map_p map, + bmi_method_addr_p method_addr, + PVFS_BMI_addr_t *new_addr); + +PVFS_BMI_addr_t bmi_addr_method_search(bmi_addr_map_p map, + bmi_method_addr_p method_addr); + +PVFS_BMI_addr_t bmi_addr_id_search(bmi_addr_map_p map, + const char *addr_string); + +int bmi_addr_map_remove(bmi_addr_map_p map, PVFS_BMI_addr_t addr); + +inline char * +bmi_addr_current_id(PVFS_BMI_addr_t addr); + +inline struct bmi_method_addr * +bmi_addr_current_method_addr(PVFS_BMI_addr_t addr); + +int bmi_addr_next(bmi_addr_map_p map, PVFS_BMI_addr_t addr); + +int bmi_addr_drop_endpoint(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr, + int force); +int bmi_addr_drop_current_addr(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr); + +struct bmi_method_ops *bmi_addr_get_method(PVFS_BMI_addr_t addr); + +int bmi_addr_refcount_increment(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr); +int bmi_addr_refcount_decrement(bmi_addr_map_p addr_map, PVFS_BMI_addr_t addr); + +#endif /* __BMI_ADDR_H */ + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */ Index: src/io/bmi/bmi-method-callback.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi-method-callback.h,v retrieving revision 1.6 diff -u -a -p -r1.6 bmi-method-callback.h --- src/io/bmi/bmi-method-callback.h 9 Oct 2007 21:58:29 -0000 1.6 +++ src/io/bmi/bmi-method-callback.h 6 Nov 2007 16:08:00 -0000 @@ -9,7 +9,7 @@ #include "bmi-method-support.h" -PVFS_BMI_addr_t bmi_method_addr_reg_callback(method_addr_p map); +PVFS_BMI_addr_t bmi_method_addr_reg_callback(bmi_method_addr_p map); int bmi_method_addr_forget_callback(PVFS_BMI_addr_t addr); #endif /* __BMI_METHOD_CALLBACK_H */ Index: src/io/bmi/bmi-method-support.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi-method-support.c,v retrieving revision 1.11 diff -u -a -p -r1.11 bmi-method-support.c --- src/io/bmi/bmi-method-support.c 22 Aug 2007 16:12:44 -0000 1.11 +++ src/io/bmi/bmi-method-support.c 6 Nov 2007 16:08:00 -0000 @@ -13,17 +13,88 @@ #include "bmi-types.h" #include "bmi-method-support.h" #include "id-generator.h" -#include "reference-list.h" +#include "gen-locks.h" +#include "str-utils.h" +#include "gossip.h" + +/* + * List of "known" BMI methods. This is dynamic, starting with + * just the static ones above, and perhaps adding more if we turn + * back on dynamic module loading. + */ +static int known_method_count = 0; +static struct bmi_method_ops **known_method_table = 0; + +int bmi_active_method_count = 0; +gen_mutex_t bmi_active_method_count_mutex = GEN_MUTEX_INITIALIZER; + +/* + * List of active BMI methods. These are the ones that will be + * dealt with for a test call, for example. On a client, known methods + * become active only when someone calls BMI_addr_lookup(). On + * a server, all possibly active methods are known at startup time + * because we listen on them for the duration. + */ +struct bmi_method_ops **bmi_active_method_table = NULL; + +static int activate_method(const char *name, const char *listen_addr, + int flags); + +/* + * Static list of defined BMI methods. These are pre-compiled into + * the client libraries and into the server. + */ +#ifdef __STATIC_METHOD_BMI_TCP__ +extern struct bmi_method_ops bmi_tcp_ops; +#endif +#ifdef __STATIC_METHOD_BMI_GM__ +extern struct bmi_method_ops bmi_gm_ops; +#endif +#ifdef __STATIC_METHOD_BMI_MX__ +extern struct bmi_method_ops bmi_mx_ops; +#endif +#ifdef __STATIC_METHOD_BMI_IB__ +extern struct bmi_method_ops bmi_ib_ops; +#endif +#ifdef __STATIC_METHOD_BMI_PORTALS__ +extern struct bmi_method_ops bmi_portals_ops; +#endif + +static struct bmi_method_ops *const static_methods[] = { +#ifdef __STATIC_METHOD_BMI_TCP__ + &bmi_tcp_ops, +#endif +#ifdef __STATIC_METHOD_BMI_GM__ + &bmi_gm_ops, +#endif +#ifdef __STATIC_METHOD_BMI_MX__ + &bmi_mx_ops, +#endif +#ifdef __STATIC_METHOD_BMI_IB__ + &bmi_ib_ops, +#endif +#ifdef __STATIC_METHOD_BMI_PORTALS__ + &bmi_portals_ops, +#endif + NULL +}; + +struct bmi_method_usage *method_usage = NULL; +static const int usage_iters_starvation = 100000; +static const int usage_iters_active = 10000; + +extern int context_array[BMI_MAX_CONTEXTS]; +extern gen_mutex_t context_mutex; /* - * alloc_method_op() + * bmi_alloc_method_op() * * allocates storage for an operation info struct. * * returns a pointer to the new structure on success, NULL on failure. */ -method_op_p alloc_method_op(bmi_size_t payload_size) +method_op_p bmi_alloc_method_op(bmi_size_t payload_size) { /* we are going to allocate the full operation structure as a @@ -57,13 +128,13 @@ method_op_p alloc_method_op(bmi_size_t p } /* - * dealloc_method_op() + * bmi_dealloc_method_op() * * frees the memory allocated to an method_op structure * * no return value */ -void dealloc_method_op(method_op_p op_p) +void bmi_dealloc_method_op(method_op_p op_p) { id_gen_fast_unregister(op_p->op_id); free(op_p); @@ -71,9 +142,8 @@ void dealloc_method_op(method_op_p op_p) return; } - /* - * alloc_method_addr() + * bmi_alloc_method_addr() * * alloc_method_addr is used to generate a basic method_addr struct and * initialize it correctly. @@ -81,8 +151,8 @@ void dealloc_method_op(method_op_p op_p) * Returns a pointer to an allocated method_addr struct on success, * NULL on failure. */ -struct method_addr *alloc_method_addr(int method_type, - bmi_size_t payload_size) +struct bmi_method_addr *bmi_alloc_method_addr(int method_type, + bmi_size_t payload_size) { /* we are going to allocate the full address structure as a @@ -90,10 +160,10 @@ struct method_addr *alloc_method_addr(in * the memory address immediately following the method_addr * structure. */ - struct method_addr *my_method_addr = NULL; - int ssize = sizeof(struct method_addr); + struct bmi_method_addr *my_method_addr = NULL; + int ssize = sizeof(struct bmi_method_addr); /* generic component */ - my_method_addr = (struct method_addr *) malloc(ssize + payload_size); + my_method_addr = (struct bmi_method_addr *) malloc(ssize + payload_size); if (!my_method_addr) { return (NULL); @@ -107,7 +177,7 @@ struct method_addr *alloc_method_addr(in } /* - * dealloc_method_addr() + * bmi_dealloc_method_addr() * * used to deallocate a method_addr structure safely. mainly used by * list management functions. MAKE SURE that any method specific @@ -116,93 +186,425 @@ struct method_addr *alloc_method_addr(in * * no return value */ -void dealloc_method_addr(method_addr_p my_method_addr) +void bmi_dealloc_method_addr(bmi_method_addr_p my_method_addr) { free(my_method_addr); my_method_addr = NULL; return; } +int bmi_methods_initialize(const char *method_list, + const char *listen_addr, + int flags) +{ + int ret; + char **requested_methods = NULL; + char **listen_addrs = NULL; + char *this_addr = NULL; + char *proto = NULL; + int addr_count = 0; + int i, j; + + /* initialize the known method list from the null-terminated static list */ + known_method_count = sizeof(static_methods) / sizeof(static_methods[0]) - 1; + known_method_table = malloc( + known_method_count * sizeof(*known_method_table)); + if (!known_method_table) + return bmi_errno_to_pvfs(-ENOMEM); + memcpy(known_method_table, static_methods, + known_method_count * sizeof(*known_method_table)); + + gen_mutex_lock(&bmi_active_method_count_mutex); + if (!method_list) { + /* nothing active until lookup */ + bmi_active_method_count = 0; + } else { + /* split and initialize the requested method list */ + int numreq = PINT_split_string_list(&requested_methods, method_list); + if (numreq < 1) + { + gossip_lerr("Error: bad method list.\n"); + ret = bmi_errno_to_pvfs(-EINVAL); + gen_mutex_unlock(&bmi_active_method_count_mutex); + goto init_failure; + } + + /* Today is that day! */ + addr_count = PINT_split_string_list(&listen_addrs, listen_addr); + + for (i=0; i, and find the + * part + */ + proto = strstr(requested_methods[i], "bmi_"); + if(!proto) + { + gossip_err("%s: Invalid method name: %s. Method names " + "must start with 'bmi_'\n", + __func__, requested_methods[i]); + ret = -PVFS_EINVAL; + gen_mutex_unlock(&bmi_active_method_count_mutex); + goto init_failure; + } + proto += 4; + + /* match the proper listen addr to the method */ + for(j=0; j:// and ends with a null terminator. - * The function strips all whitespace, commas, and address fields which do - * not match the key. - * - * Boy, I sure do hate writing code to parse strings... - * - * returns a pointer to the new string on success, NULL on failure. - */ -char *string_key(const char *key, - const char *id_string) +init_failure: + gen_mutex_lock(&bmi_active_method_count_mutex); + /* look for loaded methods and shut down */ + if (bmi_active_method_table) + { + for (i = 0; i < bmi_active_method_count; i++) + { + if (bmi_active_method_table[i]) + { + bmi_active_method_table[i]->finalize(); + } + } + free(bmi_active_method_table); + } + + if (known_method_table) { + free(known_method_table); + known_method_count = 0; + } + + /* get rid of method string list */ + if (requested_methods) + { + for (i = 0; i < bmi_active_method_count; i++) + { + if (requested_methods[i]) + { + free(requested_methods[i]); + } + } + free(requested_methods); + } + + if(listen_addrs) + { + PINT_free_string_list(listen_addrs, addr_count); + } + + bmi_active_method_count = 0; + gen_mutex_unlock(&bmi_active_method_count_mutex); + return ret; +} + +int bmi_methods_finalize(void) { + int i; - const char *holder = NULL; - const char *end = NULL; - char *newkey = NULL; - char *retstring = NULL; - int keysize = 0; - int strsize = 0; - int retsize = 0; + gen_mutex_lock(&bmi_active_method_count_mutex); + /* attempt to shut down active methods */ + for (i = 0; i < bmi_active_method_count; i++) + { + bmi_active_method_table[i]->finalize(); + } + bmi_active_method_count = 0; + free(bmi_active_method_table); + gen_mutex_unlock(&bmi_active_method_count_mutex); + + free(known_method_table); + known_method_count = 0; + + if (method_usage) + free(method_usage); + + return 0; +} + +struct bmi_method_ops *bmi_method_find(const char *protocol) +{ + int i = 0; + const char *proto; - if ((!id_string) || (!key)) + gen_mutex_lock(&bmi_active_method_count_mutex); + for (i = 0; i < bmi_active_method_count; i++) { - return (NULL); + proto = bmi_active_method_table[i]->method_name + 4; + if(strncmp(proto, protocol, strlen(proto)) == 0) + { + gen_mutex_unlock(&bmi_active_method_count_mutex); + return bmi_active_method_table[i]; + } } - keysize = strlen(key); - strsize = strlen(id_string); + gen_mutex_unlock(&bmi_active_method_count_mutex); + return NULL; +} - /* create a new key of the form :// */ - if ((newkey = (char *) malloc(keysize + 4)) == NULL) +int bmi_method_activate_from_addr(const char *id_string) +{ + int i, ret; + gen_mutex_lock(&bmi_active_method_count_mutex); + for (i=0; i "bmi_x" */ + name = known_method_table[i]->method_name + 4; + if (!strncmp(id_string, name, strlen(name))) { + ret = activate_method(known_method_table[i]->method_name, 0, 0); + if (ret < 0) { + break; + } + } + } + gen_mutex_unlock(&bmi_active_method_count_mutex); + if(ret == 0 && i == known_method_count) { - return (NULL); + return -BMI_ENOPROTOOPT; } - strcpy(newkey, key); - strcat(newkey, "://"); + return ret; +} - holder = id_string; +int bmi_methods_open_context(int context_index) +{ + int i, ret; - holder = strstr(holder, newkey); - /* first match */ - if (holder) - { - end = strpbrk(holder, ", \t\n"); - if (end) - { - end = end; /* stop on terminator */ - } - else - { - end = id_string + strsize; /* go to the end of the id string (\0) */ - } - /* move holder so it doesn't include the opening key and deliminator */ - holder = holder + keysize + 3; + gen_mutex_lock(&bmi_active_method_count_mutex); + /* tell all of the modules about the new context */ + for (i = 0; i < bmi_active_method_count; i++) + { + ret = bmi_active_method_table[i]->open_context(context_index); + if(ret < 0) + { + /* + one of them failed; kill this context in the previous + modules + */ + --i; + while (i >= 0) + { + bmi_active_method_table[i]->close_context( + context_index); + --i; + } + } } - else + gen_mutex_unlock(&bmi_active_method_count_mutex); + return ret; +} + +int bmi_methods_close_context(int context_index) +{ + int i; + + /* tell all of the modules to get rid of this context */ + gen_mutex_lock(&bmi_active_method_count_mutex); + for (i = 0; i < bmi_active_method_count; i++) { - /* no match */ - free(newkey); - return (NULL); + bmi_active_method_table[i]->close_context(context_index); } + gen_mutex_unlock(&bmi_active_method_count_mutex); + + return 0; +} - /* figure out how long our substring is */ - retsize = (end - holder); - if ((retstring = (char *) malloc(retsize + 1)) == NULL) +/* + * If some method was recently active, poll it again for speed, + * but be sure not to starve any method. If multiple active, + * poll them all. Return idle_time per method too. + */ +void bmi_methods_construct_poll_plan(struct bmi_method_usage **musage, + int *idle_time_ms) +{ + int i, numplan; + int tmp_active_method_count; + + numplan = 0; + + gen_mutex_lock(&bmi_active_method_count_mutex); + tmp_active_method_count = bmi_active_method_count; + gen_mutex_unlock(&bmi_active_method_count_mutex); + + for (i=0; i= usage_iters_starvation) { + /* starving, time to poke this one */ + if (0) gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, + "%s: polling starving meth %d: %d / %d\n", __func__, i, + method_usage[i].iters_polled, usage_iters_starvation); + method_usage[i].plan = 1; + ++numplan; + } + } + + /* if nothing is starving or busy, poll everybody */ + if (numplan == 0) { + for (i=0; imethod_name, name)) break; + if (i < bmi_active_method_count) { - free(newkey); - return (NULL); + return 0; + } + + /* is the method known? */ + for (i=0; imethod_name, name)) break; + if (i == known_method_count) { + gossip_lerr("Error: no method available for %s.\n", name); + return -ENOPROTOOPT; + } + meth = known_method_table[i]; + + /* + * Later: try to load a dynamic module, growing the known method + * table and search it again. + */ + + /* toss it into the active table */ + x = bmi_active_method_table; + bmi_active_method_table = malloc( + (bmi_active_method_count + 1) * sizeof(*bmi_active_method_table)); + if (!bmi_active_method_table) { + bmi_active_method_table = x; + return -ENOMEM; + } + if (bmi_active_method_count) { + memcpy(bmi_active_method_table, x, + bmi_active_method_count * sizeof(*bmi_active_method_table)); + free(x); + } + bmi_active_method_table[bmi_active_method_count] = meth; + + x = method_usage; + method_usage = malloc((bmi_active_method_count + 1) * sizeof(*method_usage)); + if (!method_usage) { + method_usage = x; + return -ENOMEM; + } + if (bmi_active_method_count) { + memcpy(method_usage, x, bmi_active_method_count * sizeof(*method_usage)); + free(x); + } + memset(&method_usage[bmi_active_method_count], 0, sizeof(*method_usage)); + + ++bmi_active_method_count; + + /* initialize it */ + new_addr = 0; + if (listen_addr) { + new_addr = meth->method_addr_lookup(listen_addr); + if (!new_addr) { + gossip_err( + "Error: failed to lookup listen address %s for method %s.\n", + listen_addr, name); + --bmi_active_method_count; + return -EINVAL; + } + /* this is a bit of a hack */ + new_addr->method_type = bmi_active_method_count - 1; + } + ret = meth->initialize(new_addr, bmi_active_method_count - 1, flags); + if (ret < 0) { + gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, + "failed to initialize method %s.\n", name); + --bmi_active_method_count; + return ret; } - /* copy it out */ - strncpy(retstring, holder, retsize); - retstring[retsize] = '\0'; + /* tell it about any open contexts */ + for (i=0; iopen_context(i); + if (ret < 0) + break; + } - free(newkey); - return (retstring); + return ret; } /* Index: src/io/bmi/bmi-method-support.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi-method-support.h,v retrieving revision 1.29 diff -u -a -p -r1.29 bmi-method-support.h --- src/io/bmi/bmi-method-support.h 18 Jul 2007 21:32:57 -0000 1.29 +++ src/io/bmi/bmi-method-support.h 6 Nov 2007 16:08:00 -0000 @@ -39,18 +39,19 @@ * information for every protocol we support. The method routines * upcast the void* to find their particular device information. */ -struct method_addr +struct bmi_method_addr { int method_type; + struct bmi_method_ops *ops; void *method_data; /* area to be used by specific methods */ }; -typedef struct method_addr method_addr_st, *method_addr_p; +typedef struct bmi_method_addr bmi_method_addr_st, *bmi_method_addr_p; /* used to describe unexpected messages that arrive */ -struct method_unexpected_info +struct bmi_method_unexpected_info { bmi_error_code_t error_code; - method_addr_p addr; + bmi_method_addr_p addr; void *buffer; bmi_size_t size; bmi_msg_tag_t tag; @@ -62,112 +63,105 @@ struct method_unexpected_info struct bmi_method_ops { const char *method_name; - int (*BMI_meth_initialize) (method_addr_p, - int, - int); - int (*BMI_meth_finalize) (void); - int (*BMI_meth_set_info) (int, - void *); - int (*BMI_meth_get_info) (int, - void *); - void *(*BMI_meth_memalloc) (bmi_size_t, - enum bmi_op_type); - int (*BMI_meth_memfree) (void *, - bmi_size_t, - enum bmi_op_type); - - int (*BMI_meth_unexpected_free) (void *); - - int (*BMI_meth_post_send) (bmi_op_id_t *, - method_addr_p, - const void *, - bmi_size_t, - enum bmi_buffer_type, - bmi_msg_tag_t, - void *, - bmi_context_id); - int (*BMI_meth_post_sendunexpected) (bmi_op_id_t *, - method_addr_p, - const void *, - bmi_size_t, - enum bmi_buffer_type, - bmi_msg_tag_t, - void *, - bmi_context_id); - int (*BMI_meth_post_recv) (bmi_op_id_t *, - method_addr_p, - void *, - bmi_size_t, - bmi_size_t *, - enum bmi_buffer_type, - bmi_msg_tag_t, - void *, - bmi_context_id); - int (*BMI_meth_test) (bmi_op_id_t, - int *, - bmi_error_code_t *, - bmi_size_t *, - void **, - int, - bmi_context_id); - int (*BMI_meth_testsome) (int, - bmi_op_id_t *, - int *, - int *, - bmi_error_code_t *, - bmi_size_t *, - void **, - int, - bmi_context_id); - int (*BMI_meth_testcontext) (int, - bmi_op_id_t*, - int *, - bmi_error_code_t *, - bmi_size_t *, - void **, - int, - bmi_context_id); - int (*BMI_meth_testunexpected) (int, - int *, - struct method_unexpected_info *, - int); - method_addr_p (*BMI_meth_method_addr_lookup) (const char *); - int (*BMI_meth_post_send_list) (bmi_op_id_t *, - method_addr_p, - const void *const *, - const bmi_size_t *, - int, - bmi_size_t, - enum bmi_buffer_type, - bmi_msg_tag_t, - void *, - bmi_context_id); - int (*BMI_meth_post_recv_list) (bmi_op_id_t *, - method_addr_p, - void *const *, - const bmi_size_t *, - int, - bmi_size_t, - bmi_size_t *, - enum bmi_buffer_type, - bmi_msg_tag_t, - void *, - bmi_context_id); - int (*BMI_meth_post_sendunexpected_list) (bmi_op_id_t *, - method_addr_p, - const void *const *, - const bmi_size_t *, - int, - bmi_size_t, - enum bmi_buffer_type, - bmi_msg_tag_t, - void *, - bmi_context_id); - int (*BMI_meth_open_context)(bmi_context_id); - void (*BMI_meth_close_context)(bmi_context_id); - int (*BMI_meth_cancel)(bmi_op_id_t, bmi_context_id); - const char* (*BMI_meth_rev_lookup_unexpected)(method_addr_p); - int (*BMI_meth_query_addr_range)(method_addr_p, const char *, int); + int (*initialize) (bmi_method_addr_p, int, int); + int (*finalize) (void); + int (*set_info) (int, void *); + int (*get_info) (int, void *); + void *(*memalloc) (bmi_size_t, enum bmi_op_type); + int (*memfree) (void *, bmi_size_t, enum bmi_op_type); + + int (*unexpected_free) (void *); + + int (*post_send) (bmi_op_id_t *, + bmi_method_addr_p, + const void *, + bmi_size_t, + enum bmi_buffer_type, + bmi_msg_tag_t, + void *, + bmi_context_id); + int (*post_sendunexpected) (bmi_op_id_t *, + bmi_method_addr_p, + const void *, + bmi_size_t, + enum bmi_buffer_type, + bmi_msg_tag_t, + void *, + bmi_context_id); + int (*post_recv) (bmi_op_id_t *, + bmi_method_addr_p, + void *, + bmi_size_t, + bmi_size_t *, + enum bmi_buffer_type, + bmi_msg_tag_t, + void *, + bmi_context_id); + int (*test) (bmi_op_id_t, + int *, + bmi_error_code_t *, + bmi_size_t *, + void **, + int, + bmi_context_id); + int (*testsome) (int, + bmi_op_id_t *, + int *, + int *, + bmi_error_code_t *, + bmi_size_t *, + void **, + int, + bmi_context_id); + int (*testcontext) (int, + bmi_op_id_t*, + int *, + bmi_error_code_t *, + bmi_size_t *, + void **, + int, + bmi_context_id); + int (*testunexpected) (int, + int *, + struct bmi_method_unexpected_info *, + int); + bmi_method_addr_p (*method_addr_lookup) (const char *); + int (*post_send_list) (bmi_op_id_t *, + bmi_method_addr_p, + const void *const *, + const bmi_size_t *, + int, + bmi_size_t, + enum bmi_buffer_type, + bmi_msg_tag_t, + void *, + bmi_context_id); + int (*post_recv_list) (bmi_op_id_t *, + bmi_method_addr_p, + void *const *, + const bmi_size_t *, + int, + bmi_size_t, + bmi_size_t *, + enum bmi_buffer_type, + bmi_msg_tag_t, + void *, + bmi_context_id); + int (*post_sendunexpected_list) (bmi_op_id_t *, + bmi_method_addr_p, + const void *const *, + const bmi_size_t *, + int, + bmi_size_t, + enum bmi_buffer_type, + bmi_msg_tag_t, + void *, + bmi_context_id); + int (*open_context)(bmi_context_id); + void (*close_context)(bmi_context_id); + int (*cancel)(bmi_op_id_t, bmi_context_id); + const char* (*rev_lookup_unexpected)(bmi_method_addr_p); + int (*query_addr_range)(bmi_method_addr_p, const char *, int); }; @@ -190,7 +184,7 @@ struct method_op void *buffer; /* the memory region to transfer */ bmi_size_t actual_size; /* total size of the transfer */ bmi_size_t expected_size; /* expected size of the transfer */ - method_addr_st *addr; /* peer address involved in the communication */ + bmi_method_addr_st *addr; /* peer address involved in the communication */ int mode; /* operation mode */ bmi_context_id context_id; /* context */ struct qlist_head op_list_entry; /* op_list link */ @@ -212,26 +206,42 @@ typedef struct method_op method_op_st, * struct method_drop_addr_query { - struct method_addr* addr; + struct bmi_method_addr* addr; int response; }; +struct bmi_method_usage { + int iters_polled; /* how many iterations since this method was polled */ + int iters_active; /* how many iterations since this method had action */ + int plan; +}; + /*********************************************************** * utility functions provided for use by the network methods */ /* functions for managing operations */ -method_op_p alloc_method_op(bmi_size_t payload_size); -void dealloc_method_op(method_op_p op_p); +method_op_p bmi_alloc_method_op(bmi_size_t payload_size); +void bmi_dealloc_method_op(method_op_p op_p); /* These functions can be used to manage generic address structures */ -method_addr_p alloc_method_addr(int method_type, - bmi_size_t payload_size); -void dealloc_method_addr(method_addr_p old_method_addr); - -/* string parsing utilities */ -char *string_key(const char *key, - const char *id_string); +bmi_method_addr_p bmi_alloc_method_addr(int method_type, + bmi_size_t payload_size); +void bmi_dealloc_method_addr(bmi_method_addr_p old_method_addr); + +int bmi_methods_initialize( + const char *method_list, const char *listen_addr, int flags); +int bmi_methods_finalize(void); + +int bmi_method_activate_from_addr(const char *id_string); + +int bmi_methods_open_context(int context_index); +int bmi_methods_close_context(int context_index); + +void bmi_methods_construct_poll_plan(struct bmi_method_usage **musage, + int *idle_time_ms); + +struct bmi_method_ops *bmi_method_find(const char *protocol); #endif /* __BMI_METHOD_SUPPORT_H */ Index: src/io/bmi/bmi.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi.c,v retrieving revision 1.88 diff -u -a -p -r1.88 bmi.c --- src/io/bmi/bmi.c 20 Oct 2007 15:40:13 -0000 1.88 +++ src/io/bmi/bmi.c 6 Nov 2007 16:08:00 -0000 @@ -21,22 +21,37 @@ #include "bmi-method-support.h" #include "bmi-method-callback.h" #include "gossip.h" -#include "reference-list.h" +#include "bmi-addr.h" #include "op-list.h" #include "gen-locks.h" #include "str-utils.h" #include "id-generator.h" #include "pvfs2-internal.h" +/* Addresses are stored in a hashtable, with each client address added to + * the hashtable for a given server. This value should be about 20% larger + * than the max number of clients expected, so we set it to 100K for now. + */ +#define BMI_CLIENT_ADDR_COUNT (1024 * 128) + +/* For clients, we only need to keep track of the server addresses, which + * will be fewer. Assume no more than a few hundred servers for now. + */ +#define BMI_SERVER_ADDR_COUNT (1024) + /* - * List of BMI addrs currently managed. + * Address map of BMI addrs currently managed. */ -static ref_list_p cur_ref_list = NULL; +static bmi_addr_map_p bmi_addrs_map = NULL; + +extern int bmi_active_method_count; +extern gen_mutex_t bmi_active_method_count_mutex; + +extern struct bmi_method_ops **bmi_active_method_table; /* array to keep up with active contexts */ -static int context_array[BMI_MAX_CONTEXTS] = { 0 }; -static gen_mutex_t context_mutex = GEN_MUTEX_INITIALIZER; -static gen_mutex_t ref_mutex = GEN_MUTEX_INITIALIZER; +int context_array[BMI_MAX_CONTEXTS] = { 0 }; +gen_mutex_t context_mutex = GEN_MUTEX_INITIALIZER; static QLIST_HEAD(forget_list); static gen_mutex_t forget_list_mutex = GEN_MUTEX_INITIALIZER; @@ -47,75 +62,7 @@ struct forget_item PVFS_BMI_addr_t addr; }; -/* - * Static list of defined BMI methods. These are pre-compiled into - * the client libraries and into the server. - */ -#ifdef __STATIC_METHOD_BMI_TCP__ -extern struct bmi_method_ops bmi_tcp_ops; -#endif -#ifdef __STATIC_METHOD_BMI_GM__ -extern struct bmi_method_ops bmi_gm_ops; -#endif -#ifdef __STATIC_METHOD_BMI_MX__ -extern struct bmi_method_ops bmi_mx_ops; -#endif -#ifdef __STATIC_METHOD_BMI_IB__ -extern struct bmi_method_ops bmi_ib_ops; -#endif -#ifdef __STATIC_METHOD_BMI_PORTALS__ -extern struct bmi_method_ops bmi_portals_ops; -#endif - -static struct bmi_method_ops *const static_methods[] = { -#ifdef __STATIC_METHOD_BMI_TCP__ - &bmi_tcp_ops, -#endif -#ifdef __STATIC_METHOD_BMI_GM__ - &bmi_gm_ops, -#endif -#ifdef __STATIC_METHOD_BMI_MX__ - &bmi_mx_ops, -#endif -#ifdef __STATIC_METHOD_BMI_IB__ - &bmi_ib_ops, -#endif -#ifdef __STATIC_METHOD_BMI_PORTALS__ - &bmi_portals_ops, -#endif - NULL -}; - -/* - * List of "known" BMI methods. This is dynamic, starting with - * just the static ones above, and perhaps adding more if we turn - * back on dynamic module loading. - */ -static int known_method_count = 0; -static struct bmi_method_ops **known_method_table = 0; -/* - * List of active BMI methods. These are the ones that will be - * dealt with for a test call, for example. On a client, known methods - * become active only when someone calls BMI_addr_lookup(). On - * a server, all possibly active methods are known at startup time - * because we listen on them for the duration. - */ -static int active_method_count = 0; -static gen_mutex_t active_method_count_mutex = GEN_MUTEX_INITIALIZER; - -static struct bmi_method_ops **active_method_table = NULL; -static struct { - int iters_polled; /* how many iterations since this method was polled */ - int iters_active; /* how many iterations since this method had action */ - int plan; -} *method_usage = NULL; -static const int usage_iters_starvation = 100000; -static const int usage_iters_active = 10000; - -static int activate_method(const char *name, const char *listen_addr, - int flags); -static void bmi_addr_drop(ref_st_p tmp_ref); static void bmi_check_forget_list(void); /** Initializes the BMI layer. Must be called before any other BMI @@ -134,12 +81,6 @@ int BMI_initialize(const char *method_li int flags) { int ret = -1; - int i = 0, j = 0; - char **requested_methods = NULL; - char **listen_addrs = NULL; - char *this_addr = NULL; - char *proto = NULL; - int addr_count = 0; /* server must specify method list at startup, optional for client */ if (flags & BMI_INIT_SERVER) { @@ -153,311 +94,30 @@ int BMI_initialize(const char *method_li } } - /* make a new reference list */ - cur_ref_list = ref_list_new(); - if (!cur_ref_list) - { - ret = bmi_errno_to_pvfs(-ENOMEM); - goto bmi_initialize_failure; - } - - /* initialize the known method list from the null-terminated static list */ - known_method_count = sizeof(static_methods) / sizeof(static_methods[0]) - 1; - known_method_table = malloc( - known_method_count * sizeof(*known_method_table)); - if (!known_method_table) - return bmi_errno_to_pvfs(-ENOMEM); - memcpy(known_method_table, static_methods, - known_method_count * sizeof(*known_method_table)); - - gen_mutex_lock(&active_method_count_mutex); - if (!method_list) { - /* nothing active until lookup */ - active_method_count = 0; - } else { - /* split and initialize the requested method list */ - int numreq = PINT_split_string_list(&requested_methods, method_list); - if (numreq < 1) - { - gossip_lerr("Error: bad method list.\n"); - ret = bmi_errno_to_pvfs(-EINVAL); - gen_mutex_unlock(&active_method_count_mutex); - goto bmi_initialize_failure; - } - - /* Today is that day! */ - addr_count = PINT_split_string_list(&listen_addrs, listen_addr); - - for (i=0; i, and find the - * part - */ - proto = strstr(requested_methods[i], "bmi_"); - if(!proto) - { - gossip_err("%s: Invalid method name: %s. Method names " - "must start with 'bmi_'\n", - __func__, requested_methods[i]); - ret = -PVFS_EINVAL; - gen_mutex_unlock(&active_method_count_mutex); - goto bmi_initialize_failure; - } - proto += 4; - - /* match the proper listen addr to the method */ - for(j=0; jBMI_meth_finalize(); - } - } - free(active_method_table); - } - - if (known_method_table) { - free(known_method_table); - known_method_count = 0; - } - - /* get rid of method string list */ - if (requested_methods) - { - for (i = 0; i < active_method_count; i++) - { - if (requested_methods[i]) - { - free(requested_methods[i]); - } - } - free(requested_methods); - } - - if(listen_addrs) - { - PINT_free_string_list(listen_addrs, addr_count); - } - - active_method_count = 0; - gen_mutex_unlock(&active_method_count_mutex); - - return (ret); -} - -/* the following is the old BMI_initialize() function that used dl to - * pull in method modules dynamically. Just hanging around as an - * example... - */ -#if 0 -/* BMI_initialize() - * - * Initializes the BMI layer. Must be called before any other BMI - * functions. module_string is a comma separated list of BMI modules to - * use, listen_addr is a comma separated list of addresses to listen on - * for each module (if needed), and flags are initialization flags. - * - * returns 0 on success, -errno on failure - */ -int BMI_initialize(const char *module_string, - const char *listen_addr, - int flags) -{ - - int ret = -1; - int i = 0; - char **modules = NULL; - void *meth_mod = NULL; - char *mod_error = NULL; - method_addr_p new_addr = NULL; - op_list_p olp = NULL; - - /* TODO: this is a hack to make sure we get all of the symbols loaded - * into the library... is there a better way? - */ - olp = op_list_new(); - op_list_cleanup(olp); - - if (((flags & BMI_INIT_SERVER) && (!listen_addr)) || !module_string) - { - return (bmi_errno_to_pvfs(-EINVAL)); - } - - /* separate out the module list */ - active_method_count = PINT_split_string_list( - &modules, module_string); - if (active_method_count < 1) - { - gossip_lerr("Error: bad module list.\n"); - ret = bmi_errno_to_pvfs(-EINVAL); - goto bmi_initialize_failure; - } - - /* create a table to keep up with the method modules */ - active_method_table = (struct bmi_method_ops **)malloc( - active_method_count * sizeof(struct bmi_method_ops *)); - if (!active_method_table) - { - ret = bmi_errno_to_pvfs(-ENOMEM); - goto bmi_initialize_failure; - } - - /* iterate through each method in the list and load its module */ - for (i = 0; i < active_method_count; i++) - { - meth_mod = dlopen(modules[i], RTLD_NOW); - if (!meth_mod) - { - gossip_lerr("Error: could not open module: %s\n", dlerror()); - ret = bmi_errno_to_pvfs(-EINVAL); - goto bmi_initialize_failure; - } - dlerror(); - - active_method_table[i] = (struct bmi_method_ops *) - dlsym(meth_mod, "method_interface"); - mod_error = dlerror(); - if (mod_error) - { - gossip_lerr("Error: module load: %s\n", mod_error); - ret = bmi_errno_to_pvfs(-EINVAL); - goto bmi_initialize_failure; - } - } + bmi_methods_initialize(method_list, listen_addr, flags); /* make a new reference list */ - cur_ref_list = ref_list_new(); - if (!cur_ref_list) + bmi_addrs_map = bmi_addr_map_new( + (flags & BMI_INIT_SERVER) ? + BMI_CLIENT_ADDR_COUNT : BMI_SERVER_ADDR_COUNT); + if (!bmi_addrs_map) { ret = bmi_errno_to_pvfs(-ENOMEM); goto bmi_initialize_failure; } - /* initialize methods */ - for (i = 0; i < active_method_count; i++) - { - if (flags & BMI_INIT_SERVER) - { - if ((new_addr = - active_method_table[i]-> - BMI_meth_method_addr_lookup(listen_addr)) != NULL) - { - /* this is a bit of a hack */ - new_addr->method_type = i; - ret = active_method_table[i]->BMI_meth_initialize( - new_addr, i, flags); - } - else - { - ret = -1; - } - } - else - { - ret = active_method_table[i]->BMI_meth_initialize( - NULL, i, flags); - } - if (ret < 0) - { - gossip_lerr("Error: initializing module: %s\n", modules[i]); - goto bmi_initialize_failure; - } - } - return (0); bmi_initialize_failure: - /* kill reference list */ - if (cur_ref_list) + if (bmi_addrs_map) { - ref_list_cleanup(cur_ref_list); - } - - /* look for loaded methods and shut down */ - if (active_method_table) - { - for (i = 0; i < active_method_count; i++) - { - if (active_method_table[i]) - { - active_method_table[i]->BMI_meth_finalize(); - } - } - free(active_method_table); - } - - /* get rid of method string list */ - if (modules) - { - for (i = 0; i < active_method_count; i++) - { - if (modules[i]) - { - free(modules[i]); - } - } - free(modules); + bmi_addr_map_destroy(bmi_addrs_map); + bmi_addrs_map = NULL; } return (ret); } -#endif /* 0 */ /** Shuts down the BMI layer. * @@ -465,28 +125,10 @@ int BMI_initialize(const char *module_st */ int BMI_finalize(void) { - int i = -1; - - gen_mutex_lock(&active_method_count_mutex); - /* attempt to shut down active methods */ - for (i = 0; i < active_method_count; i++) - { - active_method_table[i]->BMI_meth_finalize(); - } - active_method_count = 0; - free(active_method_table); - gen_mutex_unlock(&active_method_count_mutex); - - free(known_method_table); - known_method_count = 0; - - if (method_usage) - free(method_usage); - /* destroy the reference list */ /* (side effect: destroys all method addresses as well) */ - ref_list_cleanup(cur_ref_list); - + bmi_addr_map_destroy(bmi_addrs_map); + bmi_methods_finalize(); return (0); } @@ -499,7 +141,6 @@ int BMI_finalize(void) int BMI_open_context(bmi_context_id* context_id) { int context_index; - int i; int ret = 0; gen_mutex_lock(&context_mutex); @@ -520,29 +161,11 @@ int BMI_open_context(bmi_context_id* con return(bmi_errno_to_pvfs(-EBUSY)); } - gen_mutex_lock(&active_method_count_mutex); - /* tell all of the modules about the new context */ - for (i = 0; i < active_method_count; i++) - { - ret = active_method_table[i]->BMI_meth_open_context( - context_index); - if(ret < 0) - { - /* - one of them failed; kill this context in the previous - modules - */ - --i; - while (i >= 0) - { - active_method_table[i]->BMI_meth_close_context( - context_index); - --i; - } - goto out; - } + ret = bmi_methods_open_context(context_index); + if(ret < 0) + { + goto out; } - gen_mutex_unlock(&active_method_count_mutex); context_array[context_index] = 1; *context_id = context_index; @@ -553,13 +176,10 @@ out: return(ret); } - /** Destroys a context previous generated with BMI_open_context(). */ void BMI_close_context(bmi_context_id context_id) { - int i; - gen_mutex_lock(&context_mutex); if(!context_array[context_id]) @@ -568,15 +188,8 @@ void BMI_close_context(bmi_context_id co return; } - /* tell all of the modules to get rid of this context */ - gen_mutex_lock(&active_method_count_mutex); - for (i = 0; i < active_method_count; i++) - { - active_method_table[i]->BMI_meth_close_context(context_id); - } + bmi_methods_close_context(context_id); context_array[context_id] = 0; - gen_mutex_unlock(&active_method_count_mutex); - gen_mutex_unlock(&context_mutex); return; } @@ -596,7 +209,7 @@ int BMI_post_recv(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id) { - ref_st_p tmp_ref = NULL; + struct bmi_method_addr *method_addr; int ret = -1; gossip_debug(GOSSIP_BMI_DEBUG_OFFSETS, @@ -605,17 +218,13 @@ int BMI_post_recv(bmi_op_id_t * id, *id = 0; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, src); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(src); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); + return -BMI_EINVAL; } - gen_mutex_unlock(&ref_mutex); - - ret = tmp_ref->interface->BMI_meth_post_recv( - id, tmp_ref->method_addr, buffer, expected_size, actual_size, + ret = method_addr->ops->post_recv( + id, method_addr, buffer, expected_size, actual_size, buffer_type, tag, user_ptr, context_id); return (ret); } @@ -634,7 +243,7 @@ int BMI_post_send(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id) { - ref_st_p tmp_ref = NULL; + struct bmi_method_addr *method_addr; int ret = -1; gossip_debug(GOSSIP_BMI_DEBUG_OFFSETS, @@ -643,17 +252,14 @@ int BMI_post_send(bmi_op_id_t * id, *id = 0; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, dest); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(dest); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); + return -BMI_EINVAL; } - gen_mutex_unlock(&ref_mutex); - ret = tmp_ref->interface->BMI_meth_post_send( - id, tmp_ref->method_addr, buffer, size, buffer_type, tag, + ret = method_addr->ops->post_send( + id, method_addr, buffer, size, buffer_type, tag, user_ptr, context_id); return (ret); } @@ -672,7 +278,7 @@ int BMI_post_sendunexpected(bmi_op_id_t void *user_ptr, bmi_context_id context_id) { - ref_st_p tmp_ref = NULL; + struct bmi_method_addr *method_addr; int ret = -1; gossip_debug(GOSSIP_BMI_DEBUG_OFFSETS, @@ -681,17 +287,14 @@ int BMI_post_sendunexpected(bmi_op_id_t *id = 0; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, dest); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(dest); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); + return -BMI_EINVAL; } - gen_mutex_unlock(&ref_mutex); - ret = tmp_ref->interface->BMI_meth_post_sendunexpected( - id, tmp_ref->method_addr, buffer, size, buffer_type, tag, + ret = method_addr->ops->post_sendunexpected( + id, method_addr, buffer, size, buffer_type, tag, user_ptr, context_id); return (ret); } @@ -720,8 +323,7 @@ int BMI_test(bmi_op_id_t id, target_op = id_gen_fast_lookup(id); assert(target_op->op_id == id); - ret = active_method_table[ - target_op->addr->method_type]->BMI_meth_test( + ret = target_op->addr->ops->test( id, outcount, error_code, actual_size, user_ptr, max_idle_time_ms, context_id); @@ -744,14 +346,14 @@ int BMI_test(bmi_op_id_t id, * if it becomes used again. */ int BMI_testsome(int incount, - bmi_op_id_t * id_array, - int *outcount, - int *index_array, - bmi_error_code_t * error_code_array, - bmi_size_t * actual_size_array, - void **user_ptr_array, - int max_idle_time_ms, - bmi_context_id context_id) + bmi_op_id_t * id_array, + int *outcount, + int *index_array, + bmi_error_code_t * error_code_array, + bmi_size_t * actual_size_array, + void **user_ptr_array, + int max_idle_time_ms, + bmi_context_id context_id) { int ret = 0; int idle_per_method = 0; @@ -762,9 +364,9 @@ int BMI_testsome(int incount, int tmp_outcount; int tmp_active_method_count; - gen_mutex_lock(&active_method_count_mutex); - tmp_active_method_count = active_method_count; - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_lock(&bmi_active_method_count_mutex); + tmp_active_method_count = bmi_active_method_count; + gen_mutex_unlock(&bmi_active_method_count_mutex); if (max_idle_time_ms < 0) return (bmi_errno_to_pvfs(-EINVAL)); @@ -773,7 +375,7 @@ int BMI_testsome(int incount, if (tmp_active_method_count == 1) { /* shortcircuit for perhaps common case of only one method */ - ret = active_method_table[0]->BMI_meth_testsome( + ret = bmi_active_method_table[0]->testsome( incount, id_array, outcount, index_array, error_code_array, actual_size_array, user_ptr_array, max_idle_time_ms, context_id); @@ -823,7 +425,7 @@ int BMI_testsome(int incount, if(need_to_test) { tmp_outcount = 0; - ret = active_method_table[i]->BMI_meth_testsome( + ret = bmi_active_method_table[i]->testsome( need_to_test, tmp_id_array, &tmp_outcount, &(index_array[*outcount]), &(error_code_array[*outcount]), @@ -850,60 +452,6 @@ int BMI_testsome(int incount, return(0); } - -/* - * If some method was recently active, poll it again for speed, - * but be sure not to starve any method. If multiple active, - * poll them all. Return idle_time per method too. - */ -static void -construct_poll_plan(int nmeth, int *idle_time_ms) -{ - int i, numplan; - - numplan = 0; - for (i=0; i= usage_iters_starvation) { - /* starving, time to poke this one */ - if (0) gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, - "%s: polling starving meth %d: %d / %d\n", __func__, i, - method_usage[i].iters_polled, usage_iters_starvation); - method_usage[i].plan = 1; - ++numplan; - } - } - - /* if nothing is starving or busy, poll everybody */ - if (numplan == 0) { - for (i=0; iBMI_meth_testunexpected( + ret = bmi_active_method_table[i]->testunexpected( (incount - position), &tmp_outcount, (&(sub_info[position])), max_idle_time_ms); if (ret < 0) @@ -962,18 +506,8 @@ int BMI_testunexpected(int incount, info_array[i].buffer = sub_info[i].buffer; info_array[i].size = sub_info[i].size; info_array[i].tag = sub_info[i].tag; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_method_addr( - cur_ref_list, sub_info[i].addr); - if (!tmp_ref) - { - /* yeah, right */ - gossip_lerr("Error: critical BMI_testunexpected failure.\n"); - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); - } - gen_mutex_unlock(&ref_mutex); - info_array[i].addr = tmp_ref->bmi_addr; + info_array[i].addr = bmi_addr_method_search( + bmi_addrs_map, sub_info[i].addr); } /* return 1 if anything completed */ if (ret == 0 && *outcount > 0) @@ -1004,10 +538,11 @@ int BMI_testcontext(int incount, int tmp_outcount = 0; int tmp_active_method_count = 0; struct timespec ts; + struct bmi_method_usage *method_usage; - gen_mutex_lock(&active_method_count_mutex); - tmp_active_method_count = active_method_count; - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_lock(&bmi_active_method_count_mutex); + tmp_active_method_count = bmi_active_method_count; + gen_mutex_unlock(&bmi_active_method_count_mutex); if (max_idle_time_ms < 0) return (bmi_errno_to_pvfs(-EINVAL)); @@ -1026,12 +561,12 @@ int BMI_testcontext(int incount, return(0); } - construct_poll_plan(tmp_active_method_count, &max_idle_time_ms); + bmi_methods_construct_poll_plan(&method_usage, &max_idle_time_ms); while (position < incount && i < tmp_active_method_count) { if (method_usage[i].plan) { - ret = active_method_table[i]->BMI_meth_testcontext( + ret = bmi_active_method_table[i]->testcontext( incount - position, &out_id_array[position], &tmp_outcount, @@ -1079,22 +614,8 @@ int BMI_testcontext(int incount, */ const char* BMI_addr_rev_lookup(PVFS_BMI_addr_t addr) { - ref_st_p tmp_ref = NULL; - char* tmp_str = NULL; - /* find a reference that matches this address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) - { - gen_mutex_unlock(&ref_mutex); - return (NULL); - } - gen_mutex_unlock(&ref_mutex); - - tmp_str = tmp_ref->id_string; - - return(tmp_str); + return bmi_addr_current_id(addr); } /** Performs a reverse lookup, returning a string @@ -1108,25 +629,15 @@ const char* BMI_addr_rev_lookup(PVFS_BMI */ const char* BMI_addr_rev_lookup_unexpected(PVFS_BMI_addr_t addr) { - ref_st_p tmp_ref = NULL; + bmi_method_addr_p method_addr; - /* find a reference that matches this address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(addr); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return ("UNKNOWN"); - } - gen_mutex_unlock(&ref_mutex); - - if(!tmp_ref->interface->BMI_meth_rev_lookup_unexpected) - { - return("UNKNOWN"); + return "UNKNOWN"; } - return(tmp_ref->interface->BMI_meth_rev_lookup_unexpected( - tmp_ref->method_addr)); + return method_addr->ops->rev_lookup_unexpected(method_addr); } @@ -1139,20 +650,16 @@ void *BMI_memalloc(PVFS_BMI_addr_t addr, enum bmi_op_type send_recv) { void *new_buffer = NULL; - ref_st_p tmp_ref = NULL; + bmi_method_addr_p method_addr; - /* find a reference that matches this address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(addr); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (NULL); + return NULL; } - gen_mutex_unlock(&ref_mutex); /* allocate the buffer using the method's mechanism */ - new_buffer = tmp_ref->interface->BMI_meth_memalloc(size, send_recv); + new_buffer = method_addr->ops->memalloc(size, send_recv); return (new_buffer); } @@ -1166,23 +673,16 @@ int BMI_memfree(PVFS_BMI_addr_t addr, bmi_size_t size, enum bmi_op_type send_recv) { - ref_st_p tmp_ref = NULL; - int ret = -1; + bmi_method_addr_p method_addr; - /* find a reference that matches this address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(addr); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EINVAL)); + return -PVFS_EINVAL; } - gen_mutex_unlock(&ref_mutex); /* free the memory */ - ret = tmp_ref->interface->BMI_meth_memfree(buffer, size, send_recv); - - return (ret); + return method_addr->ops->memfree(buffer, size, send_recv); } /** Acknowledge that an unexpected message has been @@ -1191,29 +691,24 @@ int BMI_memfree(PVFS_BMI_addr_t addr, * \return 0 on success, -errno on failure. */ int BMI_unexpected_free(PVFS_BMI_addr_t addr, - void *buffer) + void *buffer) { - ref_st_p tmp_ref = NULL; - int ret = -1; + bmi_method_addr_p method_addr; + int ret; - /* find a reference that matches this address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(addr); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EINVAL)); + return -PVFS_EINVAL; } - gen_mutex_unlock(&ref_mutex); - if (!tmp_ref->interface->BMI_meth_unexpected_free) + if (method_addr->ops->unexpected_free) { - gossip_err("unimplemented BMI_meth_unexpected_free callback\n"); + gossip_err("unimplemented unexpected_free callback\n"); return bmi_errno_to_pvfs(-EOPNOTSUPP); } /* free the memory */ - ret = tmp_ref->interface->BMI_meth_unexpected_free(buffer); - + ret = method_addr->ops->unexpected_free(buffer); return (ret); } @@ -1227,7 +722,6 @@ int BMI_set_info(PVFS_BMI_addr_t addr, { int ret = -1; int i = 0; - ref_st_p tmp_ref = NULL; gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, "[BMI CONTROL]: %s: set_info: %llu option: %d\n", @@ -1237,90 +731,63 @@ int BMI_set_info(PVFS_BMI_addr_t addr, */ if (!addr) { - if (!active_method_table) + if (!bmi_active_method_table) { return (bmi_errno_to_pvfs(-EINVAL)); } - gen_mutex_lock(&active_method_count_mutex); - for (i = 0; i < active_method_count; i++) + gen_mutex_lock(&bmi_active_method_count_mutex); + for (i = 0; i < bmi_active_method_count; i++) { - ret = active_method_table[i]->BMI_meth_set_info( - option, inout_parameter); + ret = bmi_active_method_table[i]->set_info(option, inout_parameter); /* we bail out if even a single set_info fails */ if (ret < 0) { gossip_lerr( "Error: failure on set_info to method: %d\n", i); - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_unlock(&bmi_active_method_count_mutex); return (ret); } } - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_unlock(&bmi_active_method_count_mutex); return (0); } gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, "[BMI CONTROL]: %s: searching for ref %llu\n", __func__, llu(addr)); - /* find a reference that matches this address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) - { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EINVAL)); - } /* shortcut address reference counting */ if(option == BMI_INC_ADDR_REF) { - tmp_ref->ref_count++; - gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, - "[BMI CONTROL]: %s: incremented ref %llu to: %d\n", - __func__, llu(addr), tmp_ref->ref_count); - gen_mutex_unlock(&ref_mutex); - return(0); + bmi_addr_refcount_increment(bmi_addrs_map, addr); + return(0); } if(option == BMI_DEC_ADDR_REF) { - tmp_ref->ref_count--; - gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, - "[BMI CONTROL]: %s: decremented ref %llu to: %d\n", - __func__, llu(addr), tmp_ref->ref_count); - assert(tmp_ref->ref_count >= 0); - - if(tmp_ref->ref_count == 0) - { - bmi_addr_drop(tmp_ref); - } - gen_mutex_unlock(&ref_mutex); - return(0); + bmi_addr_refcount_decrement(bmi_addrs_map, addr); + return(0); } /* if the caller requests a TCP specific close socket action */ if (option == BMI_TCP_CLOSE_SOCKET) { /* check to see if the address is in fact a tcp address */ - if(strcmp(tmp_ref->interface->method_name, "bmi_tcp") == 0) + if(strcmp(bmi_addr_get_method(addr)->method_name, "bmi_tcp") == 0) { /* take the same action as in the BMI_DEC_ADDR_REF case to clean * out the entire address structure and anything linked to it so * that the next addr_lookup starts from scratch */ - gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, + gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, "[BMI CONTROL]: %s: Closing bmi_tcp " "connection at caller's request.\n", __func__); - ref_list_rem(cur_ref_list, addr); - dealloc_ref_st(tmp_ref); + bmi_addr_drop_endpoint(bmi_addrs_map, addr, 0); } - gen_mutex_unlock(&ref_mutex); return 0; } - gen_mutex_unlock(&ref_mutex); - - ret = tmp_ref->interface->BMI_meth_set_info(option, inout_parameter); + ret = bmi_addr_get_method(addr)->set_info(option, inout_parameter); return (ret); } @@ -1337,28 +804,28 @@ int BMI_get_info(PVFS_BMI_addr_t addr, int maxsize = 0; int tmp_maxsize; int ret = 0; - ref_st_p tmp_ref = NULL; + struct bmi_method_ops *ops; switch (option) { /* check to see if the interface is initialized */ case BMI_CHECK_INIT: - gen_mutex_lock(&active_method_count_mutex); - if (active_method_count > 0) + gen_mutex_lock(&bmi_active_method_count_mutex); + if (bmi_active_method_count > 0) { - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_unlock(&bmi_active_method_count_mutex); return (0); } else { - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_unlock(&bmi_active_method_count_mutex); return (bmi_errno_to_pvfs(-ENETDOWN)); } case BMI_CHECK_MAXSIZE: - gen_mutex_lock(&active_method_count_mutex); - for (i = 0; i < active_method_count; i++) + gen_mutex_lock(&bmi_active_method_count_mutex); + for (i = 0; i < bmi_active_method_count; i++) { - ret = active_method_table[i]->BMI_meth_get_info( + ret = bmi_active_method_table[i]->get_info( option, &tmp_maxsize); if (ret < 0) { @@ -1375,30 +842,11 @@ int BMI_get_info(PVFS_BMI_addr_t addr, } *((int *) inout_parameter) = maxsize; } - gen_mutex_unlock(&active_method_count_mutex); - break; - case BMI_GET_METH_ADDR: - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if(!tmp_ref) - { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EINVAL)); - } - gen_mutex_unlock(&ref_mutex); - *((void**) inout_parameter) = tmp_ref->method_addr; + gen_mutex_unlock(&bmi_active_method_count_mutex); break; case BMI_GET_UNEXP_SIZE: - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if(!tmp_ref) - { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EINVAL)); - } - gen_mutex_unlock(&ref_mutex); - ret = tmp_ref->interface->BMI_meth_get_info( - option, inout_parameter); + ops = bmi_addr_get_method(addr); + ret = ops->get_info(option, inout_parameter); if(ret < 0) { return ret; @@ -1406,7 +854,7 @@ int BMI_get_info(PVFS_BMI_addr_t addr, break; default: - return (bmi_errno_to_pvfs(-ENOSYS)); + return (bmi_errno_to_pvfs(-ENOSYS)); } return (0); } @@ -1423,21 +871,18 @@ int BMI_query_addr_range (PVFS_BMI_addr_ int i = 0, failed = 1; int provided_method_length = 0; char *ptr, *provided_method_name = NULL; - ref_st_p tmp_ref = NULL; + struct bmi_method_addr *method_addr; if((strlen(id_string)+1) > BMI_MAX_ADDR_LEN) { return(bmi_errno_to_pvfs(-ENAMETOOLONG)); } /* lookup the provided address */ - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, addr); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(addr); + if(!method_addr) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); + return -PVFS_EINVAL; } - gen_mutex_unlock(&ref_mutex); ptr = strchr(id_string, ':'); if (ptr == NULL) @@ -1457,16 +902,16 @@ int BMI_query_addr_range (PVFS_BMI_addr_ * matches the specified wildcard address. */ i = 0; - gen_mutex_lock(&active_method_count_mutex); - while (i < active_method_count) + gen_mutex_lock(&bmi_active_method_count_mutex); + while (i < bmi_active_method_count) { - const char *active_method_name = active_method_table[i]->method_name + 4; + const char *active_method_name = bmi_active_method_table[i]->method_name + 4; /* provided name matches this interface */ if (!strncmp(active_method_name, provided_method_name, provided_method_length)) { - int (*meth_fnptr)(method_addr_p, const char *, int); + int (*meth_fnptr)(bmi_method_addr_p, const char *, int); failed = 0; - if ((meth_fnptr = active_method_table[i]->BMI_meth_query_addr_range) == NULL) + if ((meth_fnptr = bmi_active_method_table[i]->query_addr_range) == NULL) { ret = -ENOSYS; gossip_lerr("Error: method doesn't implement querying address range/wildcards! Cannot implement FS export options!\n"); @@ -1474,20 +919,25 @@ int BMI_query_addr_range (PVFS_BMI_addr_ break; } /* pass it into the specific bmi layer */ - ret = meth_fnptr(tmp_ref->method_addr, id_string, netmask); + ret = meth_fnptr(method_addr, id_string, netmask); if (ret < 0) failed = 1; break; } i++; } - gen_mutex_unlock(&active_method_count_mutex); + gen_mutex_unlock(&bmi_active_method_count_mutex); free(provided_method_name); if (failed) return bmi_errno_to_pvfs(ret); return ret; } +int BMI_endpoint_fail_current_addr(PVFS_BMI_addr_t addr) +{ + return bmi_addr_next(bmi_addrs_map, addr); +} + /** Resolves the string representation of a host address into a BMI * address handle. * @@ -1496,129 +946,41 @@ int BMI_query_addr_range (PVFS_BMI_addr_ int BMI_addr_lookup(PVFS_BMI_addr_t * new_addr, const char *id_string) { - - ref_st_p new_ref = NULL; - method_addr_p meth_addr = NULL; + bmi_method_addr_p meth_addr = NULL; int ret = -1; int i = 0; - int failed; if((strlen(id_string)+1) > BMI_MAX_ADDR_LEN) { return(bmi_errno_to_pvfs(-ENAMETOOLONG)); } - /* set the addr to zero in case we fail */ - *new_addr = 0; - /* First we want to check to see if this host has already been * discovered! */ - gen_mutex_lock(&ref_mutex); - new_ref = ref_list_search_str(cur_ref_list, id_string); - gen_mutex_unlock(&ref_mutex); - - if (new_ref) - { - /* we found it. */ - *new_addr = new_ref->bmi_addr; - return (0); - } - - /* Now we will run through each method looking for one that - * responds successfully. It is assumed that they are already - * listed in order of preference - */ - i = 0; - gen_mutex_lock(&active_method_count_mutex); - while ((i < active_method_count) && - !(meth_addr = active_method_table[i]-> - BMI_meth_method_addr_lookup(id_string))) - { - i++; - } - - /* if not found, try to bring it up now */ - failed = 0; - if (!meth_addr) { - for (i=0; i "bmi_x" */ - name = known_method_table[i]->method_name + 4; - if (!strncmp(id_string, name, strlen(name))) { - ret = activate_method(known_method_table[i]->method_name, 0, 0); - if (ret < 0) { - failed = 1; - break; - } - meth_addr = known_method_table[i]-> - BMI_meth_method_addr_lookup(id_string); - i = active_method_count - 1; /* point at the new one */ - break; - } - } - } - gen_mutex_unlock(&active_method_count_mutex); - if (failed) - return bmi_errno_to_pvfs(ret); - - /* make sure one was successful */ - if (!meth_addr) + *new_addr = bmi_addr_id_search(bmi_addrs_map, id_string); + if(*new_addr != 0) { - return bmi_errno_to_pvfs(-ENOPROTOOPT); - } - - /* create a new reference for the addr */ - new_ref = alloc_ref_st(); - if (!new_ref) - { - ret = bmi_errno_to_pvfs(-ENOMEM); - goto bmi_addr_lookup_failure; + return 0; } - /* fill in the details */ - new_ref->method_addr = meth_addr; - new_ref->id_string = (char *) malloc(strlen(id_string) + 1); - if (!new_ref->id_string) + ret = bmi_addr_add_endpoint(bmi_addrs_map, id_string, new_addr); + if(ret != 0) { - ret = bmi_errno_to_pvfs(errno); - goto bmi_addr_lookup_failure; + goto bmi_addr_lookup_failure; } - strcpy(new_ref->id_string, id_string); - new_ref->interface = active_method_table[i]; - /* keep up with the reference and we are done */ - gen_mutex_lock(&ref_mutex); - ref_list_add(cur_ref_list, new_ref); - gen_mutex_unlock(&ref_mutex); - - *new_addr = new_ref->bmi_addr; return (0); bmi_addr_lookup_failure: if (meth_addr) { - active_method_table[i]->BMI_meth_set_info( - BMI_DROP_ADDR, meth_addr); - } - - if (new_ref) - { - dealloc_ref_st(new_ref); + bmi_active_method_table[i]->set_info(BMI_DROP_ADDR, meth_addr); } return (ret); } - /** Similar to BMI_post_send(), except that the source buffer is * replaced by a list of (possibly non contiguous) buffers. * @@ -1637,8 +999,9 @@ int BMI_post_send_list(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id) { - ref_st_p tmp_ref = NULL; int ret = -1; + struct bmi_method_addr *method_addr; + struct bmi_method_ops *ops; #ifndef GOSSIP_DISABLE_DEBUG int i; @@ -1657,19 +1020,12 @@ int BMI_post_send_list(bmi_op_id_t * id, *id = 0; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, dest); - if (!tmp_ref) - { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); - } - gen_mutex_unlock(&ref_mutex); - - if (tmp_ref->interface->BMI_meth_post_send_list) + method_addr = bmi_addr_current_method_addr(dest); + ops = bmi_addr_get_method(dest); + if (ops->post_send_list) { - ret = tmp_ref->interface->BMI_meth_post_send_list( - id, tmp_ref->method_addr, buffer_list, size_list, + ret = ops->post_send_list( + id, method_addr, buffer_list, size_list, list_count, total_size, buffer_type, tag, user_ptr, context_id); @@ -1704,8 +1060,9 @@ int BMI_post_recv_list(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id) { - ref_st_p tmp_ref = NULL; int ret = -1; + struct bmi_method_addr *method_addr; + struct bmi_method_ops *ops; #ifndef GOSSIP_DISABLE_DEBUG int i; @@ -1724,19 +1081,12 @@ int BMI_post_recv_list(bmi_op_id_t * id, *id = 0; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, src); - if (!tmp_ref) + method_addr = bmi_addr_current_method_addr(src); + ops = bmi_addr_get_method(src); + if (ops->post_recv_list) { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); - } - gen_mutex_unlock(&ref_mutex); - - if (tmp_ref->interface->BMI_meth_post_recv_list) - { - ret = tmp_ref->interface->BMI_meth_post_recv_list( - id, tmp_ref->method_addr, buffer_list, size_list, + ret = ops->post_recv_list( + id, method_addr, buffer_list, size_list, list_count, total_expected_size, total_actual_size, buffer_type, tag, user_ptr, context_id); @@ -1769,8 +1119,9 @@ int BMI_post_sendunexpected_list(bmi_op_ void *user_ptr, bmi_context_id context_id) { - ref_st_p tmp_ref = NULL; int ret = -1; + struct bmi_method_addr *method_addr; + struct bmi_method_ops *ops; #ifndef GOSSIP_DISABLE_DEBUG int i; @@ -1790,19 +1141,12 @@ int BMI_post_sendunexpected_list(bmi_op_ *id = 0; - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, dest); - if (!tmp_ref) - { - gen_mutex_unlock(&ref_mutex); - return (bmi_errno_to_pvfs(-EPROTO)); - } - gen_mutex_unlock(&ref_mutex); - - if (tmp_ref->interface->BMI_meth_post_send_list) + method_addr = bmi_addr_current_method_addr(dest); + ops = bmi_addr_get_method(dest); + if (ops->post_send_list) { - ret = tmp_ref->interface->BMI_meth_post_sendunexpected_list( - id, tmp_ref->method_addr, buffer_list, size_list, + ret = ops->post_sendunexpected_list( + id, method_addr, buffer_list, size_list, list_count, total_size, buffer_type, tag, user_ptr, context_id); @@ -1842,10 +1186,9 @@ int BMI_cancel(bmi_op_id_t id, assert(target_op->op_id == id); - if(active_method_table[target_op->addr->method_type]->BMI_meth_cancel) + if(bmi_active_method_table[target_op->addr->method_type]->cancel) { - ret = active_method_table[ - target_op->addr->method_type]->BMI_meth_cancel( + ret = bmi_active_method_table[target_op->addr->method_type]->cancel( id, context_id); } else @@ -1870,40 +1213,29 @@ int BMI_cancel(bmi_op_id_t id, * of a socket accept() and get a new connection. * * Do not call this function for active lookups, that is from your - * BMI_meth_method_addr_lookup. BMI already knows about the address in + * method_addr_lookup. BMI already knows about the address in * this case, since the user provided it. * * returns 0 on success, -errno on failure */ -PVFS_BMI_addr_t bmi_method_addr_reg_callback(method_addr_p map) +PVFS_BMI_addr_t bmi_method_addr_reg_callback(bmi_method_addr_p map) { - ref_st_p new_ref = NULL; + PVFS_BMI_addr_t new_addr; + int ret; /* NOTE: we are trusting the method to make sure that we really * don't know about the address yet. No verification done here. */ - /* create a new reference structure */ - new_ref = alloc_ref_st(); - if (!new_ref) + ret = bmi_addr_add_method(bmi_addrs_map, map, &new_addr); + if(ret != 0) { - return 0; + gossip_err("%s: failed to register address in callback: %d\n", + __func__, ret); + return -1; } - /* - fill in the details; we don't have an id string for this one. - */ - new_ref->method_addr = map; - new_ref->id_string = NULL; - - /* check the method_type from the method_addr pointer to know - * which interface to use */ - new_ref->interface = active_method_table[map->method_type]; - - /* add the reference structure to the list */ - ref_list_add(cur_ref_list, new_ref); - - return new_ref->bmi_addr; + return new_addr; } int bmi_method_addr_forget_callback(PVFS_BMI_addr_t addr) @@ -1928,104 +1260,6 @@ int bmi_method_addr_forget_callback(PVFS return (0); } -/* - * Attempt to insert this name into the list of active methods, - * and bring it up. - * NOTE: assumes caller has protected active_method_count with a mutex lock - */ -static int -activate_method(const char *name, const char *listen_addr, int flags) -{ - int i, ret; - void *x; - struct bmi_method_ops *meth; - method_addr_p new_addr; - - /* already active? */ - for (i=0; imethod_name, name)) break; - if (i < active_method_count) - { - return 0; - } - - /* is the method known? */ - for (i=0; imethod_name, name)) break; - if (i == known_method_count) { - gossip_lerr("Error: no method available for %s.\n", name); - return -ENOPROTOOPT; - } - meth = known_method_table[i]; - - /* - * Later: try to load a dynamic module, growing the known method - * table and search it again. - */ - - /* toss it into the active table */ - x = active_method_table; - active_method_table = malloc( - (active_method_count + 1) * sizeof(*active_method_table)); - if (!active_method_table) { - active_method_table = x; - return -ENOMEM; - } - if (active_method_count) { - memcpy(active_method_table, x, - active_method_count * sizeof(*active_method_table)); - free(x); - } - active_method_table[active_method_count] = meth; - - x = method_usage; - method_usage = malloc((active_method_count + 1) * sizeof(*method_usage)); - if (!method_usage) { - method_usage = x; - return -ENOMEM; - } - if (active_method_count) { - memcpy(method_usage, x, active_method_count * sizeof(*method_usage)); - free(x); - } - memset(&method_usage[active_method_count], 0, sizeof(*method_usage)); - - ++active_method_count; - - /* initialize it */ - new_addr = 0; - if (listen_addr) { - new_addr = meth->BMI_meth_method_addr_lookup(listen_addr); - if (!new_addr) { - gossip_err( - "Error: failed to lookup listen address %s for method %s.\n", - listen_addr, name); - --active_method_count; - return -EINVAL; - } - /* this is a bit of a hack */ - new_addr->method_type = active_method_count - 1; - } - ret = meth->BMI_meth_initialize(new_addr, active_method_count - 1, flags); - if (ret < 0) { - gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, - "failed to initialize method %s.\n", name); - --active_method_count; - return ret; - } - - /* tell it about any open contexts */ - for (i=0; iBMI_meth_open_context(i); - if (ret < 0) - break; - } - - return ret; -} - - int bmi_errno_to_pvfs(int error) { int bmi_errno = error; @@ -2103,13 +1337,12 @@ static void bmi_check_forget_list(void) { PVFS_BMI_addr_t tmp_addr; struct forget_item* tmp_item; - ref_st_p tmp_ref = NULL; - + gen_mutex_lock(&forget_list_mutex); while(!qlist_empty(&forget_list)) { tmp_item = qlist_entry(forget_list.next, struct forget_item, - link); + link); qlist_del(&tmp_item->link); /* item is off of the list; unlock for a moment while we work on * this addr @@ -2118,53 +1351,15 @@ static void bmi_check_forget_list(void) tmp_addr = tmp_item->addr; free(tmp_item); - gen_mutex_lock(&ref_mutex); - tmp_ref = ref_list_search_addr(cur_ref_list, tmp_addr); - if(tmp_ref && tmp_ref->ref_count == 0) - { - bmi_addr_drop(tmp_ref); - } - gen_mutex_unlock(&ref_mutex); - + /* we ignore an EINVAL from addr_drop at this point, a non-zero + * ref count just means that there are still references to + * this address. + */ + bmi_addr_drop_endpoint(bmi_addrs_map, tmp_addr, 0); gen_mutex_lock(&forget_list_mutex); } gen_mutex_unlock(&forget_list_mutex); - return; -} - -/* bmi_addr_drop - * - * Destroys a complete BMI address, including asking the method to clean up - * its portion. Will query the method for permission before proceeding - * - * NOTE: must be called with ref list mutex held - */ -static void bmi_addr_drop(ref_st_p tmp_ref) -{ - struct method_drop_addr_query query; - query.response = 0; - query.addr = tmp_ref->method_addr; - int ret = 0; - - /* reference count is zero; ask module if it wants us to discard - * the address; TCP will tell us to drop addresses for which the - * socket has died with no possibility of reconnect - */ - ret = tmp_ref->interface->BMI_meth_get_info(BMI_DROP_ADDR_QUERY, - &query); - if(ret == 0 && query.response == 1) - { - /* kill the address */ - gossip_debug(GOSSIP_BMI_DEBUG_CONTROL, - "[BMI CONTROL]: %s: bmi discarding address: %llu\n", - __func__, llu(tmp_ref->bmi_addr)); - ref_list_rem(cur_ref_list, tmp_ref->bmi_addr); - /* NOTE: this triggers request to module to free underlying - * resources if it wants to - */ - dealloc_ref_st(tmp_ref); - } return; } Index: src/io/bmi/bmi.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi.h,v retrieving revision 1.30 diff -u -a -p -r1.30 bmi.h --- src/io/bmi/bmi.h 20 Sep 2006 04:36:12 -0000 1.30 +++ src/io/bmi/bmi.h 6 Nov 2007 16:08:00 -0000 @@ -123,7 +123,9 @@ int BMI_get_info(PVFS_BMI_addr_t addr, void *inout_parameter); int BMI_addr_lookup(PVFS_BMI_addr_t * new_addr, - const char *id_string); + const char *id_string); + +int BMI_endpoint_fail_current_addr(PVFS_BMI_addr_t addr); const char* BMI_addr_rev_lookup(PVFS_BMI_addr_t addr); Index: src/io/bmi/module.mk.in =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/module.mk.in,v retrieving revision 1.2 diff -u -a -p -r1.2 module.mk.in --- src/io/bmi/module.mk.in 24 Jan 2003 21:52:49 -0000 1.2 +++ src/io/bmi/module.mk.in 6 Nov 2007 16:08:00 -0000 @@ -3,9 +3,9 @@ LIBSRC += \ $(DIR)/bmi.c \ $(DIR)/bmi-method-support.c \ $(DIR)/op-list.c \ - $(DIR)/reference-list.c + $(DIR)/bmi-addr.c SERVERSRC += \ $(DIR)/bmi.c \ $(DIR)/bmi-method-support.c \ $(DIR)/op-list.c \ - $(DIR)/reference-list.c + $(DIR)/bmi-addr.c Index: src/io/bmi/op-list.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/op-list.c,v retrieving revision 1.8 diff -u -a -p -r1.8 op-list.c --- src/io/bmi/op-list.c 28 Jul 2004 14:32:39 -0000 1.8 +++ src/io/bmi/op-list.c 6 Nov 2007 16:08:00 -0000 @@ -130,7 +130,7 @@ void op_list_cleanup(op_list_p olp) { tmp_method_op = qlist_entry(iterator, struct method_op, op_list_entry); - dealloc_method_op(tmp_method_op); + bmi_dealloc_method_op(tmp_method_op); } free(olp); olp = NULL; Index: src/io/bmi/op-list.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/op-list.h,v retrieving revision 1.6 diff -u -a -p -r1.6 op-list.h --- src/io/bmi/op-list.h 28 Jul 2004 14:32:39 -0000 1.6 +++ src/io/bmi/op-list.h 6 Nov 2007 16:08:00 -0000 @@ -26,7 +26,7 @@ typedef struct qlist_head *op_list_p; */ struct op_list_search_key { - method_addr_p method_addr; + bmi_method_addr_p method_addr; int method_addr_yes; bmi_msg_tag_t msg_tag; int msg_tag_yes; Index: src/io/bmi/reference-list.c =================================================================== RCS file: src/io/bmi/reference-list.c diff -N src/io/bmi/reference-list.c --- src/io/bmi/reference-list.c 20 Aug 2007 01:39:57 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,250 +0,0 @@ -/* - * (C) 2001 Clemson University and The University of Chicago - * - * See COPYING in top-level directory. - */ - - -/* - * reference_list.c - functions to handle the creation and modification of - * reference structures for the BMI layer - * - */ - -#include -#include -#include - -#include "reference-list.h" -#include "gossip.h" -#include "id-generator.h" - - -/*************************************************************** - * Visible functions - */ - -/* - * ref_list_new() - * - * creates a new reference list. - * - * returns pointer to an empty list or NULL on failure. - */ -ref_list_p ref_list_new(void) -{ - - ref_list_p tmp_list = NULL; - - tmp_list = (ref_list_p) malloc(sizeof(struct qlist_head)); - if (tmp_list) - { - INIT_QLIST_HEAD(tmp_list); - } - return (tmp_list); -} - -/* - * ref_list_add() - * - * adds a reference to the list. - * - * no return value - */ -void ref_list_add(ref_list_p rlp, - ref_st_p rsp) -{ - qlist_add(&(rsp->list_link), rlp); -} - -/* - * ref_list_search_addr() - * - * looks for a reference structure in the list that matches the given - * PVFS_BMI_addr_t. - * - * returns a pointer to the structure on success, a NULL on failure. - */ -ref_st_p ref_list_search_addr(ref_list_p rlp, - PVFS_BMI_addr_t my_addr) -{ - ref_list_p tmp_link = NULL; - ref_st_p tmp_entry = NULL; - - qlist_for_each(tmp_link, rlp) - { - tmp_entry = qlist_entry(tmp_link, struct ref_st, - list_link); - if (tmp_entry->bmi_addr == my_addr) - return (tmp_entry); - } - return (NULL); -} - - -/* - * ref_list_search_method_addr() - * - * looks for a reference structure in the list that matches the given - * method_addr_p. - * - * returns a pointer to the structure on success, NULL on failure. - */ -ref_st_p ref_list_search_method_addr(ref_list_p rlp, - method_addr_p map) -{ - ref_list_p tmp_link = NULL; - ref_st_p tmp_entry = NULL; - - qlist_for_each(tmp_link, rlp) - { - tmp_entry = qlist_entry(tmp_link, struct ref_st, list_link); - if (tmp_entry->method_addr == map) - return (tmp_entry); - } - return (NULL); -} - -/* - * ref_list_search_str() - * - * looks for a reference structure in the list that matches the given - * id string. - * - * returns a pointer to the structure on success, a NULL on failure. - */ -ref_st_p ref_list_search_str(ref_list_p rlp, - const char *idstring) -{ - ref_list_p tmp_link = NULL; - ref_st_p tmp_entry = NULL; - - qlist_for_each(tmp_link, rlp) - { - tmp_entry = qlist_entry(tmp_link, struct ref_st, - list_link); - if (tmp_entry->id_string && !strcmp(tmp_entry->id_string, idstring)) - return (tmp_entry); - } - return (NULL); -} - -/* - * ref_list_rem() - * - * removes the first match from the list - does not destroy it - * - * returns a pointer to the structure on success, a NULL on failure. - */ -ref_st_p ref_list_rem(ref_list_p rlp, - PVFS_BMI_addr_t my_addr) -{ - ref_list_p tmp_link = NULL; - ref_list_p scratch = NULL; - ref_st_p tmp_entry = NULL; - - qlist_for_each_safe(tmp_link, scratch, rlp) - { - tmp_entry = qlist_entry(tmp_link, struct ref_st, list_link); - if (tmp_entry->bmi_addr == my_addr) - { - qlist_del(&tmp_entry->list_link); - return (tmp_entry); - } - } - return (NULL); -} - - - -/* - * ref_list_cleanup() - * - * frees up the list and all data associated with it. - * - * no return values - */ -void ref_list_cleanup(ref_list_p rlp) -{ - ref_list_p tmp_link = NULL; - ref_list_p scratch = NULL; - ref_st_p tmp_entry = NULL; - - qlist_for_each_safe(tmp_link, scratch, rlp) - { - tmp_entry = qlist_entry(tmp_link, struct ref_st, - list_link); - dealloc_ref_st(tmp_entry); - } - - free(rlp); - return; -} - -/* - * alloc_ref_st() - * - * allocates storage for a reference struct. - * - * returns a pointer to the new structure on success, NULL on failure. - */ -ref_st_p alloc_ref_st(void) -{ - - int ssize = sizeof(struct ref_st); - ref_st_p new_ref = NULL; - - new_ref = (ref_st_p) malloc(ssize); - if (!new_ref) - { - return (NULL); - } - - memset(new_ref, 0, ssize); - - /* we can go ahead and set the bmi_addr here */ - id_gen_fast_register(&(new_ref->bmi_addr), new_ref); - - return (new_ref); -} - -/* - * dealloc_ref_st() - * - * frees all memory associated with a reference structure - * NOTE: it *does not*, however, destroy the associated method address. - * - * returns 0 on success, -1 on failure - */ -void dealloc_ref_st(ref_st_p deadref) -{ - - if (!deadref) - { - return; - } - - if (deadref->id_string) - { - free(deadref->id_string); - } - - if (deadref->method_addr) - { - deadref->interface->BMI_meth_set_info(BMI_DROP_ADDR, - deadref->method_addr); - } - - id_gen_fast_unregister(deadref->bmi_addr); - - free(deadref); -} - -/* - * Local variables: - * c-indent-level: 4 - * c-basic-offset: 4 - * End: - * - * vim: ts=8 sts=4 sw=4 expandtab - */ Index: src/io/bmi/reference-list.h =================================================================== RCS file: src/io/bmi/reference-list.h diff -N src/io/bmi/reference-list.h --- src/io/bmi/reference-list.h 28 Jul 2004 14:32:39 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,73 +0,0 @@ -/* - * (C) 2001 Clemson University and The University of Chicago - * - * See COPYING in top-level directory. - */ - - -/* - * Header file for reference list management functions. Reference structures - * are used to maintain the mapping between PVFS_BMI_addr_t and - * method_addr_p addresses. - */ - -#ifndef __REFERENCE_LIST_H -#define __REFERENCE_LIST_H - -#include "bmi-types.h" -#include "bmi-method-support.h" -#include "quicklist.h" - -typedef struct qlist_head *ref_list_p; - -/**********************************************************************/ -/* this is the basic reference structure for the glue layer above the - * actual methods. It keeps up with the bmi_addr, id string, method - * address, and pointers to each of the appropriate method functions. - */ -struct ref_st -{ - PVFS_BMI_addr_t bmi_addr; /* the identifier passed out of the BMI layer */ - char *id_string; /* the id string that represents this reference */ - method_addr_p method_addr; /* address structure used by the method */ - - /* pointer to the appropriate method interface */ - struct bmi_method_ops *interface; - - /* linked list entry */ - struct qlist_head list_link; - int ref_count; -}; - -typedef struct ref_st ref_st, *ref_st_p; - -/******************************************************************** - * reference list management prototypes - */ - -ref_list_p ref_list_new(void); -void ref_list_add(ref_list_p rlp, - ref_st_p rsp); -ref_st_p ref_list_search_addr(ref_list_p rlp, - PVFS_BMI_addr_t my_addr); -ref_st_p ref_list_rem(ref_list_p rlp, - PVFS_BMI_addr_t my_addr); -ref_st_p ref_list_search_method_addr(ref_list_p rlp, - method_addr_p map); -ref_st_p ref_list_search_str(ref_list_p rlp, - const char *idstring); -void ref_list_cleanup(ref_list_p rlp); -ref_st_p alloc_ref_st(void); -void dealloc_ref_st(ref_st_p deadref); - - -#endif /* __REFERENCE_LIST_H */ - -/* - * Local variables: - * c-indent-level: 4 - * c-basic-offset: 4 - * End: - * - * vim: ts=8 sts=4 sw=4 expandtab - */ Index: src/io/bmi/bmi_gm/bmi-gm-addr-list.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_gm/bmi-gm-addr-list.c,v retrieving revision 1.5 diff -u -a -p -r1.5 bmi-gm-addr-list.c --- src/io/bmi/bmi_gm/bmi-gm-addr-list.c 28 Sep 2004 14:03:57 -0000 1.5 +++ src/io/bmi/bmi_gm/bmi-gm-addr-list.c 6 Nov 2007 16:08:00 -0000 @@ -21,7 +21,7 @@ * no return value */ void gm_addr_add(struct qlist_head *head, - method_addr_p map) + bmi_method_addr_p map) { struct gm_addr *gm_addr_data = NULL; gm_addr_data = map->method_data; @@ -35,7 +35,7 @@ void gm_addr_add(struct qlist_head *head * * no return value */ -void gm_addr_del(method_addr_p map) +void gm_addr_del(bmi_method_addr_p map) { struct gm_addr *gm_addr_data = NULL; gm_addr_data = map->method_data; @@ -50,9 +50,9 @@ void gm_addr_del(method_addr_p map) * * returns pointer to method address on success, NULL on failure */ -method_addr_p gm_addr_search(struct qlist_head * head, - unsigned int node_id, - unsigned int port_id) +bmi_method_addr_p gm_addr_search(struct qlist_head * head, + unsigned int node_id, + unsigned int port_id) { struct qlist_head *tmp_entry = NULL; struct gm_addr *gm_addr_data = NULL; @@ -63,14 +63,14 @@ method_addr_p gm_addr_search(struct qlis gm_addr_list); if (gm_addr_data->node_id == node_id && gm_addr_data->port_id == port_id) - { - /* pointer magic :) we know that the method addr structure and - * gm_addr structure are adjacent and contiguous. - */ - return ((method_addr_p) ((unsigned long) gm_addr_data - - (unsigned long) sizeof(struct - method_addr))); - } + { + /* pointer magic :) we know that the method addr structure and + * gm_addr structure are adjacent and contiguous. + */ + return ((bmi_method_addr_p) ((unsigned long) gm_addr_data - + (unsigned long) sizeof(struct + method_addr))); + } } return (NULL); } Index: src/io/bmi/bmi_gm/bmi-gm-addr-list.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_gm/bmi-gm-addr-list.h,v retrieving revision 1.6 diff -u -a -p -r1.6 bmi-gm-addr-list.h --- src/io/bmi/bmi_gm/bmi-gm-addr-list.h 28 Sep 2004 14:03:57 -0000 1.6 +++ src/io/bmi/bmi_gm/bmi-gm-addr-list.h 6 Nov 2007 16:08:00 -0000 @@ -15,9 +15,9 @@ #define bmi_gm_errno_to_pvfs bmi_errno_to_pvfs void gm_addr_add(struct qlist_head *head, - method_addr_p map); -void gm_addr_del(method_addr_p map); -method_addr_p gm_addr_search(struct qlist_head *head, + bmi_method_addr_p map); +void gm_addr_del(bmi_method_addr_p map); +bmi_method_addr_p gm_addr_search(struct qlist_head *head, unsigned int node_id, unsigned int port_id); Index: src/io/bmi/bmi_gm/bmi-gm.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_gm/bmi-gm.c,v retrieving revision 1.87 diff -u -a -p -r1.87 bmi-gm.c --- src/io/bmi/bmi_gm/bmi-gm.c 9 Oct 2007 21:58:30 -0000 1.87 +++ src/io/bmi/bmi_gm/bmi-gm.c 6 Nov 2007 16:08:00 -0000 @@ -41,7 +41,7 @@ static unsigned int bmi_gm_reserved_port #define PINT_CANCELLED_REND_RECLAIM_TIMEOUT (60*15) /* function prototypes */ -int BMI_gm_initialize(method_addr_p listen_addr, +int BMI_gm_initialize(bmi_method_addr_p listen_addr, int method_id, int init_flags); int BMI_gm_finalize(void); @@ -56,7 +56,7 @@ int BMI_gm_memfree(void *buffer, enum bmi_op_type send_recv); int BMI_gm_unexpected_free(void *buffer); int BMI_gm_post_send(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -64,7 +64,7 @@ int BMI_gm_post_send(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id); int BMI_gm_post_send_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -74,7 +74,7 @@ int BMI_gm_post_send_list(bmi_op_id_t * void *user_ptr, bmi_context_id context_id); int BMI_gm_post_sendunexpected_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -84,7 +84,7 @@ int BMI_gm_post_sendunexpected_list(bmi_ void *user_ptr, bmi_context_id context_id); int BMI_gm_post_sendunexpected(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -92,7 +92,7 @@ int BMI_gm_post_sendunexpected(bmi_op_id void *user_ptr, bmi_context_id context_id); int BMI_gm_post_recv(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *buffer, bmi_size_t expected_size, bmi_size_t * actual_size, @@ -101,7 +101,7 @@ int BMI_gm_post_recv(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id); int BMI_gm_post_recv_list(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -137,9 +137,9 @@ int BMI_gm_testcontext(int incount, bmi_context_id context_id); int BMI_gm_testunexpected(int incount, int *outcount, - struct method_unexpected_info *info, + struct bmi_method_unexpected_info *info, int max_idle_time_ms); -method_addr_p BMI_gm_method_addr_lookup(const char *id_string); +bmi_method_addr_p BMI_gm_method_addr_lookup(const char *id_string); int BMI_gm_open_context(bmi_context_id context_id); void BMI_gm_close_context(bmi_context_id context_id); int BMI_gm_cancel(bmi_op_id_t id, bmi_context_id context_id); @@ -150,29 +150,29 @@ char BMI_gm_method_name[] = "bmi_gm"; /* exported method interface */ struct bmi_method_ops bmi_gm_ops = { .method_name = BMI_gm_method_name, - .BMI_meth_initialize = BMI_gm_initialize, - .BMI_meth_finalize = BMI_gm_finalize, - .BMI_meth_set_info = BMI_gm_set_info, - .BMI_meth_get_info = BMI_gm_get_info, - .BMI_meth_memalloc = BMI_gm_memalloc, - .BMI_meth_memfree = BMI_gm_memfree, - .BMI_meth_unexpected_free = BMI_gm_unexpected_free, - .BMI_meth_post_send = BMI_gm_post_send, - .BMI_meth_post_sendunexpected = BMI_gm_post_sendunexpected, - .BMI_meth_post_recv = BMI_gm_post_recv, - .BMI_meth_test = BMI_gm_test, - .BMI_meth_testsome = BMI_gm_testsome, - .BMI_meth_testcontext = BMI_gm_testcontext, - .BMI_meth_testunexpected = BMI_gm_testunexpected, - .BMI_meth_method_addr_lookup = BMI_gm_method_addr_lookup, - .BMI_meth_post_send_list = BMI_gm_post_send_list, - .BMI_meth_post_recv_list = BMI_gm_post_recv_list, - .BMI_meth_post_sendunexpected_list = BMI_gm_post_sendunexpected_list, - .BMI_meth_open_context = BMI_gm_open_context, - .BMI_meth_close_context = BMI_gm_close_context, - .BMI_meth_cancel = BMI_gm_cancel, - .BMI_meth_rev_lookup_unexpected = NULL, - .BMI_meth_query_addr_range = NULL, + .initialize = BMI_gm_initialize, + .finalize = BMI_gm_finalize, + .set_info = BMI_gm_set_info, + .get_info = BMI_gm_get_info, + .memalloc = BMI_gm_memalloc, + .memfree = BMI_gm_memfree, + .unexpected_free = BMI_gm_unexpected_free, + .post_send = BMI_gm_post_send, + .post_sendunexpected = BMI_gm_post_sendunexpected, + .post_recv = BMI_gm_post_recv, + .test = BMI_gm_test, + .testsome = BMI_gm_testsome, + .testcontext = BMI_gm_testcontext, + .testunexpected = BMI_gm_testunexpected, + .method_addr_lookup = BMI_gm_method_addr_lookup, + .post_send_list = BMI_gm_post_send_list, + .post_recv_list = BMI_gm_post_recv_list, + .post_sendunexpected_list = BMI_gm_post_sendunexpected_list, + .open_context = BMI_gm_open_context, + .close_context = BMI_gm_close_context, + .cancel = BMI_gm_cancel, + .rev_lookup_unexpected = NULL, + .query_addr_range = NULL, }; /* module parameters */ @@ -180,7 +180,7 @@ static struct { int method_flags; int method_id; - method_addr_p listen_addr; + bmi_method_addr_p listen_addr; } gm_method_params; /* op_list_array indices */ @@ -332,11 +332,11 @@ static struct bufferpool *io_pool = NULL #endif /* ENABLE_GM_BUFPOOL */ /* internal utility functions */ -static method_addr_p alloc_gm_method_addr(void); -static void dealloc_gm_method_addr(method_addr_p map); +static bmi_method_addr_p alloc_gm_method_addr(void); +static void dealloc_gm_method_addr(bmi_method_addr_p map); static int gm_post_send_check_resource(struct method_op* mop); static int gm_post_send_build_op(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, bmi_msg_tag_t tag, @@ -344,7 +344,7 @@ static int gm_post_send_build_op(bmi_op_ int buffer_status, void *user_ptr, bmi_context_id context_id); static int gm_post_send_build_op_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -376,11 +376,11 @@ static int ctrl_req_handler_rend(bmi_op_ unsigned int port_id); static int immed_unexp_recv_handler(bmi_size_t size, bmi_msg_tag_t msg_tag, - method_addr_p map, + bmi_method_addr_p map, void *buffer); static int immed_recv_handler(bmi_size_t actual_size, bmi_msg_tag_t msg_tag, - method_addr_p map, + bmi_method_addr_p map, void *buffer); static void put_recv_handler(bmi_op_id_t ctrl_op_id); static void ctrl_ack_callback(struct gm_port *port, @@ -417,7 +417,7 @@ static int io_buffers_exhausted(void); * * returns 0 on success, -errno on failure */ -int BMI_gm_initialize(method_addr_p listen_addr, +int BMI_gm_initialize(bmi_method_addr_p listen_addr, int method_id, int init_flags) { @@ -656,10 +656,10 @@ int BMI_gm_finalize(void) * * returns a pointer to method_addr on success, NULL on failure */ -method_addr_p BMI_gm_method_addr_lookup(const char *id_string) +bmi_method_addr_p BMI_gm_method_addr_lookup(const char *id_string) { char *gm_string = NULL; - method_addr_p new_addr = NULL; + bmi_method_addr_p new_addr = NULL; struct gm_addr *gm_data = NULL; char local_tag[] = "NULL"; char* delim = NULL; @@ -899,7 +899,7 @@ int BMI_gm_get_info(int option, * completion, -errno on failure */ int BMI_gm_post_send(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -990,7 +990,7 @@ int BMI_gm_post_send(bmi_op_id_t * id, * -errno on failure */ int BMI_gm_post_send_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -1093,7 +1093,7 @@ int BMI_gm_post_send_list(bmi_op_id_t * * -errno on failure */ int BMI_gm_post_sendunexpected_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -1184,7 +1184,7 @@ int BMI_gm_post_sendunexpected_list(bmi_ * completion, -errno on failure */ int BMI_gm_post_sendunexpected(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -1256,7 +1256,7 @@ int BMI_gm_post_sendunexpected(bmi_op_id * completion, -errno on failure */ int BMI_gm_post_recv(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *buffer, bmi_size_t expected_size, bmi_size_t * actual_size, @@ -1426,7 +1426,7 @@ int BMI_gm_post_recv(bmi_op_id_t * id, * returns 0 on success, -errno on failure */ int BMI_gm_post_recv_list(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -1930,7 +1930,7 @@ int BMI_gm_testcontext(int incount, */ int BMI_gm_testunexpected(int incount, int *outcount, - struct method_unexpected_info *info, + struct bmi_method_unexpected_info *info, int max_idle_time_ms) { int ret = -1; @@ -2034,7 +2034,7 @@ void BMI_gm_close_context(bmi_context_id * * no return value */ -static void dealloc_gm_method_addr(method_addr_p map) +static void dealloc_gm_method_addr(bmi_method_addr_p map) { dealloc_method_addr(map); @@ -2050,7 +2050,7 @@ static void dealloc_gm_method_addr(metho * * returns pointer to struct on success, NULL on failure */ -static method_addr_p alloc_gm_method_addr(void) +static bmi_method_addr_p alloc_gm_method_addr(void) { struct method_addr *my_method_addr = NULL; @@ -2063,6 +2063,7 @@ static method_addr_p alloc_gm_method_add return (NULL); } + my_method_addr->ops = &bmi_gm_ops; /* note that we trust the alloc_method_addr() function to have zeroed * out the structures for us already */ @@ -2115,7 +2116,7 @@ void dealloc_gm_method_op(method_op_p op * returns 0 on success, -errno on failure */ static int gm_post_send_build_op_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -2168,7 +2169,7 @@ static int gm_post_send_build_op_list(bm * returns 0 on success, -errno on failure */ static int gm_post_send_build_op(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, bmi_msg_tag_t tag, @@ -2889,7 +2890,7 @@ void alarm_callback(void *context) */ static int immed_unexp_recv_handler(bmi_size_t size, bmi_msg_tag_t msg_tag, - method_addr_p map, + bmi_method_addr_p map, void *buffer) { method_op_p new_method_op = NULL; @@ -2926,7 +2927,7 @@ static int immed_unexp_recv_handler(bmi_ */ static int immed_recv_handler(bmi_size_t actual_size, bmi_msg_tag_t msg_tag, - method_addr_p map, + bmi_method_addr_p map, void *buffer) { method_op_p new_method_op = NULL; @@ -2965,7 +2966,7 @@ static int recv_event_handler(gm_recv_ev { struct ctrl_msg ctrl_copy; int ret = bmi_gm_errno_to_pvfs(-ENOSYS); - method_addr_p map = NULL; + bmi_method_addr_p map = NULL; struct op_list_search_key key; void *tmp_buffer = NULL; method_op_p query_op = NULL; @@ -3836,7 +3837,7 @@ static int ctrl_req_handler_rend(bmi_op_ unsigned int node_id, unsigned int port_id) { - method_addr_p map = NULL; + bmi_method_addr_p map = NULL; struct gm_addr *gm_addr_data = NULL; struct gm_op *gm_op_data = NULL; method_op_p active_method_op = NULL; Index: src/io/bmi/bmi_ib/ib.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_ib/ib.c,v retrieving revision 1.57 diff -u -a -p -r1.57 ib.c --- src/io/bmi/bmi_ib/ib.c 9 Oct 2007 21:58:30 -0000 1.57 +++ src/io/bmi/bmi_ib/ib.c 6 Nov 2007 16:08:00 -0000 @@ -1364,7 +1364,7 @@ restart: */ static int BMI_ib_testunexpected(int incount __unused, int *outcount, - struct method_unexpected_info *ui, int max_idle_time) + struct bmi_method_unexpected_info *ui, int max_idle_time) { struct qlist_head *l; int activity = 0, n; @@ -1607,8 +1607,11 @@ static struct method_addr *BMI_ib_method if (map) free(hostname); /* found it */ else + { map = ib_alloc_method_addr(0, hostname, port); /* alloc new one */ + map->ops = &bmi_ib_ops; /* but don't call bmi_method_addr_reg_callback! */ + } return map; } @@ -2095,28 +2098,28 @@ static int BMI_ib_finalize(void) const struct bmi_method_ops bmi_ib_ops = { .method_name = "bmi_ib", - .BMI_meth_initialize = BMI_ib_initialize, - .BMI_meth_finalize = BMI_ib_finalize, - .BMI_meth_set_info = BMI_ib_set_info, - .BMI_meth_get_info = BMI_ib_get_info, - .BMI_meth_memalloc = BMI_ib_memalloc, - .BMI_meth_memfree = BMI_ib_memfree, - .BMI_meth_unexpected_free = BMI_ib_unexpected_free, - .BMI_meth_post_send = BMI_ib_post_send, - .BMI_meth_post_sendunexpected = BMI_ib_post_sendunexpected, - .BMI_meth_post_recv = BMI_ib_post_recv, - .BMI_meth_test = BMI_ib_test, - .BMI_meth_testsome = BMI_ib_testsome, - .BMI_meth_testcontext = BMI_ib_testcontext, - .BMI_meth_testunexpected = BMI_ib_testunexpected, - .BMI_meth_method_addr_lookup = BMI_ib_method_addr_lookup, - .BMI_meth_post_send_list = BMI_ib_post_send_list, - .BMI_meth_post_recv_list = BMI_ib_post_recv_list, - .BMI_meth_post_sendunexpected_list = BMI_ib_post_sendunexpected_list, - .BMI_meth_open_context = BMI_ib_open_context, - .BMI_meth_close_context = BMI_ib_close_context, - .BMI_meth_cancel = BMI_ib_cancel, - .BMI_meth_rev_lookup_unexpected = BMI_ib_rev_lookup, - .BMI_meth_query_addr_range = NULL, + .initialize = BMI_ib_initialize, + .finalize = BMI_ib_finalize, + .set_info = BMI_ib_set_info, + .get_info = BMI_ib_get_info, + .memalloc = BMI_ib_memalloc, + .memfree = BMI_ib_memfree, + .unexpected_free = BMI_ib_unexpected_free, + .post_send = BMI_ib_post_send, + .post_sendunexpected = BMI_ib_post_sendunexpected, + .post_recv = BMI_ib_post_recv, + .test = BMI_ib_test, + .testsome = BMI_ib_testsome, + .testcontext = BMI_ib_testcontext, + .testunexpected = BMI_ib_testunexpected, + .method_addr_lookup = BMI_ib_method_addr_lookup, + .post_send_list = BMI_ib_post_send_list, + .post_recv_list = BMI_ib_post_recv_list, + .post_sendunexpected_list = BMI_ib_post_sendunexpected_list, + .open_context = BMI_ib_open_context, + .close_context = BMI_ib_close_context, + .cancel = BMI_ib_cancel, + .rev_lookup_unexpected = BMI_ib_rev_lookup, + .query_addr_range = NULL, }; Index: src/io/bmi/bmi_mx/mx.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_mx/mx.c,v retrieving revision 1.8 diff -u -a -p -r1.8 mx.c --- src/io/bmi/bmi_mx/mx.c 4 Oct 2007 12:45:24 -0000 1.8 +++ src/io/bmi/bmi_mx/mx.c 6 Nov 2007 16:08:00 -0000 @@ -834,7 +834,7 @@ bmx_open_endpoint(mx_endpoint_t *ep, uin /* The listen_addr is our method if we are a server. It is NULL for a * client. The other params are NULL/0 for the client as well. */ static int -BMI_mx_initialize(method_addr_p listen_addr, int method_id, int init_flags) +BMI_mx_initialize(bmi_method_addr_p listen_addr, int method_id, int init_flags) { int i = 0; int ret = 0; @@ -1988,12 +1988,15 @@ bmx_alloc_method_addr(const char *peerna struct bmx_method_addr *mxmap = NULL; if (bmi_mx == NULL) { - map = alloc_method_addr(tmp_id, (bmi_size_t) sizeof(*mxmap)); + map = bmi_alloc_method_addr( + tmp_id, &bmi_mx_ops, (bmi_size_t) sizeof(*mxmap)); } else { - map = alloc_method_addr(bmi_mx->bmx_method_id, (bmi_size_t) sizeof(*mxmap)); + map = bmi_alloc_method_addr(bmi_mx->bmx_method_id, (bmi_size_t) sizeof(*mxmap)); } if (map == NULL) return NULL; + map->ops = &bmi_mx_ops; + mxmap = map->method_data; mxmap->mxm_map = map; mxmap->mxm_peername = strdup(peername); @@ -2586,7 +2589,7 @@ BMI_mx_testcontext(int incount, bmi_op_i static int BMI_mx_testunexpected(int incount __unused, int *outcount, - struct method_unexpected_info *ui, int max_idle_time __unused) + struct bmi_method_unexpected_info *ui, int max_idle_time __unused) { uint32_t result = 0; uint64_t match = (uint64_t) BMX_MSG_UNEXPECTED << 60; @@ -2858,27 +2861,27 @@ BMI_mx_rev_lookup(struct method_addr *me struct bmi_method_ops bmi_mx_ops = { - .method_name = "bmi_mx", - .BMI_meth_initialize = BMI_mx_initialize, - .BMI_meth_finalize = BMI_mx_finalize, - .BMI_meth_set_info = BMI_mx_set_info, - .BMI_meth_get_info = BMI_mx_get_info, - .BMI_meth_memalloc = BMI_mx_memalloc, - .BMI_meth_memfree = BMI_mx_memfree, - .BMI_meth_unexpected_free = BMI_mx_unexpected_free, - .BMI_meth_post_send = BMI_mx_post_send, - .BMI_meth_post_sendunexpected = BMI_mx_post_sendunexpected, - .BMI_meth_post_recv = BMI_mx_post_recv, - .BMI_meth_test = BMI_mx_test, - .BMI_meth_testsome = 0, - .BMI_meth_testcontext = BMI_mx_testcontext, - .BMI_meth_testunexpected = BMI_mx_testunexpected, - .BMI_meth_method_addr_lookup = BMI_mx_method_addr_lookup, - .BMI_meth_post_send_list = BMI_mx_post_send_list, - .BMI_meth_post_recv_list = BMI_mx_post_recv_list, - .BMI_meth_post_sendunexpected_list = BMI_mx_post_sendunexpected_list, - .BMI_meth_open_context = BMI_mx_open_context, - .BMI_meth_close_context = BMI_mx_close_context, - .BMI_meth_cancel = BMI_mx_cancel, - .BMI_meth_rev_lookup_unexpected = BMI_mx_rev_lookup, + .method_name = "bmi_mx", + .initialize = BMI_mx_initialize, + .finalize = BMI_mx_finalize, + .set_info = BMI_mx_set_info, + .get_info = BMI_mx_get_info, + .memalloc = BMI_mx_memalloc, + .memfree = BMI_mx_memfree, + .unexpected_free = BMI_mx_unexpected_free, + .post_send = BMI_mx_post_send, + .post_sendunexpected = BMI_mx_post_sendunexpected, + .post_recv = BMI_mx_post_recv, + .test = BMI_mx_test, + .testsome = 0, + .testcontext = BMI_mx_testcontext, + .testunexpected = BMI_mx_testunexpected, + .method_addr_lookup = BMI_mx_method_addr_lookup, + .post_send_list = BMI_mx_post_send_list, + .post_recv_list = BMI_mx_post_recv_list, + .post_sendunexpected_list = BMI_mx_post_sendunexpected_list, + .open_context = BMI_mx_open_context, + .close_context = BMI_mx_close_context, + .cancel = BMI_mx_cancel, + .rev_lookup_unexpected = BMI_mx_rev_lookup, }; Index: src/io/bmi/bmi_portals/portals.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_portals/portals.c,v retrieving revision 1.4 diff -u -a -p -r1.4 portals.c --- src/io/bmi/bmi_portals/portals.c 18 Oct 2007 15:56:45 -0000 1.4 +++ src/io/bmi/bmi_portals/portals.c 6 Nov 2007 16:08:00 -0000 @@ -703,7 +703,7 @@ static int bmip_testsome(int num __unuse * to the idle time. */ static int bmip_testunexpected(int incount, int *outcount, - struct method_unexpected_info *ui, + struct bmi_method_unexpected_info *ui, int max_idle_time) { struct bmip_work *w, *wn; @@ -1427,6 +1427,7 @@ static struct method_addr *bmip_alloc_me extra = sizeof(*pma) + 2 * (strlen(hostname) + 1) + 10 + 1; map = alloc_method_addr(bmi_portals_method_id, extra); + map->ops = &bmi_portals_ops; pma = map->method_data; pma->hostname = (void *) &pma[1]; @@ -1987,28 +1988,28 @@ static int bmip_query_addr_range(struct const struct bmi_method_ops bmi_portals_ops = { .method_name = "bmi_portals", - .BMI_meth_initialize = bmip_initialize, - .BMI_meth_finalize = bmip_finalize, - .BMI_meth_set_info = bmip_set_info, - .BMI_meth_get_info = bmip_get_info, - .BMI_meth_memalloc = bmip_memalloc, - .BMI_meth_memfree = bmip_memfree, - .BMI_meth_unexpected_free = bmip_unexpected_free, - .BMI_meth_post_send = bmip_post_send, - .BMI_meth_post_sendunexpected = bmip_post_sendunexpected, - .BMI_meth_post_recv = bmip_post_recv, - .BMI_meth_test = bmip_test, - .BMI_meth_testsome = bmip_testsome, - .BMI_meth_testcontext = bmip_testcontext, - .BMI_meth_testunexpected = bmip_testunexpected, - .BMI_meth_method_addr_lookup = bmip_method_addr_lookup, - .BMI_meth_post_send_list = bmip_post_send_list, - .BMI_meth_post_recv_list = bmip_post_recv_list, - .BMI_meth_post_sendunexpected_list = bmip_post_sendunexpected_list, - .BMI_meth_open_context = bmip_open_context, - .BMI_meth_close_context = bmip_close_context, - .BMI_meth_cancel = bmip_cancel, - .BMI_meth_rev_lookup_unexpected = bmip_rev_lookup, - .BMI_meth_query_addr_range = bmip_query_addr_range, + .initialize = bmip_initialize, + .finalize = bmip_finalize, + .set_info = bmip_set_info, + .get_info = bmip_get_info, + .memalloc = bmip_memalloc, + .memfree = bmip_memfree, + .unexpected_free = bmip_unexpected_free, + .post_send = bmip_post_send, + .post_sendunexpected = bmip_post_sendunexpected, + .post_recv = bmip_post_recv, + .test = bmip_test, + .testsome = bmip_testsome, + .testcontext = bmip_testcontext, + .testunexpected = bmip_testunexpected, + .method_addr_lookup = bmip_method_addr_lookup, + .post_send_list = bmip_post_send_list, + .post_recv_list = bmip_post_recv_list, + .post_sendunexpected_list = bmip_post_sendunexpected_list, + .open_context = bmip_open_context, + .close_context = bmip_close_context, + .cancel = bmip_cancel, + .rev_lookup_unexpected = bmip_rev_lookup, + .query_addr_range = bmip_query_addr_range, }; Index: src/io/bmi/bmi_tcp/bmi-tcp-addressing.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/bmi-tcp-addressing.h,v retrieving revision 1.16 diff -u -a -p -r1.16 bmi-tcp-addressing.h --- src/io/bmi/bmi_tcp/bmi-tcp-addressing.h 9 Oct 2007 21:58:31 -0000 1.16 +++ src/io/bmi/bmi_tcp/bmi-tcp-addressing.h 6 Nov 2007 16:08:00 -0000 @@ -46,8 +46,8 @@ struct tcp_allowed_connection_s { * connections are made */ struct tcp_addr { + bmi_method_addr_p map; /* points back to generic address */ \ PVFS_BMI_addr_t bmi_addr; - method_addr_p map; /* points back to generic address */ /* stores error code for addresses that are broken for some reason */ int addr_error; char *hostname; @@ -78,10 +78,10 @@ struct tcp_addr #define bmi_tcp_errno_to_pvfs bmi_errno_to_pvfs -void tcp_forget_addr(method_addr_p map, +void tcp_forget_addr(bmi_method_addr_p map, int dealloc_flag, int error_code); -method_addr_p alloc_tcp_method_addr(void); +bmi_method_addr_p alloc_tcp_method_addr(void); #endif /* __BMI_TCP_ADDRESSING_H */ Index: src/io/bmi/bmi_tcp/bmi-tcp.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/bmi-tcp.c,v retrieving revision 1.121 diff -u -a -p -r1.121 bmi-tcp.c --- src/io/bmi/bmi_tcp/bmi-tcp.c 20 Oct 2007 15:40:13 -0000 1.121 +++ src/io/bmi/bmi_tcp/bmi-tcp.c 6 Nov 2007 16:08:01 -0000 @@ -55,7 +55,7 @@ static gen_mutex_t interface_mutex = GEN_MUTEX_INITIALIZER; /* function prototypes */ -int BMI_tcp_initialize(method_addr_p listen_addr, +int BMI_tcp_initialize(bmi_method_addr_p listen_addr, int method_id, int init_flags); int BMI_tcp_finalize(void); @@ -70,7 +70,7 @@ int BMI_tcp_memfree(void *buffer, enum bmi_op_type send_recv); int BMI_tcp_unexpected_free(void *buffer); int BMI_tcp_post_send(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -78,7 +78,7 @@ int BMI_tcp_post_send(bmi_op_id_t * id, void *user_ptr, bmi_context_id context_id); int BMI_tcp_post_sendunexpected(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -86,7 +86,7 @@ int BMI_tcp_post_sendunexpected(bmi_op_i void *user_ptr, bmi_context_id context_id); int BMI_tcp_post_recv(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *buffer, bmi_size_t expected_size, bmi_size_t * actual_size, @@ -112,7 +112,7 @@ int BMI_tcp_testsome(int incount, bmi_context_id context_id); int BMI_tcp_testunexpected(int incount, int *outcount, - struct method_unexpected_info *info, + struct bmi_method_unexpected_info *info, int max_idle_time_ms); int BMI_tcp_testcontext(int incount, bmi_op_id_t * out_id_array, @@ -122,11 +122,11 @@ int BMI_tcp_testcontext(int incount, void **user_ptr_array, int max_idle_time_ms, bmi_context_id context_id); -method_addr_p BMI_tcp_method_addr_lookup(const char *id_string); -const char* BMI_tcp_addr_rev_lookup_unexpected(method_addr_p map); -int BMI_tcp_query_addr_range(method_addr_p, const char *, int); +bmi_method_addr_p BMI_tcp_method_addr_lookup(const char *id_string); +const char* BMI_tcp_addr_rev_lookup_unexpected(bmi_method_addr_p map); +int BMI_tcp_query_addr_range(bmi_method_addr_p, const char *, int); int BMI_tcp_post_send_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -136,7 +136,7 @@ int BMI_tcp_post_send_list(bmi_op_id_t * void *user_ptr, bmi_context_id context_id); int BMI_tcp_post_recv_list(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -147,7 +147,7 @@ int BMI_tcp_post_recv_list(bmi_op_id_t * void *user_ptr, bmi_context_id context_id); int BMI_tcp_post_sendunexpected_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -221,11 +221,11 @@ static struct iovec stat_io_vector[BMI_T /* internal utility functions */ static int tcp_server_init(void); -static void dealloc_tcp_method_addr(method_addr_p map); -static int tcp_sock_init(method_addr_p my_method_addr); +static void dealloc_tcp_method_addr(bmi_method_addr_p map); +static int tcp_sock_init(bmi_method_addr_p my_method_addr); static int enqueue_operation(op_list_p target_list, enum bmi_op_type send_recv, - method_addr_p map, + bmi_method_addr_p map, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -238,12 +238,12 @@ static int enqueue_operation(op_list_p t bmi_size_t actual_size, bmi_size_t expected_size, bmi_context_id context_id); -static int tcp_cleanse_addr(method_addr_p map, int error_code); -static int tcp_shutdown_addr(method_addr_p map); +static int tcp_cleanse_addr(bmi_method_addr_p map, int error_code); +static int tcp_shutdown_addr(bmi_method_addr_p map); static int tcp_do_work(int max_idle_time); -static int tcp_do_work_error(method_addr_p map); -static int tcp_do_work_recv(method_addr_p map, int* stall_flag); -static int tcp_do_work_send(method_addr_p map, int* stall_flag); +static int tcp_do_work_error(bmi_method_addr_p map); +static int tcp_do_work_recv(bmi_method_addr_p map, int* stall_flag); +static int tcp_do_work_send(bmi_method_addr_p map, int* stall_flag); static int work_on_recv_op(method_op_p my_method_op, int *stall_flag); static int work_on_send_op(method_op_p my_method_op, @@ -251,9 +251,9 @@ static int work_on_send_op(method_op_p m static int tcp_accept_init(int *socket, char** peer); static method_op_p alloc_tcp_method_op(void); static void dealloc_tcp_method_op(method_op_p old_op); -static int handle_new_connection(method_addr_p map); +static int handle_new_connection(bmi_method_addr_p map); static int BMI_tcp_post_send_generic(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -262,7 +262,7 @@ static int BMI_tcp_post_send_generic(bmi void *user_ptr, bmi_context_id context_id); static int tcp_post_recv_generic(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -289,29 +289,29 @@ static void bmi_set_sock_buffers(int soc /* exported method interface */ struct bmi_method_ops bmi_tcp_ops = { .method_name = BMI_tcp_method_name, - .BMI_meth_initialize = BMI_tcp_initialize, - .BMI_meth_finalize = BMI_tcp_finalize, - .BMI_meth_set_info = BMI_tcp_set_info, - .BMI_meth_get_info = BMI_tcp_get_info, - .BMI_meth_memalloc = BMI_tcp_memalloc, - .BMI_meth_memfree = BMI_tcp_memfree, - .BMI_meth_unexpected_free = BMI_tcp_unexpected_free, - .BMI_meth_post_send = BMI_tcp_post_send, - .BMI_meth_post_sendunexpected = BMI_tcp_post_sendunexpected, - .BMI_meth_post_recv = BMI_tcp_post_recv, - .BMI_meth_test = BMI_tcp_test, - .BMI_meth_testsome = BMI_tcp_testsome, - .BMI_meth_testcontext = BMI_tcp_testcontext, - .BMI_meth_testunexpected = BMI_tcp_testunexpected, - .BMI_meth_method_addr_lookup = BMI_tcp_method_addr_lookup, - .BMI_meth_post_send_list = BMI_tcp_post_send_list, - .BMI_meth_post_recv_list = BMI_tcp_post_recv_list, - .BMI_meth_post_sendunexpected_list = BMI_tcp_post_sendunexpected_list, - .BMI_meth_open_context = BMI_tcp_open_context, - .BMI_meth_close_context = BMI_tcp_close_context, - .BMI_meth_cancel = BMI_tcp_cancel, - .BMI_meth_rev_lookup_unexpected = BMI_tcp_addr_rev_lookup_unexpected, - .BMI_meth_query_addr_range = BMI_tcp_query_addr_range, + .initialize = BMI_tcp_initialize, + .finalize = BMI_tcp_finalize, + .set_info = BMI_tcp_set_info, + .get_info = BMI_tcp_get_info, + .memalloc = BMI_tcp_memalloc, + .memfree = BMI_tcp_memfree, + .unexpected_free = BMI_tcp_unexpected_free, + .post_send = BMI_tcp_post_send, + .post_sendunexpected = BMI_tcp_post_sendunexpected, + .post_recv = BMI_tcp_post_recv, + .test = BMI_tcp_test, + .testsome = BMI_tcp_testsome, + .testcontext = BMI_tcp_testcontext, + .testunexpected = BMI_tcp_testunexpected, + .method_addr_lookup = BMI_tcp_method_addr_lookup, + .post_send_list = BMI_tcp_post_send_list, + .post_recv_list = BMI_tcp_post_recv_list, + .post_sendunexpected_list = BMI_tcp_post_sendunexpected_list, + .open_context = BMI_tcp_open_context, + .close_context = BMI_tcp_close_context, + .cancel = BMI_tcp_cancel, + .rev_lookup_unexpected = BMI_tcp_addr_rev_lookup_unexpected, + .query_addr_range = BMI_tcp_query_addr_range, }; /* module parameters */ @@ -319,7 +319,7 @@ static struct { int method_flags; int method_id; - method_addr_p listen_addr; + bmi_method_addr_p listen_addr; } tcp_method_params; #if defined(USE_TRUSTED) && defined(__PVFS2_SERVER__) @@ -400,7 +400,7 @@ static int tcp_buffer_size_send = 0; * * returns 0 on success, -errno on failure */ -int BMI_tcp_initialize(method_addr_p listen_addr, +int BMI_tcp_initialize(bmi_method_addr_p listen_addr, int method_id, int init_flags) { @@ -545,16 +545,16 @@ int BMI_tcp_finalize(void) * * returns a pointer to method_addr on success, NULL on failure */ -method_addr_p BMI_tcp_method_addr_lookup(const char *id_string) +bmi_method_addr_p BMI_tcp_method_addr_lookup(const char *id_string) { char *tcp_string = NULL; char *delim = NULL; char *hostname = NULL; - method_addr_p new_addr = NULL; + bmi_method_addr_p new_addr = NULL; struct tcp_addr *tcp_addr_data = NULL; int ret = -1; - tcp_string = string_key("tcp", id_string); + tcp_string = strdup(id_string); if (!tcp_string) { /* the string doesn't even have our info */ @@ -739,7 +739,7 @@ int BMI_tcp_set_info(int option, void *inout_parameter) { int ret = -1; - method_addr_p tmp_addr = NULL; + bmi_method_addr_p tmp_addr = NULL; gen_mutex_lock(&interface_mutex); @@ -780,7 +780,7 @@ int BMI_tcp_set_info(int option, } else { - tmp_addr = (method_addr_p) inout_parameter; + tmp_addr = (bmi_method_addr_p) inout_parameter; /* take it out of the socket collection */ tcp_forget_addr(tmp_addr, 1, 0); ret = 0; @@ -950,7 +950,7 @@ int BMI_tcp_get_info(int option, * completion, -errno on failure */ int BMI_tcp_post_send(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -1005,7 +1005,7 @@ int BMI_tcp_post_send(bmi_op_id_t * id, * completion, -errno on failure */ int BMI_tcp_post_sendunexpected(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *buffer, bmi_size_t size, enum bmi_buffer_type buffer_type, @@ -1053,7 +1053,7 @@ int BMI_tcp_post_sendunexpected(bmi_op_i * completion, -errno on failure */ int BMI_tcp_post_recv(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *buffer, bmi_size_t expected_size, bmi_size_t * actual_size, @@ -1222,7 +1222,7 @@ int BMI_tcp_testsome(int incount, */ int BMI_tcp_testunexpected(int incount, int *outcount, - struct method_unexpected_info *info, + struct bmi_method_unexpected_info *info, int max_idle_time) { int ret = -1; @@ -1348,7 +1348,7 @@ int BMI_tcp_testcontext(int incount, * -errno on failure */ int BMI_tcp_post_send_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -1406,7 +1406,7 @@ int BMI_tcp_post_send_list(bmi_op_id_t * * -errno on failure */ int BMI_tcp_post_recv_list(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -1450,7 +1450,7 @@ int BMI_tcp_post_recv_list(bmi_op_id_t * * -errno on failure */ int BMI_tcp_post_sendunexpected_list(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -1701,7 +1701,7 @@ static int check_octets(struct in_addr a * Check if a given address is within the network specified by the wildcard string! * or if it is part of the subnet mask specified */ -int BMI_tcp_query_addr_range(method_addr_p map, const char *wildcard_string, int netmask) +int BMI_tcp_query_addr_range(bmi_method_addr_p map, const char *wildcard_string, int netmask) { struct tcp_addr *tcp_addr_data = map->method_data; struct sockaddr_in map_addr; @@ -1756,7 +1756,7 @@ int BMI_tcp_query_addr_range(method_addr * * returns string on success, "UNKNOWN" on failure */ -const char* BMI_tcp_addr_rev_lookup_unexpected(method_addr_p map) +const char* BMI_tcp_addr_rev_lookup_unexpected(bmi_method_addr_p map) { struct tcp_addr *tcp_addr_data = map->method_data; int debug_on; @@ -1836,14 +1836,14 @@ const char* BMI_tcp_addr_rev_lookup_unex * * no return value */ -void tcp_forget_addr(method_addr_p map, +void tcp_forget_addr(bmi_method_addr_p map, int dealloc_flag, int error_code) { struct tcp_addr* tcp_addr_data = map->method_data; PVFS_BMI_addr_t bmi_addr = tcp_addr_data->bmi_addr; int tmp_outcount; - method_addr_p tmp_addr; + bmi_method_addr_p tmp_addr; int tmp_status; if (tcp_socket_collection_p) @@ -1885,7 +1885,7 @@ void tcp_forget_addr(method_addr_p map, * * no return value */ -static void dealloc_tcp_method_addr(method_addr_p map) +static void dealloc_tcp_method_addr(bmi_method_addr_p map) { struct tcp_addr *tcp_addr_data = NULL; @@ -1907,7 +1907,7 @@ static void dealloc_tcp_method_addr(meth if (tcp_addr_data->peer) free(tcp_addr_data->peer); - dealloc_method_addr(map); + bmi_dealloc_method_addr(map); return; } @@ -1920,19 +1920,21 @@ static void dealloc_tcp_method_addr(meth * * returns pointer to struct on success, NULL on failure */ -method_addr_p alloc_tcp_method_addr(void) +bmi_method_addr_p alloc_tcp_method_addr(void) { - struct method_addr *my_method_addr = NULL; + struct bmi_method_addr *my_method_addr = NULL; struct tcp_addr *tcp_addr_data = NULL; my_method_addr = - alloc_method_addr(tcp_method_params.method_id, sizeof(struct tcp_addr)); + bmi_alloc_method_addr(tcp_method_params.method_id, sizeof(struct tcp_addr)); if (!my_method_addr) { return (NULL); } + my_method_addr->ops = &bmi_tcp_ops; + /* note that we trust the alloc_method_addr() function to have zeroed * out the structures for us already */ @@ -2028,7 +2030,7 @@ static int tcp_server_init(void) * * returns pointer to operation on success, NULL if nothing found. */ -static method_op_p find_recv_inflight(method_addr_p map) +static method_op_p find_recv_inflight(bmi_method_addr_p map) { struct op_list_search_key key; method_op_p query_op = NULL; @@ -2056,7 +2058,7 @@ static method_op_p find_recv_inflight(me * * returns 0 on success, -errno on failure */ -static int tcp_sock_init(method_addr_p my_method_addr) +static int tcp_sock_init(bmi_method_addr_p my_method_addr) { int oldfl = 0; /* socket flags */ @@ -2205,7 +2207,7 @@ static int tcp_sock_init(method_addr_p m */ static int enqueue_operation(op_list_p target_list, enum bmi_op_type send_recv, - method_addr_p map, + bmi_method_addr_p map, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -2348,7 +2350,7 @@ static int enqueue_operation(op_list_p t * completion, -errno on failure */ static int tcp_post_recv_generic(bmi_op_id_t * id, - method_addr_p src, + bmi_method_addr_p src, void *const *buffer_list, const bmi_size_t *size_list, int list_count, @@ -2603,7 +2605,7 @@ static int tcp_post_recv_generic(bmi_op_ * * returns 0 on success, -errno on failure */ -static int tcp_cleanse_addr(method_addr_p map, int error_code) +static int tcp_cleanse_addr(bmi_method_addr_p map, int error_code) { int i = 0; struct op_list_search_key key; @@ -2648,7 +2650,7 @@ static int tcp_cleanse_addr(method_addr_ * * returns 0 on success, -errno on failure */ -static int tcp_shutdown_addr(method_addr_p map) +static int tcp_shutdown_addr(bmi_method_addr_p map) { struct tcp_addr *tcp_addr_data = map->method_data; @@ -2674,7 +2676,7 @@ static int tcp_shutdown_addr(method_addr static int tcp_do_work(int max_idle_time) { int ret = -1; - method_addr_p addr_array[TCP_WORK_METRIC]; + bmi_method_addr_p addr_array[TCP_WORK_METRIC]; int status_array[TCP_WORK_METRIC]; int socket_count = 0; int i = 0; @@ -2772,7 +2774,7 @@ static int tcp_do_work(int max_idle_time * * returns 0 on success, -errno on failure */ -static int tcp_do_work_send(method_addr_p map, int* stall_flag) +static int tcp_do_work_send(bmi_method_addr_p map, int* stall_flag) { method_op_p active_method_op = NULL; struct op_list_search_key key; @@ -2817,11 +2819,11 @@ static int tcp_do_work_send(method_addr_ * * returns 0 on success, -errno on failure */ -static int handle_new_connection(method_addr_p map) +static int handle_new_connection(bmi_method_addr_p map) { struct tcp_addr *tcp_addr_data = NULL; int accepted_socket = -1; - method_addr_p new_addr = NULL; + bmi_method_addr_p new_addr = NULL; int ret = -1; char* tmp_peer = NULL; @@ -2880,7 +2882,7 @@ static int handle_new_connection(method_ * * returns 0 on success, -errno on failure */ -static int tcp_do_work_recv(method_addr_p map, int* stall_flag) +static int tcp_do_work_recv(bmi_method_addr_p map, int* stall_flag) { method_op_p active_method_op = NULL; @@ -3326,7 +3328,7 @@ static int work_on_recv_op(method_op_p m * * returns 0 on success, -errno on failure */ -static int tcp_do_work_error(method_addr_p map) +static int tcp_do_work_error(bmi_method_addr_p map) { struct tcp_addr *tcp_addr_data = NULL; int buf; @@ -3603,7 +3605,7 @@ static method_op_p alloc_tcp_method_op(v { method_op_p my_method_op = NULL; - my_method_op = alloc_method_op(sizeof(struct tcp_op)); + my_method_op = bmi_alloc_method_op(sizeof(struct tcp_op)); /* we trust alloc_method_op to zero it out */ @@ -3620,7 +3622,7 @@ static method_op_p alloc_tcp_method_op(v */ static void dealloc_tcp_method_op(method_op_p old_op) { - dealloc_method_op(old_op); + bmi_dealloc_method_op(old_op); return; } @@ -3632,7 +3634,7 @@ static void dealloc_tcp_method_op(method * completion, -errno on failure */ static int BMI_tcp_post_send_generic(bmi_op_id_t * id, - method_addr_p dest, + bmi_method_addr_p dest, const void *const *buffer_list, const bmi_size_t *size_list, int list_count, Index: src/io/bmi/bmi_tcp/socket-collection-epoll.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/socket-collection-epoll.c,v retrieving revision 1.5 diff -u -a -p -r1.5 socket-collection-epoll.c --- src/io/bmi/bmi_tcp/socket-collection-epoll.c 9 Oct 2007 21:58:31 -0000 1.5 +++ src/io/bmi/bmi_tcp/socket-collection-epoll.c 6 Nov 2007 16:08:01 -0000 @@ -101,7 +101,7 @@ socket_collection_p BMI_socket_collectio * returns 0 on success, -errno on failure. */ void BMI_socket_collection_queue(socket_collection_p scp, - method_addr_p map, struct qlist_head* queue) + bmi_method_addr_p map, struct qlist_head* queue) { struct qlist_head* iterator = NULL; struct qlist_head* scratch = NULL; @@ -168,7 +168,7 @@ void BMI_socket_collection_finalize(sock int BMI_socket_collection_testglobal(socket_collection_p scp, int incount, int *outcount, - method_addr_p * maps, + bmi_method_addr_p * maps, int * status, int poll_timeout, gen_mutex_t* external_mutex) @@ -187,7 +187,7 @@ int BMI_socket_collection_testglobal(soc /* init the outgoing arguments for safety */ *outcount = 0; - memset(maps, 0, (sizeof(method_addr_p) * incount)); + memset(maps, 0, (sizeof(bmi_method_addr_p) * incount)); memset(status, 0, (sizeof(int) * incount)); gen_mutex_lock(&scp->mutex); Index: src/io/bmi/bmi_tcp/socket-collection-epoll.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/socket-collection-epoll.h,v retrieving revision 1.3 diff -u -a -p -r1.3 socket-collection-epoll.h --- src/io/bmi/bmi_tcp/socket-collection-epoll.h 25 Sep 2006 18:20:43 -0000 1.3 +++ src/io/bmi/bmi_tcp/socket-collection-epoll.h 6 Nov 2007 16:08:01 -0000 @@ -53,7 +53,7 @@ enum socket_collection_p BMI_socket_collection_init(int new_server_socket); void BMI_socket_collection_queue(socket_collection_p scp, - method_addr_p map, struct qlist_head* queue); + bmi_method_addr_p map, struct qlist_head* queue); /* the bmi_tcp code may try to add a socket to the collection before * it is fully connected, just ignore in this case @@ -159,7 +159,7 @@ void BMI_socket_collection_finalize(sock int BMI_socket_collection_testglobal(socket_collection_p scp, int incount, int *outcount, - method_addr_p * maps, + bmi_method_addr_p * maps, int * status, int poll_timeout, gen_mutex_t* external_mutex); Index: src/io/bmi/bmi_tcp/socket-collection.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/socket-collection.c,v retrieving revision 1.16 diff -u -a -p -r1.16 socket-collection.c --- src/io/bmi/bmi_tcp/socket-collection.c 26 Mar 2007 18:26:35 -0000 1.16 +++ src/io/bmi/bmi_tcp/socket-collection.c 6 Nov 2007 16:08:01 -0000 @@ -66,7 +66,7 @@ socket_collection_p BMI_socket_collectio return(NULL); } tmp_scp->addr_array = - (method_addr_p*)malloc(POLLFD_ARRAY_START*sizeof(method_addr_p)); + (bmi_method_addr_p*)malloc(POLLFD_ARRAY_START*sizeof(method_addr_p)); if(!tmp_scp->addr_array) { free(tmp_scp->pollfd_array); @@ -111,7 +111,7 @@ socket_collection_p BMI_socket_collectio * returns 0 on success, -errno on failure. */ void BMI_socket_collection_queue(socket_collection_p scp, - method_addr_p map, struct qlist_head* queue) + bmi_method_addr_p map, struct qlist_head* queue) { struct qlist_head* iterator = NULL; struct qlist_head* scratch = NULL; @@ -175,7 +175,7 @@ void BMI_socket_collection_finalize(sock int BMI_socket_collection_testglobal(socket_collection_p scp, int incount, int *outcount, - method_addr_p * maps, + bmi_method_addr_p * maps, int * status, int poll_timeout, gen_mutex_t* external_mutex) @@ -185,7 +185,7 @@ int BMI_socket_collection_testglobal(soc struct tcp_addr* tcp_addr_data = NULL; struct tcp_addr* shifted_tcp_addr_data = NULL; struct pollfd* tmp_pollfd_array = NULL; - method_addr_p* tmp_addr_array = NULL; + bmi_method_addr_p* tmp_addr_array = NULL; int ret = -1; int old_errno; int tmp_count; @@ -199,7 +199,7 @@ int BMI_socket_collection_testglobal(soc do_again: /* init the outgoing arguments for safety */ *outcount = 0; - memset(maps, 0, (sizeof(method_addr_p) * incount)); + memset(maps, 0, (sizeof(bmi_method_addr_p) * incount)); memset(status, 0, (sizeof(int) * incount)); gen_mutex_lock(&scp->mutex); @@ -255,8 +255,8 @@ do_again: (scp->array_max+POLLFD_ARRAY_INC)*sizeof(struct pollfd)); /* TODO: handle this */ assert(tmp_pollfd_array); - tmp_addr_array = (method_addr_p*)malloc( - (scp->array_max+POLLFD_ARRAY_INC)*sizeof(method_addr_p)); + tmp_addr_array = (bmi_method_addr_p*)malloc( + (scp->array_max+POLLFD_ARRAY_INC)*sizeof(bmi_method_addr_p)); /* TODO: handle this */ assert(tmp_addr_array); memcpy(tmp_pollfd_array, scp->pollfd_array, @@ -264,7 +264,7 @@ do_again: free(scp->pollfd_array); scp->pollfd_array = tmp_pollfd_array; memcpy(tmp_addr_array, scp->addr_array, - scp->array_max*sizeof(method_addr_p)); + scp->array_max*sizeof(bmi_method_addr_p)); free(scp->addr_array); scp->addr_array = tmp_addr_array; scp->array_max = scp->array_max+POLLFD_ARRAY_INC; Index: src/io/bmi/bmi_tcp/socket-collection.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/socket-collection.h,v retrieving revision 1.12 diff -u -a -p -r1.12 socket-collection.h --- src/io/bmi/bmi_tcp/socket-collection.h 24 May 2006 13:24:50 -0000 1.12 +++ src/io/bmi/bmi_tcp/socket-collection.h 6 Nov 2007 16:08:01 -0000 @@ -29,7 +29,7 @@ struct socket_collection gen_mutex_t mutex; struct pollfd* pollfd_array; - method_addr_p* addr_array; + bmi_method_addr_p* addr_array; int array_max; int array_count; @@ -51,7 +51,7 @@ enum socket_collection_p BMI_socket_collection_init(int new_server_socket); void BMI_socket_collection_queue(socket_collection_p scp, - method_addr_p map, struct qlist_head* queue); + bmi_method_addr_p map, struct qlist_head* queue); #ifndef __PVFS2_JOB_THREADED__ /* the bmi_tcp code may try to add a socket to the collection before @@ -151,7 +151,7 @@ void BMI_socket_collection_finalize(sock int BMI_socket_collection_testglobal(socket_collection_p scp, int incount, int *outcount, - method_addr_p * maps, + bmi_method_addr_p * maps, int * status, int poll_timeout, gen_mutex_t* external_mutex);