Whamcloud - gitweb
LU-13004 modules: replace lnet_kiov_t with struct bio_vec
[fs/lustre-release.git] / lnet / lnet / lib-md.c
index 7737744..b7b0939 100644 (file)
@@ -132,7 +132,7 @@ lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
        /*
         * There are three cases to handle:
-        *  1. The MD is using lnet_kiov_t
+        *  1. The MD is using struct bio_vec
         *  2. The MD is using struct kvec
         *  3. Contiguous buffer allocated via vmalloc
         *
@@ -147,10 +147,10 @@ lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
         * DMAed.
         */
        if ((md->md_options & LNET_MD_KIOV) != 0) {
-               lnet_kiov_t *kiov = md->md_iov.kiov;
+               struct bio_vec *kiov = md->md_iov.kiov;
 
-               while (offset >= kiov->kiov_len) {
-                       offset -= kiov->kiov_len;
+               while (offset >= kiov->bv_len) {
+                       offset -= kiov->bv_len;
                        niov--;
                        kiov++;
                        if (niov == 0) {
@@ -160,7 +160,7 @@ lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
                }
 
                cpt = cfs_cpt_of_node(lnet_cpt_table(),
-                               page_to_nid(kiov->kiov_page));
+                               page_to_nid(kiov->bv_page));
        } else {
                struct kvec *iov = md->md_iov.iov;
                unsigned long vaddr;
@@ -239,11 +239,11 @@ lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
 
                for (i = 0; i < (int)niov; i++) {
                        /* We take the page pointer on trust */
-                       if (lmd->md_iov.kiov[i].kiov_offset +
-                           lmd->md_iov.kiov[i].kiov_len > PAGE_SIZE)
+                       if (lmd->md_iov.kiov[i].bv_offset +
+                           lmd->md_iov.kiov[i].bv_len > PAGE_SIZE)
                                return -EINVAL; /* invalid length */
 
-                       total_length += lmd->md_iov.kiov[i].kiov_len;
+                       total_length += lmd->md_iov.kiov[i].bv_len;
                }
 
                lmd->md_length = total_length;
@@ -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);