Whamcloud - gitweb
fixed bulk source callback race
authoreeb <eeb>
Fri, 6 Sep 2002 15:58:41 +0000 (15:58 +0000)
committereeb <eeb>
Fri, 6 Sep 2002 15:58:41 +0000 (15:58 +0000)
lustre/include/linux/lustre_net.h
lustre/ptlrpc/events.c
lustre/ptlrpc/niobuf.c

index 08c67c6..94a3136 100644 (file)
@@ -168,6 +168,8 @@ struct ptlrpc_bulk_desc {
         ptl_handle_md_t bd_md_h;
         ptl_handle_me_t bd_me_h;
 
+        atomic_t       bd_source_callback_count;
+
         struct iovec bd_iov[16];    /* self-sized pre-allocated iov */
 };
 
index b8405fb..8c855bf 100644 (file)
@@ -130,6 +130,16 @@ static int bulk_source_callback(ptl_event_t *ev)
         struct list_head        *next;
         ENTRY;
 
+        CDEBUG(D_NET, "got %s event %d\n",
+               (ev->type == PTL_EVENT_SENT) ? "SENT" :
+               (ev->type == PTL_EVENT_ACK)  ? "ACK"  : "UNEXPECTED", ev->type);
+
+        LASSERT (ev->type == PTL_EVENT_SENT ||
+                 ev->type == PTL_EVENT_ACK);
+
+        LASSERT (atomic_read (&desc->bd_source_callback_count) > 0 &&
+                 atomic_read (&desc->bd_source_callback_count) <= 2);
+        
         if (ev->mem_desc.niov != desc->bd_page_count)
         {
                 int mdniov = ev->mem_desc.niov;
@@ -144,15 +154,12 @@ static int bulk_source_callback(ptl_event_t *ev)
         /* 1 fragment for each page always */
         LASSERT (ev->mem_desc.niov == desc->bd_page_count);
 
-        if (ev->type == PTL_EVENT_SENT) {
-                CDEBUG(D_NET, "got SENT event\n");
-        } else if (ev->type == PTL_EVENT_ACK) {
-                CDEBUG(D_NET, "got ACK event\n");
-
+        if (atomic_dec_and_test (&desc->bd_source_callback_count))
+        {
                 list_for_each_safe(tmp, next, &desc->bd_page_list) {
                         bulk = list_entry(tmp, struct ptlrpc_bulk_page,
                                           bp_link);
-
+                        
                         if (bulk->bp_cb != NULL)
                                 bulk->bp_cb(bulk);
                 }
@@ -160,12 +167,9 @@ static int bulk_source_callback(ptl_event_t *ev)
                 wake_up(&desc->bd_waitq);
                 if (desc->bd_cb != NULL)
                         desc->bd_cb(desc, desc->bd_cb_data);
-        } else {
-                CERROR("Unexpected event type!\n");
-                LBUG();
         }
 
-        RETURN(1);
+        RETURN(0);
 }
 
 static int bulk_sink_callback(ptl_event_t *ev)
index 6445db0..8606f01 100644 (file)
@@ -130,6 +130,8 @@ int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *desc)
         desc->bd_md.options = PTL_MD_OP_PUT | PTL_MD_IOV;
         desc->bd_md.user_ptr = desc;
 
+        atomic_set (&desc->bd_source_callback_count, 2);
+        
         list_for_each_safe(tmp, next, &desc->bd_page_list) {
                 struct ptlrpc_bulk_page *bulk;
                 bulk = list_entry(tmp, struct ptlrpc_bulk_page, bp_link);