#include <lnet/lib-lnet.h>
-/* must be called with LNET_LOCK held */
+/* must be called with lnet_res_lock held */
void
lnet_md_unlink(lnet_libmd_t *md)
{
/* Disassociate from ME (if any), and unlink it if it was created
* with LNET_UNLINK */
if (me != NULL) {
- md->md_me = NULL;
- me->me_md = NULL;
+ /* detach MD from portal */
+ lnet_ptl_detach_md(me, md);
if (me->me_unlink == LNET_UNLINK)
lnet_me_unlink(me);
}
return 0;
}
-/* must be called with LNET_LOCK held */
+/* must be called with lnet_res_lock held */
void
lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd)
{
LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
lnet_unlink_t unlink, lnet_handle_md_t *handle)
{
+ CFS_LIST_HEAD (matches);
+ CFS_LIST_HEAD (drops);
lnet_me_t *me;
lnet_libmd_t *md;
int rc;
rc = lnet_md_build(md, &umd, unlink);
- LNET_LOCK();
+ lnet_res_lock();
if (rc != 0)
goto failed;
if (rc != 0)
goto failed;
- the_lnet.ln_portals[me->me_portal]->ptl_ml_version++;
-
- me->me_md = md;
- md->md_me = me;
+ /* attach this MD to portal of ME and check if it matches any
+ * blocked msgs on this portal */
+ lnet_ptl_attach_md(me, md, &matches, &drops);
lnet_md2handle(handle, md);
- /* check if this MD matches any blocked msgs */
- lnet_match_blocked_msg(md); /* expects LNET_LOCK held */
+ lnet_res_unlock();
+
+ lnet_drop_delayed_msg_list(&drops, "Bad match");
+ lnet_recv_delayed_msg_list(&matches);
- LNET_UNLOCK();
return 0;
failed:
lnet_md_free_locked(md);
- LNET_UNLOCK();
+ lnet_res_unlock();
return rc;
}
rc = lnet_md_build(md, &umd, unlink);
- LNET_LOCK();
+ lnet_res_lock();
if (rc != 0)
goto failed;
lnet_md2handle(handle, md);
- LNET_UNLOCK();
+ lnet_res_unlock();
return 0;
failed:
lnet_md_free_locked(md);
- LNET_UNLOCK();
+ lnet_res_unlock();
return rc;
}
LASSERT (the_lnet.ln_init);
LASSERT (the_lnet.ln_refcount > 0);
- LNET_LOCK();
+ lnet_res_lock();
- md = lnet_handle2md(&mdh);
- if (md == NULL) {
- LNET_UNLOCK();
+ md = lnet_handle2md(&mdh);
+ if (md == NULL) {
+ lnet_res_unlock();
return -ENOENT;
}
lnet_md_unlink(md);
- LNET_UNLOCK();
- return 0;
+ lnet_res_unlock();
+ return 0;
}