[Pvfs2-cvs] commit by slang in pvfs2/src/io/bmi: bmi-method-callback.h bmi.c

CVS commit program cvs at parl.clemson.edu
Tue Oct 9 17:58:30 EDT 2007


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

Modified Files:
	bmi-method-callback.h bmi.c 
Log Message:
my fix for the halloween bug.


Index: bmi-method-callback.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi-method-callback.h,v
diff -p -u -r1.5 -r1.6
--- bmi-method-callback.h	28 Jul 2004 14:32:39 -0000	1.5
+++ bmi-method-callback.h	9 Oct 2007 21:58:29 -0000	1.6
@@ -9,7 +9,8 @@
 
 #include "bmi-method-support.h"
 
-int bmi_method_addr_reg_callback(method_addr_p map);
+PVFS_BMI_addr_t bmi_method_addr_reg_callback(method_addr_p map);
+int bmi_method_addr_forget_callback(PVFS_BMI_addr_t addr);
 
 #endif /* __BMI_METHOD_CALLBACK_H */
 

Index: bmi.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi.c,v
diff -p -u -r1.86 -r1.87
--- bmi.c	17 Aug 2007 19:31:19 -0000	1.86
+++ bmi.c	9 Oct 2007 21:58:29 -0000	1.87
@@ -1215,6 +1215,9 @@ int BMI_set_info(PVFS_BMI_addr_t addr,
     int i = 0;
     ref_st_p tmp_ref = NULL;
 
+    gossip_debug(GOSSIP_BMI_DEBUG_CONTROL,
+                 "[BMI CONTROL]: %s: set_info: %llu option: %d\n",
+                 __func__, llu(addr), option);
     /* if the addr is NULL, then the set_info should apply to all
      * available methods.
      */
@@ -1242,6 +1245,9 @@ int BMI_set_info(PVFS_BMI_addr_t addr,
 	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);
@@ -1255,12 +1261,18 @@ int BMI_set_info(PVFS_BMI_addr_t addr,
     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);
     }
     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)
@@ -1278,7 +1290,8 @@ int BMI_set_info(PVFS_BMI_addr_t addr,
 	    {
 		/* kill the address */
 		gossip_debug(GOSSIP_BMI_DEBUG_CONTROL,
-		    "bmi discarding address: %llu\n", llu(addr));
+		    "[BMI CONTROL]: %s: bmi discarding address: %llu\n",
+                    __func__, llu(addr));
 		ref_list_rem(cur_ref_list, addr);
 		/* NOTE: this triggers request to module to free underlying
 		 * resources if it wants to
@@ -1300,7 +1313,10 @@ int BMI_set_info(PVFS_BMI_addr_t addr,
              * 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, "Closing bmi_tcp connection at caller's request.\n"); 
+	    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);
         }
@@ -1562,7 +1578,7 @@ int BMI_addr_lookup(PVFS_BMI_addr_t * ne
     /* make sure one was successful */
     if (!meth_addr)
     {
-	return (bmi_errno_to_pvfs(-ENOPROTOOPT));
+        return bmi_errno_to_pvfs(-ENOPROTOOPT);
     }
 
     /* create a new reference for the addr */
@@ -1578,7 +1594,7 @@ int BMI_addr_lookup(PVFS_BMI_addr_t * ne
     new_ref->id_string = (char *) malloc(strlen(id_string) + 1);
     if (!new_ref->id_string)
     {
-	ret = -errno;
+	ret = bmi_errno_to_pvfs(errno);
 	goto bmi_addr_lookup_failure;
     }
     strcpy(new_ref->id_string, id_string);
@@ -1865,7 +1881,7 @@ int BMI_cancel(bmi_op_id_t id, 
  *
  * returns 0 on success, -errno on failure
  */
-int bmi_method_addr_reg_callback(method_addr_p map)
+PVFS_BMI_addr_t bmi_method_addr_reg_callback(method_addr_p map)
 {
     ref_st_p new_ref = NULL;
 
@@ -1877,7 +1893,7 @@ int bmi_method_addr_reg_callback(method_
     new_ref = alloc_ref_st();
     if (!new_ref)
     {
-	return (bmi_errno_to_pvfs(-ENOMEM));
+	return 0;
     }
 
     /*
@@ -1891,8 +1907,33 @@ int bmi_method_addr_reg_callback(method_
     new_ref->interface = active_method_table[map->method_type];
 
     /* add the reference structure to the list */
+    gen_mutex_lock(&ref_mutex);
     ref_list_add(cur_ref_list, new_ref);
+    gen_mutex_unlock(&ref_mutex);
 
+    return new_ref->bmi_addr;
+}
+
+int bmi_method_addr_forget_callback(PVFS_BMI_addr_t addr)
+{
+    ref_st_p ref;
+
+    gen_mutex_lock(&ref_mutex);
+    ref = ref_list_search_addr(cur_ref_list, addr);
+    if (!ref)
+    {
+	gen_mutex_unlock(&ref_mutex);
+	return (bmi_errno_to_pvfs(-EPROTO));
+    }
+    gen_mutex_unlock(&ref_mutex);
+
+    ref_list_rem(cur_ref_list, ref->bmi_addr);
+
+    /* have to set the method_addr to null before deallocating, since
+     * dealloc_ref_st tries to enter the method again to drop the addr
+     */
+    ref->method_addr = NULL;
+    dealloc_ref_st(ref);
     return (0);
 }
 



More information about the Pvfs2-cvs mailing list