/* must be called with resource lock held */
static int
-lnet_md_link(struct lnet_libmd *md, struct lnet_handle_eq eq_handle, int cpt)
+lnet_md_link(struct lnet_libmd *md, struct lnet_eq *eq, int cpt)
{
struct lnet_res_container *container = the_lnet.ln_md_containers[cpt];
* maybe there we shouldn't even allow LNET_EQ_NONE!)
* LASSERT (eq == NULL);
*/
- if (!LNetEQHandleIsInvalid(eq_handle)) {
- md->md_eq = lnet_handle2eq(&eq_handle);
-
- if (md->md_eq == NULL)
- return -ENOENT;
-
+ if (eq) {
+ md->md_eq = eq;
(*md->md_eq->eq_refs[cpt])++;
}
umd->max_size = lmd->md_max_size;
umd->options = lmd->md_options;
umd->user_ptr = lmd->md_user_ptr;
- lnet_eq2handle(&umd->eq_handle, lmd->md_eq);
}
static int
/**
* Create a memory descriptor and attach it to a ME
*
- * \param meh A handle for a ME to associate the new MD with.
+ * \param me An ME to associate the new MD with.
* \param umd Provides initial values for the user-visible parts of a MD.
* Other than its use for initialization, there is no linkage between this
* structure and the MD maintained by the LNet.
* a MD.
*/
int
-LNetMDAttach(struct lnet_handle_me meh, struct lnet_md umd,
+LNetMDAttach(struct lnet_me *me, struct lnet_md umd,
enum lnet_unlink unlink, struct lnet_handle_md *handle)
{
- struct list_head matches = LIST_HEAD_INIT(matches);
- struct list_head drops = LIST_HEAD_INIT(drops);
- struct lnet_me *me;
+ LIST_HEAD(matches);
+ LIST_HEAD(drops);
struct lnet_libmd *md;
int cpt;
int rc;
if (rc != 0)
goto out_free;
- cpt = lnet_cpt_of_cookie(meh.cookie);
+ cpt = me->me_cpt;
lnet_res_lock(cpt);
- me = lnet_handle2me(&meh);
- if (me == NULL)
- rc = -ENOENT;
- else if (me->me_md != NULL)
+ if (me->me_md)
rc = -EBUSY;
else
rc = lnet_md_link(md, umd.eq_handle, cpt);
if (rc != 0)
goto out_free;
+ if (md->md_length > LNET_MTU) {
+ CERROR("Invalid length: too big transfer size %u, %d max\n",
+ md->md_length, LNET_MTU);
+ rc = -EINVAL;
+ goto out_free;
+ }
+
cpt = lnet_res_lock_current();
rc = lnet_md_link(md, umd.eq_handle, cpt);
lnet_eq_enqueue_event(md->md_eq, &ev);
}
+ if (md->md_rspt_ptr != NULL)
+ lnet_detach_rsp_tracker(md, cpt);
+
lnet_md_unlink(md);
lnet_res_unlock(cpt);