X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Flnet%2Flib-msg.c;h=089d7886de0a24681287f9eb322d7125dffa1de1;hb=6e3ec5812ebd1b5ecf7cae584f429b013ffe7431;hp=a9834b5bcae26e8d559a330ab729fca64e38c5b8;hpb=ed88907a96ba81d3558e71ade9def98bdc785169;p=fs%2Flustre-release.git diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c index a9834b5..089d788 100644 --- a/lnet/lnet/lib-msg.c +++ b/lnet/lnet/lib-msg.c @@ -1,25 +1,41 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * lib/lib-msg.c - * Message decoding, parsing and finalizing routines + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * Copyright (c) 2001-2003 Cluster File Systems, Inc. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * This file is part of Lustre, http://www.lustre.org + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * lnet/lnet/lib-msg.c * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Message decoding, parsing and finalizing routines */ #define DEBUG_SUBSYSTEM S_LNET @@ -27,6 +43,21 @@ #include void +lnet_build_unlink_event (lnet_libmd_t *md, lnet_event_t *ev) +{ + ENTRY; + + memset(ev, 0, sizeof(*ev)); + + ev->status = 0; + ev->unlinked = 1; + ev->type = LNET_EVENT_UNLINK; + lnet_md_deconstruct(md, &ev->md); + lnet_md2handle(&ev->md_handle, md); + EXIT; +} + +void lnet_enq_event_locked (lnet_eq_t *eq, lnet_event_t *ev) { lnet_event_t *eq_slot; @@ -54,7 +85,7 @@ lnet_enq_event_locked (lnet_eq_t *eq, lnet_event_t *ev) if (cfs_waitq_active(&the_lnet.ln_waitq)) cfs_waitq_broadcast(&the_lnet.ln_waitq); #else -# if !HAVE_LIBPTHREAD +# ifndef HAVE_LIBPTHREAD /* LNetEQPoll() calls into _the_ LND to wait for action */ # else /* Wake anyone waiting in LNetEQPoll() */ @@ -79,18 +110,18 @@ lnet_complete_msg_locked(lnet_msg_t *msg) msg->msg_ack = 0; LNET_UNLOCK(); - + LASSERT(msg->msg_ev.type == LNET_EVENT_PUT); LASSERT(!msg->msg_routing); ack_wmd = msg->msg_hdr.msg.put.ack_wmd; - + lnet_prep_send(msg, LNET_MSG_ACK, msg->msg_ev.initiator, 0, 0); msg->msg_hdr.msg.ack.dst_wmd = ack_wmd; msg->msg_hdr.msg.ack.match_bits = msg->msg_ev.match_bits; msg->msg_hdr.msg.ack.mlength = cpu_to_le32(msg->msg_ev.mlength); - + rc = lnet_send(msg->msg_ev.target.nid, msg); LNET_LOCK(); @@ -116,7 +147,7 @@ lnet_complete_msg_locked(lnet_msg_t *msg) LASSERT (msg->msg_onactivelist); msg->msg_onactivelist = 0; - list_del (&msg->msg_activelist); + cfs_list_del (&msg->msg_activelist); the_lnet.ln_counters.msgs_alloc--; lnet_msg_free(msg); } @@ -131,7 +162,7 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status) #endif lnet_libmd_t *md; - LASSERT (!in_interrupt ()); + LASSERT (!cfs_in_interrupt ()); if (msg == NULL) return; @@ -167,19 +198,19 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status) LASSERT (md->md_refcount >= 0); unlink = lnet_md_unlinkable(md); - + msg->msg_ev.unlinked = unlink; - + if (md->md_eq != NULL) lnet_enq_event_locked(md->md_eq, &msg->msg_ev); - + if (unlink) lnet_md_unlink(md); msg->msg_md = NULL; } - list_add_tail (&msg->msg_list, &the_lnet.ln_finalizeq); + cfs_list_add_tail (&msg->msg_list, &the_lnet.ln_finalizeq); /* Recursion breaker. Don't complete the message here if I am (or * enough other threads are) already completing messages */ @@ -199,13 +230,15 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status) #else if (the_lnet.ln_finalizing) goto out; + + the_lnet.ln_finalizing = 1; #endif - while (!list_empty(&the_lnet.ln_finalizeq)) { - msg = list_entry(the_lnet.ln_finalizeq.next, - lnet_msg_t, msg_list); - - list_del(&msg->msg_list); + while (!cfs_list_empty(&the_lnet.ln_finalizeq)) { + msg = cfs_list_entry(the_lnet.ln_finalizeq.next, + lnet_msg_t, msg_list); + + cfs_list_del(&msg->msg_list); /* NB drops and regains the lnet lock if it actually does * anything, so my finalizing friends can chomp along too */ @@ -221,4 +254,3 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status) out: LNET_UNLOCK(); } -