Whamcloud - gitweb
LU-10391 lnet: remove 'fatal' arg from lnet_{sock_}connect
[fs/lustre-release.git] / lnet / lnet / lib-md.c
index 7737744..53a8557 100644 (file)
@@ -269,7 +269,7 @@ lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
 
 /* 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];
 
@@ -285,12 +285,8 @@ lnet_md_link(struct lnet_libmd *md, struct lnet_handle_eq eq_handle, int 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])++;
        }
 
@@ -318,7 +314,6 @@ lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd)
        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
@@ -335,10 +330,6 @@ lnet_md_validate(struct lnet_md *umd)
                CERROR("Invalid option: too many fragments %u, %d max\n",
                       umd->length, LNET_MAX_IOV);
                return -EINVAL;
-       } else if (umd->length > LNET_MTU) {
-               CERROR("Invalid length: too big fragment size %u, %d max\n",
-                      umd->length, LNET_MTU);
-               return -EINVAL;
        }
 
        return 0;
@@ -347,7 +338,7 @@ lnet_md_validate(struct lnet_md *umd)
 /**
  * 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.
@@ -370,12 +361,11 @@ lnet_md_validate(struct lnet_md *umd)
  * 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;
@@ -398,14 +388,11 @@ LNetMDAttach(struct lnet_handle_me meh, struct lnet_md umd,
        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);
@@ -476,6 +463,13 @@ LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink,
        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);
@@ -553,6 +547,9 @@ LNetMDUnlink(struct lnet_handle_md mdh)
                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);