From 90b3e0af23d076ff5a90006b62a8261163e93355 Mon Sep 17 00:00:00 2001 From: eeb Date: Fri, 6 Sep 2002 15:58:41 +0000 Subject: [PATCH] fixed bulk source callback race --- lustre/include/linux/lustre_net.h | 2 ++ lustre/ptlrpc/events.c | 24 ++++++++++++++---------- lustre/ptlrpc/niobuf.c | 2 ++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h index 08c67c6..94a3136 100644 --- a/lustre/include/linux/lustre_net.h +++ b/lustre/include/linux/lustre_net.h @@ -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 */ }; diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index b8405fb..8c855bf 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -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) diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c index 6445db0..8606f01 100644 --- a/lustre/ptlrpc/niobuf.c +++ b/lustre/ptlrpc/niobuf.c @@ -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); -- 1.8.3.1