[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/io/bmi: bmi-method-support.h bmi.c reference-list.c reference-list.h

CVS commit program cvs at parl.clemson.edu
Thu Aug 7 12:30:18 EDT 2008


Update of /projects/cvsroot/pvfs2-1/src/io/bmi
In directory parlweb1:/tmp/cvs-serv6370/src/io/bmi

Modified Files:
      Tag: small-file-branch
	bmi-method-support.h bmi.c reference-list.c reference-list.h 
Log Message:
merge trunk updates down to small-file-branch.  Passes basic tests but needs
some double checking of pint-cached-config and sys-create conflicts.


Index: bmi-method-support.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/bmi/bmi-method-support.h,v
diff -p -u -r1.32 -r1.32.2.1
--- bmi-method-support.h	30 Nov 2007 19:35:26 -0000	1.32
+++ bmi-method-support.h	7 Aug 2008 16:30:17 -0000	1.32.2.1
@@ -43,6 +43,7 @@ struct bmi_method_addr
 {
     int method_type;
     void *method_data;		/* area to be used by specific methods */
+    void *parent;               /* pointer back to generic BMI address info */  
 };
 typedef struct bmi_method_addr *bmi_method_addr_p;
 

Index: bmi.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/bmi/bmi.c,v
diff -p -u -r1.90 -r1.90.6.1
--- bmi.c	7 Nov 2007 16:43:59 -0000	1.90
+++ bmi.c	7 Aug 2008 16:30:17 -0000	1.90.6.1
@@ -141,6 +141,7 @@ int BMI_initialize(const char *method_li
     char *proto = NULL;
     int addr_count = 0;
 
+
     /* server must specify method list at startup, optional for client */
     if (flags & BMI_INIT_SERVER) {
 	if (!listen_addr || !method_list)
@@ -153,6 +154,13 @@ int BMI_initialize(const char *method_li
 	}
     }
 
+    /* make sure that id generator is initialized if not already */
+    ret = id_gen_safe_initialize();
+    if(ret < 0)
+    {
+        return(ret);
+    }
+
     /* make a new reference list */
     cur_ref_list = ref_list_new();
     if (!cur_ref_list)
@@ -297,6 +305,9 @@ int BMI_initialize(const char *method_li
     active_method_count = 0;
     gen_mutex_unlock(&active_method_count_mutex);
 
+    /* shut down id generator */
+    id_gen_safe_finalize();
+
     return (ret);
 }
 
@@ -487,6 +498,9 @@ int BMI_finalize(void)
     /* (side effect: destroys all method addresses as well) */
     ref_list_cleanup(cur_ref_list);
 
+    /* shut down id generator */
+    id_gen_safe_finalize();
+
     return (0);
 }
 
@@ -1584,6 +1598,7 @@ int BMI_addr_lookup(PVFS_BMI_addr_t * ne
 
     /* fill in the details */
     new_ref->method_addr = meth_addr;
+    meth_addr->parent = new_ref;
     new_ref->id_string = (char *) malloc(strlen(id_string) + 1);
     if (!new_ref->id_string)
     {
@@ -1894,6 +1909,7 @@ PVFS_BMI_addr_t bmi_method_addr_reg_call
     */
     new_ref->method_addr = map;
     new_ref->id_string = NULL;
+    map->parent = new_ref;
 
     /* check the method_type from the method_addr pointer to know
      * which interface to use */

Index: reference-list.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/bmi/reference-list.c,v
diff -p -u -r1.13 -r1.13.6.1
--- reference-list.c	6 Nov 2007 23:08:33 -0000	1.13
+++ reference-list.c	7 Aug 2008 16:30:18 -0000	1.13.6.1
@@ -14,16 +14,22 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
+#include <assert.h>
 
 #include "reference-list.h"
 #include "gossip.h"
 #include "id-generator.h"
+#include "quickhash.h"
 
+static struct qhash_table* str_table = NULL;
+#define STR_TABLE_SIZE 137
 
 /***************************************************************
  * Visible functions
  */
 
+static int ref_list_compare_key_entry(void* key, struct qhash_head* link);
+
 /*
  * ref_list_new()
  *
@@ -36,11 +42,31 @@ ref_list_p ref_list_new(void)
 
     ref_list_p tmp_list = NULL;
 
+    /* There is currently never more than one reference list in BMI.  If we
+     * ever have a need for more, then this hash table should be moved from
+     * a static global to actually be part of the ref_list_p.
+     */
+    assert(str_table == NULL);
+
+    str_table = qhash_init(
+        ref_list_compare_key_entry,
+        quickhash_string_hash, 
+        STR_TABLE_SIZE);
+
+    if(!str_table)
+    {
+        return(NULL);
+    }
+
     tmp_list = (ref_list_p) malloc(sizeof(struct qlist_head));
-    if (tmp_list)
+    if(!tmp_list)
     {
-	INIT_QLIST_HEAD(tmp_list);
+        qhash_finalize(str_table);
+        str_table = NULL;
+        return(NULL);
     }
+
+    INIT_QLIST_HEAD(tmp_list);
     return (tmp_list);
 }
 
@@ -54,6 +80,11 @@ ref_list_p ref_list_new(void)
 void ref_list_add(ref_list_p rlp,
 		  ref_st_p rsp)
 {
+    if(rsp->id_string)
+    {
+        qhash_add(str_table, rsp->id_string, &rsp->hash_link);
+    }
+
     qlist_add(&(rsp->list_link), rlp);
 }
 
@@ -68,17 +99,7 @@ void ref_list_add(ref_list_p rlp,
 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);
+    return(id_gen_safe_lookup(my_addr));
 }
 
 
@@ -93,16 +114,7 @@ ref_st_p ref_list_search_addr(ref_list_p
 ref_st_p ref_list_search_method_addr(ref_list_p rlp,
 				     bmi_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);
+    return(map->parent);
 }
 
 /*
@@ -116,17 +128,16 @@ ref_st_p ref_list_search_method_addr(ref
 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)
+    struct qhash_head* tmp_link;
+
+    tmp_link = qhash_search(str_table, idstring);
+    if(!tmp_link)
     {
-	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);
     }
-    return (NULL);
+
+    return(qlist_entry(tmp_link, ref_st, hash_link));
 }
 
 /*
@@ -139,20 +150,20 @@ ref_st_p ref_list_search_str(ref_list_p 
 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;
+    ref_st_p tmp_entry;
+    
+    tmp_entry = id_gen_safe_lookup(my_addr);
 
-    qlist_for_each_safe(tmp_link, scratch, rlp)
+    if(tmp_entry)
     {
-	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);
-	}
+        qlist_del(&tmp_entry->list_link);
+
+        if(tmp_entry->id_string)
+        {
+            qhash_del(&tmp_entry->hash_link);
+        }
     }
-    return (NULL);
+    return (tmp_entry);
 }
 
 
@@ -177,6 +188,9 @@ void ref_list_cleanup(ref_list_p rlp)
         dealloc_ref_st(tmp_entry);
     }
 
+    qhash_finalize(str_table);
+    str_table = NULL;
+
     free(rlp);
     return;
 }
@@ -203,7 +217,7 @@ ref_st_p alloc_ref_st(void)
     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);
+    id_gen_safe_register(&(new_ref->bmi_addr), new_ref);
 
     return (new_ref);
 }
@@ -234,9 +248,24 @@ void dealloc_ref_st(ref_st_p deadref)
 	deadref->interface->set_info(BMI_DROP_ADDR, deadref->method_addr);
     }
 
-    id_gen_fast_unregister(deadref->bmi_addr);
+    id_gen_safe_unregister(deadref->bmi_addr);
 
     free(deadref);
+}
+
+static int ref_list_compare_key_entry(void* key, struct qhash_head* link)
+{
+    char* key_string = (char*)key;
+    ref_st_p tmp_entry = NULL;
+
+    tmp_entry = qhash_entry(link, ref_st, hash_link);
+    assert(tmp_entry);
+
+    if(strcmp(tmp_entry->id_string, key_string) == 0)
+    {
+        return(1);
+    }
+    return(0);
 }
 
 /*

Index: reference-list.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/bmi/reference-list.h,v
diff -p -u -r1.8 -r1.8.6.1
--- reference-list.h	6 Nov 2007 23:08:33 -0000	1.8
+++ reference-list.h	7 Aug 2008 16:30:18 -0000	1.8.6.1
@@ -17,6 +17,7 @@
 #include "bmi-types.h"
 #include "bmi-method-support.h"
 #include "quicklist.h"
+#include "quickhash.h"
 
 typedef struct qlist_head *ref_list_p;
 
@@ -37,6 +38,7 @@ struct ref_st
     /* linked list entry */
     struct qlist_head list_link;
     int ref_count;
+    struct qhash_head hash_link;
 };
 
 typedef struct ref_st ref_st, *ref_st_p;



More information about the Pvfs2-cvs mailing list