1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Match Entry management routines
7 * Copyright (c) 2001-2003 Cluster File Systems, Inc.
9 * This file is part of Lustre, http://www.lustre.org
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define DEBUG_SUBSYSTEM S_LNET
27 #include <lnet/lib-lnet.h>
30 LNetMEAttach(unsigned int portal,
31 lnet_process_id_t match_id,
32 __u64 match_bits, __u64 ignore_bits,
33 lnet_unlink_t unlink, lnet_ins_pos_t pos,
34 lnet_handle_me_t *handle)
38 LASSERT (the_lnet.ln_init);
39 LASSERT (the_lnet.ln_refcount > 0);
41 if (portal >= the_lnet.ln_nportals)
50 me->me_portal = portal;
51 me->me_match_id = match_id;
52 me->me_match_bits = match_bits;
53 me->me_ignore_bits = ignore_bits;
54 me->me_unlink = unlink;
57 lnet_initialise_handle (&me->me_lh, LNET_COOKIE_TYPE_ME);
59 if (pos == LNET_INS_AFTER)
60 list_add_tail(&me->me_list, &(the_lnet.ln_portals[portal].ptl_ml));
62 list_add(&me->me_list, &(the_lnet.ln_portals[portal].ptl_ml));
64 lnet_me2handle(handle, me);
72 LNetMEInsert(lnet_handle_me_t current_meh,
73 lnet_process_id_t match_id,
74 __u64 match_bits, __u64 ignore_bits,
75 lnet_unlink_t unlink, lnet_ins_pos_t pos,
76 lnet_handle_me_t *handle)
78 lnet_me_t *current_me;
81 LASSERT (the_lnet.ln_init);
82 LASSERT (the_lnet.ln_refcount > 0);
84 new_me = lnet_me_alloc();
90 current_me = lnet_handle2me(¤t_meh);
91 if (current_me == NULL) {
92 lnet_me_free (new_me);
98 new_me->me_match_id = match_id;
99 new_me->me_match_bits = match_bits;
100 new_me->me_ignore_bits = ignore_bits;
101 new_me->me_unlink = unlink;
102 new_me->me_md = NULL;
104 lnet_initialise_handle (&new_me->me_lh, LNET_COOKIE_TYPE_ME);
106 if (pos == LNET_INS_AFTER)
107 list_add_tail(&new_me->me_list, ¤t_me->me_list);
109 list_add(&new_me->me_list, ¤t_me->me_list);
111 lnet_me2handle(handle, new_me);
119 LNetMEUnlink(lnet_handle_me_t meh)
124 LASSERT (the_lnet.ln_init);
125 LASSERT (the_lnet.ln_refcount > 0);
129 me = lnet_handle2me(&meh);
142 /* call with LNET_LOCK please */
144 lnet_me_unlink(lnet_me_t *me)
146 list_del (&me->me_list);
148 if (me->me_md != NULL) {
149 me->me_md->md_me = NULL;
150 lnet_md_unlink(me->me_md);
153 lnet_invalidate_handle (&me->me_lh);
159 lib_me_dump(lnet_me_t *me)
161 CWARN("Match Entry %p ("LPX64")\n", me,
162 me->me_lh.lh_cookie);
164 CWARN("\tMatch/Ignore\t= %016lx / %016lx\n",
165 me->me_match_bits, me->me_ignore_bits);
167 CWARN("\tMD\t= %p\n", me->md);
168 CWARN("\tprev\t= %p\n",
169 list_entry(me->me_list.prev, lnet_me_t, me_list));
170 CWARN("\tnext\t= %p\n",
171 list_entry(me->me_list.next, lnet_me_t, me_list));