Whamcloud - gitweb
LU-9679 modules: Use LIST_HEAD for declaring list_heads
[fs/lustre-release.git] / lnet / lnet / lib-ptl.c
index acba755..e8f7ef7 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -44,7 +44,7 @@ module_param(portal_rotor, int, 0644);
 MODULE_PARM_DESC(portal_rotor, "redirect PUTs to different cpu-partitions");
 
 static int
-lnet_ptl_match_type(unsigned int index, lnet_process_id_t match_id,
+lnet_ptl_match_type(unsigned int index, struct lnet_process_id match_id,
                    __u64 mbits, __u64 ignore_bits)
 {
        struct lnet_portal      *ptl = the_lnet.ln_portals[index];
@@ -136,14 +136,14 @@ lnet_ptl_disable_mt(struct lnet_portal *ptl, int cpt)
 }
 
 static int
-lnet_try_match_md(lnet_libmd_t *md,
+lnet_try_match_md(struct lnet_libmd *md,
                  struct lnet_match_info *info, struct lnet_msg *msg)
 {
        /* ALWAYS called holding the lnet_res_lock, and can't lnet_res_unlock;
         * lnet_match_blocked_msg() relies on this to avoid races */
        unsigned int    offset;
        unsigned int    mlength;
-       lnet_me_t       *me = md->md_me;
+       struct lnet_me  *me = md->md_me;
 
        /* MD exhausted */
        if (lnet_md_exhausted(md))
@@ -215,19 +215,19 @@ lnet_try_match_md(lnet_libmd_t *md,
 }
 
 static struct lnet_match_table *
-lnet_match2mt(struct lnet_portal *ptl, lnet_process_id_t id, __u64 mbits)
+lnet_match2mt(struct lnet_portal *ptl, struct lnet_process_id id, __u64 mbits)
 {
        if (LNET_CPT_NUMBER == 1)
                return ptl->ptl_mtables[0]; /* the only one */
 
        /* if it's a unique portal, return match-table hashed by NID */
        return lnet_ptl_is_unique(ptl) ?
-              ptl->ptl_mtables[lnet_cpt_of_nid(id.nid)] : NULL;
+              ptl->ptl_mtables[lnet_cpt_of_nid(id.nid, NULL)] : NULL;
 }
 
 struct lnet_match_table *
-lnet_mt_of_attach(unsigned int index, lnet_process_id_t id,
-                 __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos)
+lnet_mt_of_attach(unsigned int index, struct lnet_process_id id,
+                 __u64 mbits, __u64 ignore_bits, enum lnet_ins_pos pos)
 {
        struct lnet_portal      *ptl;
        struct lnet_match_table *mtable;
@@ -292,7 +292,7 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg)
 
        rotor = ptl->ptl_rotor++; /* get round-robin factor */
        if (portal_rotor == LNET_PTL_ROTOR_HASH_RT && routed)
-               cpt = lnet_cpt_of_nid(msg->msg_hdr.src_nid);
+               cpt = info->mi_cpt;
        else
                cpt = rotor % LNET_CPT_NUMBER;
 
@@ -356,7 +356,7 @@ lnet_mt_set_exhausted(struct lnet_match_table *mtable, int pos, int exhausted)
 
 struct list_head *
 lnet_mt_match_head(struct lnet_match_table *mtable,
-                  lnet_process_id_t id, __u64 mbits)
+                  struct lnet_process_id id, __u64 mbits)
 {
        struct lnet_portal *ptl = the_lnet.ln_portals[mtable->mt_portal];
 
@@ -376,8 +376,8 @@ lnet_mt_match_md(struct lnet_match_table *mtable,
                 struct lnet_match_info *info, struct lnet_msg *msg)
 {
        struct list_head        *head;
-       lnet_me_t               *me;
-       lnet_me_t               *tmp;
+       struct lnet_me          *me;
+       struct lnet_me          *tmp;
        int                     exhausted = 0;
        int                     rc;
 
@@ -584,7 +584,7 @@ lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg)
        mtable = lnet_mt_of_match(info, msg);
        lnet_res_lock(mtable->mt_cpt);
 
-       if (the_lnet.ln_shutdown) {
+       if (the_lnet.ln_state != LNET_STATE_RUNNING) {
                rc = LNET_MATCHMD_DROP;
                goto out1;
        }
@@ -637,7 +637,7 @@ lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg)
 }
 
 void
-lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md)
+lnet_ptl_detach_md(struct lnet_me *me, struct lnet_libmd *md)
 {
        LASSERT(me->me_md == md && md->md_me == me);
 
@@ -647,16 +647,16 @@ lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md)
 
 /* called with lnet_res_lock held */
 void
-lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
+lnet_ptl_attach_md(struct lnet_me *me, struct lnet_libmd *md,
                   struct list_head *matches, struct list_head *drops)
 {
-       struct lnet_portal      *ptl = the_lnet.ln_portals[me->me_portal];
+       struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal];
        struct lnet_match_table *mtable;
-       struct list_head        *head;
-       lnet_msg_t              *tmp;
-       lnet_msg_t              *msg;
-       int                     exhausted = 0;
-       int                     cpt;
+       struct list_head *head;
+       struct lnet_msg *tmp;
+       struct lnet_msg *msg;
+       int exhausted = 0;
+       int cpt;
 
        LASSERT(md->md_refcount == 0); /* a brand new MD */
 
@@ -676,13 +676,14 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
  again:
        list_for_each_entry_safe(msg, tmp, head, msg_list) {
                struct lnet_match_info  info;
-               lnet_hdr_t              *hdr;
+               struct lnet_hdr         *hdr;
                int                     rc;
 
                LASSERT(msg->msg_rx_delayed || head == &ptl->ptl_msg_stealing);
 
                hdr   = &msg->msg_hdr;
-               info.mi_id.nid  = hdr->src_nid;
+               /* Multi-Rail: Primary peer NID */
+               info.mi_id.nid  = msg->msg_initiator;
                info.mi_id.pid  = hdr->src_pid;
                info.mi_opc     = LNET_MD_OP_PUT;
                info.mi_portal  = hdr->msg.put.ptl_index;
@@ -753,7 +754,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl)
        LASSERT(list_empty(&ptl->ptl_msg_stealing));
        cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) {
                struct list_head *mhash;
-               lnet_me_t        *me;
+               struct lnet_me   *me;
                int               j;
 
                if (mtable->mt_mhash == NULL) /* uninitialized match-table */
@@ -764,7 +765,7 @@ lnet_ptl_cleanup(struct lnet_portal *ptl)
                for (j = 0; j < LNET_MT_HASH_SIZE + 1; j++) {
                        while (!list_empty(&mhash[j])) {
                                me = list_entry(mhash[j].next,
-                                               lnet_me_t, me_list);
+                                               struct lnet_me, me_list);
                                CERROR("Active ME %p on exit\n", me);
                                list_del(&me->me_list);
                                lnet_me_free(me);
@@ -919,7 +920,7 @@ int
 lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason)
 {
        struct lnet_portal      *ptl;
-       struct list_head        zombies = LIST_HEAD_INIT(zombies);
+       LIST_HEAD(zombies);
 
        if (portal < 0 || portal >= the_lnet.ln_nportals)
                return -EINVAL;
@@ -941,11 +942,11 @@ lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason)
                /* grab all messages which are on the NI passed in */
                list_for_each_entry_safe(msg, tmp, &ptl->ptl_msg_delayed,
                                         msg_list) {
-                       if (msg->msg_rxpeer->lp_ni == ni)
+                       if (msg->msg_txni == ni || msg->msg_rxni == ni)
                                list_move(&msg->msg_list, &zombies);
                }
        } else {
-               if (the_lnet.ln_shutdown)
+               if (the_lnet.ln_state != LNET_STATE_RUNNING)
                        CWARN("Active lazy portal %d on exit\n", portal);
                else
                        CDEBUG(D_NET, "clearing portal %d lazy\n", portal);