Whamcloud - gitweb
LU-10391 lnet: discard some peer_ni lookup functions 24/44624/7
authorMr NeilBrown <neilb@suse.de>
Thu, 16 Jun 2022 18:32:21 +0000 (14:32 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 11 Jul 2022 06:49:06 +0000 (06:49 +0000)
lnet_nid2peerni_locked(), lnet_peer_get_ni_locked(),
lnet_find_peer4(), and lnet_find_peer_ni_locked() each have few users
left and that can call be change to use alternate versions which take
'struct lnet_nid' rather than 'lnet_nid_t'.

So convert all those callers over, and discard the older functions.

Test-Parameters: trivial testlist=sanity-lnet
Test-Parameters: serverversion=2.12 serverdistro=el7.9 testlist=runtests
Test-Parameters: clientversion=2.12 testlist=runtests
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I9f0ebd0631c2e4160c3198aa37f16b45027bce3d
Reviewed-on: https://review.whamcloud.com/44624
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-lnet.h
lnet/lnet/api-ni.c
lnet/lnet/lib-move.c
lnet/lnet/peer.c
lnet/lnet/router.c
lnet/lnet/udsp.c

index fba7de0..c013a23 100644 (file)
@@ -975,19 +975,13 @@ struct lnet_peer_net *lnet_get_next_peer_net_locked(struct lnet_peer *lp,
 struct lnet_peer_ni *lnet_get_next_peer_ni_locked(struct lnet_peer *peer,
                                                  struct lnet_peer_net *peer_net,
                                                  struct lnet_peer_ni *prev);
-struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref,
-                                       int cpt);
 struct lnet_peer_ni *lnet_peerni_by_nid_locked(struct lnet_nid *nid,
                                               struct lnet_nid *pref,
                                               int cpt);
 struct lnet_peer_ni *lnet_nid2peerni_ex(struct lnet_nid *nid);
-struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp,
-                                            lnet_nid_t nid);
 struct lnet_peer_ni *lnet_peer_ni_get_locked(struct lnet_peer *lp,
                                             struct lnet_nid *nid);
-struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid);
 struct lnet_peer_ni *lnet_peer_ni_find_locked(struct lnet_nid *nid);
-struct lnet_peer *lnet_find_peer4(lnet_nid_t nid);
 struct lnet_peer *lnet_find_peer(struct lnet_nid *nid);
 void lnet_peer_net_added(struct lnet_net *net);
 void lnet_peer_primary_nid_locked(struct lnet_nid *nid,
index 1af3c56..1e34546 100644 (file)
@@ -4457,7 +4457,8 @@ LNetCtl(unsigned int cmd, void *arg)
                        return rc;
 
                mutex_lock(&the_lnet.ln_api_mutex);
-               lp = lnet_find_peer4(ping->ping_id.nid);
+               lnet_nid4_to_nid(ping->ping_id.nid, &nid);
+               lp = lnet_find_peer(&nid);
                if (lp) {
                        ping->ping_id.nid =
                                lnet_nid_to_nid4(&lp->lp_primary_nid);
@@ -4481,7 +4482,8 @@ LNetCtl(unsigned int cmd, void *arg)
                        return rc;
 
                mutex_lock(&the_lnet.ln_api_mutex);
-               lp = lnet_find_peer4(discover->ping_id.nid);
+               lnet_nid4_to_nid(discover->ping_id.nid, &nid);
+               lp = lnet_find_peer(&nid);
                if (lp) {
                        discover->ping_id.nid =
                                lnet_nid_to_nid4(&lp->lp_primary_nid);
@@ -4794,7 +4796,7 @@ static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
 
        if (nob < 8) {
                CERROR("%s: ping info too short %d\n",
-                      libcfs_id2str(id4), nob);
+                      libcfs_idstr(&id), nob);
                goto fail_ping_buffer_decref;
        }
 
@@ -4802,19 +4804,19 @@ static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
                lnet_swap_pinginfo(pbuf);
        } else if (pbuf->pb_info.pi_magic != LNET_PROTO_PING_MAGIC) {
                CERROR("%s: Unexpected magic %08x\n",
-                      libcfs_id2str(id4), pbuf->pb_info.pi_magic);
+                      libcfs_idstr(&id), pbuf->pb_info.pi_magic);
                goto fail_ping_buffer_decref;
        }
 
        if ((pbuf->pb_info.pi_features & LNET_PING_FEAT_NI_STATUS) == 0) {
                CERROR("%s: ping w/o NI status: 0x%x\n",
-                      libcfs_id2str(id4), pbuf->pb_info.pi_features);
+                      libcfs_idstr(&id), pbuf->pb_info.pi_features);
                goto fail_ping_buffer_decref;
        }
 
        if (nob < LNET_PING_INFO_SIZE(0)) {
                CERROR("%s: Short reply %d(%d min)\n",
-                      libcfs_id2str(id4),
+                      libcfs_idstr(&id),
                       nob, (int)LNET_PING_INFO_SIZE(0));
                goto fail_ping_buffer_decref;
        }
@@ -4824,7 +4826,7 @@ static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
 
        if (nob < LNET_PING_INFO_SIZE(n_ids)) {
                CERROR("%s: Short reply %d(%d expected)\n",
-                      libcfs_id2str(id4),
+                      libcfs_idstr(&id),
                       nob, (int)LNET_PING_INFO_SIZE(n_ids));
                goto fail_ping_buffer_decref;
        }
@@ -4846,21 +4848,23 @@ static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
 }
 
 static int
-lnet_discover(struct lnet_process_id id, __u32 force,
+lnet_discover(struct lnet_process_id id4, __u32 force,
              struct lnet_process_id __user *ids, int n_ids)
 {
        struct lnet_peer_ni *lpni;
        struct lnet_peer_ni *p;
        struct lnet_peer *lp;
        struct lnet_process_id *buf;
+       struct lnet_processid id;
        int cpt;
        int i;
        int rc;
 
        if (n_ids <= 0 ||
-           id.nid == LNET_NID_ANY)
+           id4.nid == LNET_NID_ANY)
                return -EINVAL;
 
+       lnet_pid4_to_pid(id4, &id);
        if (id.pid == LNET_PID_ANY)
                id.pid = LNET_PID_LUSTRE;
 
@@ -4876,7 +4880,7 @@ lnet_discover(struct lnet_process_id id, __u32 force,
                return -ENOMEM;
 
        cpt = lnet_net_lock_current();
-       lpni = lnet_nid2peerni_locked(id.nid, LNET_NID_ANY, cpt);
+       lpni = lnet_peerni_by_nid_locked(&id.nid, NULL, cpt);
        if (IS_ERR(lpni)) {
                rc = PTR_ERR(lpni);
                goto out;
@@ -4902,7 +4906,7 @@ lnet_discover(struct lnet_process_id id, __u32 force,
         * and lookup the lpni again
         */
        lnet_peer_ni_decref_locked(lpni);
-       lpni = lnet_find_peer_ni_locked(id.nid);
+       lpni = lnet_peer_ni_find_locked(&id.nid);
        if (!lpni) {
                rc = -ENOENT;
                goto out;
index 2fcfc79..93bf52b 100644 (file)
@@ -2106,7 +2106,7 @@ lnet_initiate_peer_discovery(struct lnet_peer_ni *lpni, struct lnet_msg *msg,
                return rc;
        }
 
-       new_lpni = lnet_find_peer_ni_locked(lnet_nid_to_nid4(&lpni->lpni_nid));
+       new_lpni = lnet_peer_ni_find_locked(&lpni->lpni_nid);
        if (!new_lpni) {
                lnet_peer_ni_decref_locked(lpni);
                return -ENOENT;
@@ -3035,7 +3035,7 @@ again:
                 * try to send it via non-multi-rail criteria
                 */
                if (!IS_ERR(src_lpni)) {
-                       /* Drop ref taken by lnet_nid2peerni_locked() */
+                       /* Drop ref taken by lnet_peerni_by_nid_locked() */
                        lnet_peer_ni_decref_locked(src_lpni);
                        src_lp = lpni->lpni_peer_net->lpn_peer;
                        if (lnet_peer_is_multi_rail(src_lp) &&
@@ -3780,7 +3780,7 @@ lnet_recover_peer_nis(void)
                                            true);
                        lnet_net_lock(0);
                        /*
-                        * lnet_find_peer_ni_locked() grabs a refcount for
+                        * lnet_peer_ni_find_locked() grabs a refcount for
                         * us. No need to take it explicitly.
                         */
                        lpni = lnet_peer_ni_find_locked(&nid);
@@ -3803,7 +3803,7 @@ lnet_recover_peer_nis(void)
                                spin_unlock(&lpni->lpni_lock);
                        }
 
-                       /* Drop the ref taken by lnet_find_peer_ni_locked() */
+                       /* Drop the ref taken by lnet_peer_ni_find_locked() */
                        lnet_peer_ni_decref_locked(lpni);
                        lnet_net_unlock(0);
                } else
index ae71e25..bad2843 100644 (file)
@@ -705,24 +705,6 @@ lnet_get_peer_ni_locked(struct lnet_peer_table *ptable, struct lnet_nid *nid)
 }
 
 struct lnet_peer_ni *
-lnet_find_peer_ni_locked(lnet_nid_t nid4)
-{
-       struct lnet_peer_ni *lpni;
-       struct lnet_peer_table *ptable;
-       int cpt;
-       struct lnet_nid nid;
-
-       lnet_nid4_to_nid(nid4, &nid);
-
-       cpt = lnet_nid_cpt_hash(&nid, LNET_CPT_NUMBER);
-
-       ptable = the_lnet.ln_peer_tables[cpt];
-       lpni = lnet_get_peer_ni_locked(ptable, &nid);
-
-       return lpni;
-}
-
-struct lnet_peer_ni *
 lnet_peer_ni_find_locked(struct lnet_nid *nid)
 {
        struct lnet_peer_ni *lpni;
@@ -738,24 +720,6 @@ lnet_peer_ni_find_locked(struct lnet_nid *nid)
 }
 
 struct lnet_peer_ni *
-lnet_peer_get_ni_locked(struct lnet_peer *lp, lnet_nid_t nid)
-{
-       struct lnet_peer_net *lpn;
-       struct lnet_peer_ni *lpni;
-
-       lpn = lnet_peer_get_net_locked(lp, LNET_NIDNET(nid));
-       if (!lpn)
-               return NULL;
-
-       list_for_each_entry(lpni, &lpn->lpn_peer_nis, lpni_peer_nis) {
-               if (lnet_nid_to_nid4(&lpni->lpni_nid) == nid)
-                       return lpni;
-       }
-
-       return NULL;
-}
-
-struct lnet_peer_ni *
 lnet_peer_ni_get_locked(struct lnet_peer *lp, struct lnet_nid *nid)
 {
        struct lnet_peer_net *lpn;
@@ -774,25 +738,6 @@ lnet_peer_ni_get_locked(struct lnet_peer *lp, struct lnet_nid *nid)
 }
 
 struct lnet_peer *
-lnet_find_peer4(lnet_nid_t nid)
-{
-       struct lnet_peer_ni *lpni;
-       struct lnet_peer *lp = NULL;
-       int cpt;
-
-       cpt = lnet_net_lock_current();
-       lpni = lnet_find_peer_ni_locked(nid);
-       if (lpni) {
-               lp = lpni->lpni_peer_net->lpn_peer;
-               lnet_peer_addref_locked(lp);
-               lnet_peer_ni_decref_locked(lpni);
-       }
-       lnet_net_unlock(cpt);
-
-       return lp;
-}
-
-struct lnet_peer *
 lnet_find_peer(struct lnet_nid *nid)
 {
        struct lnet_peer_ni *lpni;
@@ -1628,21 +1573,20 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp,
  * Call with the lnet_api_mutex held.
  */
 static int
-lnet_peer_add(lnet_nid_t nid4, unsigned int flags)
+lnet_peer_add(struct lnet_nid *nid, unsigned int flags)
 {
-       struct lnet_nid nid;
        struct lnet_peer *lp;
        struct lnet_peer_net *lpn;
        struct lnet_peer_ni *lpni;
        int rc = 0;
 
-       LASSERT(nid4 != LNET_NID_ANY);
+       LASSERT(nid);
 
        /*
         * No need for the lnet_net_lock here, because the
         * lnet_api_mutex is held.
         */
-       lpni = lnet_find_peer_ni_locked(nid4);
+       lpni = lnet_peer_ni_find_locked(nid);
        if (lpni) {
                /* A peer with this NID already exists. */
                lp = lpni->lpni_peer_net->lpn_peer;
@@ -1654,13 +1598,13 @@ lnet_peer_add(lnet_nid_t nid4, unsigned int flags)
                 * that an existing peer is being modified.
                 */
                if (lp->lp_state & LNET_PEER_CONFIGURED) {
-                       if (lnet_nid_to_nid4(&lp->lp_primary_nid) != nid4)
+                       if (!nid_same(&lp->lp_primary_nid, nid))
                                rc = -EEXIST;
                        else if ((lp->lp_state ^ flags) & LNET_PEER_MULTI_RAIL)
                                rc = -EPERM;
                        goto out;
                } else if (!(flags & LNET_PEER_CONFIGURED)) {
-                       if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid4) {
+                       if (nid_same(&lp->lp_primary_nid, nid)) {
                                rc = -EEXIST;
                                goto out;
                        }
@@ -1673,14 +1617,13 @@ lnet_peer_add(lnet_nid_t nid4, unsigned int flags)
 
        /* Create peer, peer_net, and peer_ni. */
        rc = -ENOMEM;
-       lnet_nid4_to_nid(nid4, &nid);
-       lp = lnet_peer_alloc(&nid);
+       lp = lnet_peer_alloc(nid);
        if (!lp)
                goto out;
-       lpn = lnet_peer_net_alloc(LNET_NID_NET(&nid));
+       lpn = lnet_peer_net_alloc(LNET_NID_NET(nid));
        if (!lpn)
                goto out_free_lp;
-       lpni = lnet_peer_ni_alloc(&nid);
+       lpni = lnet_peer_ni_alloc(nid);
        if (!lpni)
                goto out_free_lpn;
 
@@ -1692,7 +1635,7 @@ out_free_lp:
        LIBCFS_FREE(lp, sizeof(*lp));
 out:
        CDEBUG(D_NET, "peer %s NID flags %#x: %d\n",
-              libcfs_nid2str(nid4), flags, rc);
+              libcfs_nidstr(nid), flags, rc);
        return rc;
 }
 
@@ -1707,17 +1650,15 @@ out:
  *             non-multi-rail peer.
  */
 static int
-lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid4, unsigned int flags)
+lnet_peer_add_nid(struct lnet_peer *lp, struct lnet_nid *nid,
+                 unsigned int flags)
 {
        struct lnet_peer_net *lpn;
        struct lnet_peer_ni *lpni;
-       struct lnet_nid nid;
        int rc = 0;
 
        LASSERT(lp);
-       LASSERT(nid4 != LNET_NID_ANY);
-
-       lnet_nid4_to_nid(nid4, &nid);
+       LASSERT(nid);
 
        /* A configured peer can only be updated through configuration. */
        if (!(flags & LNET_PEER_CONFIGURED)) {
@@ -1743,7 +1684,7 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid4, unsigned int flags)
                goto out;
        }
 
-       lpni = lnet_find_peer_ni_locked(nid4);
+       lpni = lnet_peer_ni_find_locked(nid);
        if (lpni) {
                /*
                 * A peer_ni already exists. This is only a problem if
@@ -1772,14 +1713,14 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid4, unsigned int flags)
                        }
                        lnet_peer_del(lpni->lpni_peer_net->lpn_peer);
                        lnet_peer_ni_decref_locked(lpni);
-                       lpni = lnet_peer_ni_alloc(&nid);
+                       lpni = lnet_peer_ni_alloc(nid);
                        if (!lpni) {
                                rc = -ENOMEM;
                                goto out_free_lpni;
                        }
                }
        } else {
-               lpni = lnet_peer_ni_alloc(&nid);
+               lpni = lnet_peer_ni_alloc(nid);
                if (!lpni) {
                        rc = -ENOMEM;
                        goto out_free_lpni;
@@ -1790,9 +1731,9 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid4, unsigned int flags)
         * Get the peer_net. Check that we're not adding a second
         * peer_ni on a peer_net of a non-multi-rail peer.
         */
-       lpn = lnet_peer_get_net_locked(lp, LNET_NIDNET(nid4));
+       lpn = lnet_peer_get_net_locked(lp, LNET_NID_NET(nid));
        if (!lpn) {
-               lpn = lnet_peer_net_alloc(LNET_NIDNET(nid4));
+               lpn = lnet_peer_net_alloc(LNET_NID_NET(nid));
                if (!lpn) {
                        rc = -ENOMEM;
                        goto out_free_lpni;
@@ -1808,7 +1749,7 @@ out_free_lpni:
        lnet_peer_ni_decref_locked(lpni);
 out:
        CDEBUG(D_NET, "peer %s NID %s flags %#x: %d\n",
-              libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid4),
+              libcfs_nidstr(&lp->lp_primary_nid), libcfs_nidstr(nid),
               flags, rc);
        return rc;
 }
@@ -1819,16 +1760,16 @@ out:
  * Call with the lnet_api_mutex held.
  */
 static int
-lnet_peer_set_primary_nid(struct lnet_peer *lp, lnet_nid_t nid,
+lnet_peer_set_primary_nid(struct lnet_peer *lp, struct lnet_nid *nid,
                          unsigned int flags)
 {
        struct lnet_nid old = lp->lp_primary_nid;
        int rc = 0;
 
-       if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid)
+       if (nid_same(&lp->lp_primary_nid, nid))
                goto out;
 
-       lnet_nid4_to_nid(nid, &lp->lp_primary_nid);
+       lp->lp_primary_nid = *nid;
 
        rc = lnet_peer_add_nid(lp, nid, flags);
        if (rc) {
@@ -1837,7 +1778,7 @@ lnet_peer_set_primary_nid(struct lnet_peer *lp, lnet_nid_t nid,
        }
 out:
        CDEBUG(D_NET, "peer %s NID %s: %d\n",
-              libcfs_nidstr(&old), libcfs_nid2str(nid), rc);
+              libcfs_nidstr(&old), libcfs_nidstr(nid), rc);
 
        return rc;
 }
@@ -1918,16 +1859,20 @@ out:
  * being created/modified/deleted by a different thread.
  */
 int
-lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp)
+lnet_add_peer_ni(lnet_nid_t prim_nid4, lnet_nid_t nid4, bool mr, bool temp)
 {
+       struct lnet_nid prim_nid, nid;
        struct lnet_peer *lp = NULL;
        struct lnet_peer_ni *lpni;
        unsigned int flags = 0;
 
        /* The prim_nid must always be specified */
-       if (prim_nid == LNET_NID_ANY)
+       if (prim_nid4 == LNET_NID_ANY)
                return -EINVAL;
 
+       lnet_nid4_to_nid(prim_nid4, &prim_nid);
+       lnet_nid4_to_nid(nid4, &nid);
+
        if (!temp)
                flags = LNET_PEER_CONFIGURED;
 
@@ -1938,11 +1883,11 @@ lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp)
         * If nid isn't specified, we must create a new peer with
         * prim_nid as its primary nid.
         */
-       if (nid == LNET_NID_ANY)
-               return lnet_peer_add(prim_nid, flags);
+       if (nid4 == LNET_NID_ANY)
+               return lnet_peer_add(&prim_nid, flags);
 
        /* Look up the prim_nid, which must exist. */
-       lpni = lnet_find_peer_ni_locked(prim_nid);
+       lpni = lnet_peer_ni_find_locked(&prim_nid);
        if (!lpni)
                return -ENOENT;
        lnet_peer_ni_decref_locked(lpni);
@@ -1951,14 +1896,14 @@ lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp)
        /* Peer must have been configured. */
        if (!temp && !(lp->lp_state & LNET_PEER_CONFIGURED)) {
                CDEBUG(D_NET, "peer %s was not configured\n",
-                      libcfs_nid2str(prim_nid));
+                      libcfs_nidstr(&prim_nid));
                return -ENOENT;
        }
 
        /* Primary NID must match */
-       if (lnet_nid_to_nid4(&lp->lp_primary_nid) != prim_nid) {
+       if (!nid_same(&lp->lp_primary_nid, &prim_nid)) {
                CDEBUG(D_NET, "prim_nid %s is not primary for peer %s\n",
-                      libcfs_nid2str(prim_nid),
+                      libcfs_nidstr(&prim_nid),
                       libcfs_nidstr(&lp->lp_primary_nid));
                return -ENODEV;
        }
@@ -1966,11 +1911,11 @@ lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp)
        /* Multi-Rail flag must match. */
        if ((lp->lp_state ^ flags) & LNET_PEER_MULTI_RAIL) {
                CDEBUG(D_NET, "multi-rail state mismatch for peer %s\n",
-                      libcfs_nid2str(prim_nid));
+                      libcfs_nidstr(&prim_nid));
                return -EPERM;
        }
 
-       return lnet_peer_add_nid(lp, nid, flags);
+       return lnet_peer_add_nid(lp, &nid, flags);
 }
 
 /*
@@ -1985,24 +1930,26 @@ lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp)
  * being modified/deleted by a different thread.
  */
 int
-lnet_del_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid)
+lnet_del_peer_ni(lnet_nid_t prim_nid4, lnet_nid_t nid)
 {
        struct lnet_peer *lp;
        struct lnet_peer_ni *lpni;
-       unsigned flags;
+       unsigned int flags;
+       struct lnet_nid prim_nid;
 
-       if (prim_nid == LNET_NID_ANY)
+       if (prim_nid4 == LNET_NID_ANY)
                return -EINVAL;
+       lnet_nid4_to_nid(prim_nid4, &prim_nid);
 
-       lpni = lnet_find_peer_ni_locked(prim_nid);
+       lpni = lnet_peer_ni_find_locked(&prim_nid);
        if (!lpni)
                return -ENOENT;
        lnet_peer_ni_decref_locked(lpni);
        lp = lpni->lpni_peer_net->lpn_peer;
 
-       if (prim_nid != lnet_nid_to_nid4(&lp->lp_primary_nid)) {
+       if (!nid_same(&prim_nid, &lp->lp_primary_nid)) {
                CDEBUG(D_NET, "prim_nid %s is not primary for peer %s\n",
-                      libcfs_nid2str(prim_nid),
+                      libcfs_nidstr(&prim_nid),
                       libcfs_nidstr(&lp->lp_primary_nid));
                return -ENODEV;
        }
@@ -2011,7 +1958,7 @@ lnet_del_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid)
        if (lp->lp_rtr_refcount > 0) {
                lnet_net_unlock(LNET_LOCK_EX);
                CERROR("%s is a router. Can not be deleted\n",
-                      libcfs_nid2str(prim_nid));
+                      libcfs_nidstr(&prim_nid));
                return -EBUSY;
        }
        lnet_net_unlock(LNET_LOCK_EX);
@@ -2151,19 +2098,6 @@ lnet_peerni_by_nid_locked(struct lnet_nid *nid,
        return lpni;
 }
 
-struct lnet_peer_ni *
-lnet_nid2peerni_locked(lnet_nid_t nid4, lnet_nid_t pref4, int cpt)
-{
-       struct lnet_nid nid, pref;
-
-       lnet_nid4_to_nid(nid4, &nid);
-       lnet_nid4_to_nid(pref4, &pref);
-       if (pref4 == LNET_NID_ANY)
-               return lnet_peerni_by_nid_locked(&nid, NULL, cpt);
-       else
-               return lnet_peerni_by_nid_locked(&nid, &pref, cpt);
-}
-
 bool
 lnet_peer_gw_discovery(struct lnet_peer *lp)
 {
@@ -2979,7 +2913,8 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
        lnet_nid_t *curnis = NULL;
        struct lnet_ni_status *addnis = NULL;
        lnet_nid_t *delnis = NULL;
-       unsigned flags;
+       struct lnet_nid nid;
+       unsigned int flags;
        int ncurnis;
        int naddnis;
        int ndelnis;
@@ -3048,7 +2983,8 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
                                 * peer with the latest information we
                                 * received
                                 */
-                               lpni = lnet_find_peer_ni_locked(curnis[i]);
+                               lnet_nid4_to_nid(curnis[i], &nid);
+                               lpni = lnet_peer_ni_find_locked(&nid);
                                if (lpni) {
                                        lpni->lpni_ns_status = pbuf->pb_info.pi_ni[j].ns_status;
                                        lnet_peer_ni_decref_locked(lpni);
@@ -3070,7 +3006,8 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
                goto out;
 
        for (i = 0; i < naddnis; i++) {
-               rc = lnet_peer_add_nid(lp, addnis[i].ns_nid, flags);
+               lnet_nid4_to_nid(addnis[i].ns_nid, &nid);
+               rc = lnet_peer_add_nid(lp, &nid, flags);
                if (rc) {
                        CERROR("Error adding NID %s to peer %s: %d\n",
                               libcfs_nid2str(addnis[i].ns_nid),
@@ -3078,7 +3015,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
                        if (rc == -ENOMEM)
                                goto out;
                }
-               lpni = lnet_find_peer_ni_locked(addnis[i].ns_nid);
+               lpni = lnet_peer_ni_find_locked(&nid);
                if (lpni) {
                        lpni->lpni_ns_status = addnis[i].ns_status;
                        lnet_peer_ni_decref_locked(lpni);
@@ -3108,7 +3045,8 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
         * peer's lp_peer_nets list, and the peer NI for the primary NID should
         * be the first entry in its peer net's lpn_peer_nis list.
         */
-       lpni = lnet_find_peer_ni_locked(pbuf->pb_info.pi_ni[1].ns_nid);
+       lnet_nid4_to_nid(pbuf->pb_info.pi_ni[1].ns_nid, &nid);
+       lpni = lnet_peer_ni_find_locked(&nid);
        if (!lpni) {
                CERROR("Internal error: Failed to lookup peer NI for primary NID: %s\n",
                       libcfs_nid2str(pbuf->pb_info.pi_ni[1].ns_nid));
@@ -3303,8 +3241,8 @@ __must_hold(&lp->lp_lock)
 {
        struct lnet_ping_buffer *pbuf;
        struct lnet_peer_ni *lpni;
-       lnet_nid_t nid = LNET_NID_ANY;
-       unsigned flags;
+       struct lnet_nid nid;
+       unsigned int flags;
        int rc = 0;
 
        pbuf = lp->lp_data;
@@ -3361,9 +3299,9 @@ __must_hold(&lp->lp_lock)
                lnet_ping_buffer_decref(pbuf);
                goto out;
        }
-       nid = pbuf->pb_info.pi_ni[1].ns_nid;
+       lnet_nid4_to_nid(pbuf->pb_info.pi_ni[1].ns_nid, &nid);
        if (nid_is_lo0(&lp->lp_primary_nid)) {
-               rc = lnet_peer_set_primary_nid(lp, nid, flags);
+               rc = lnet_peer_set_primary_nid(lp, &nid, flags);
                if (rc)
                        lnet_ping_buffer_decref(pbuf);
                else
@@ -3376,19 +3314,19 @@ __must_hold(&lp->lp_lock)
         * to update the status of the nids that we currently have
         * recorded in that peer.
         */
-       } else if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid ||
+       } else if (nid_same(&lp->lp_primary_nid, &nid) ||
                   (lnet_is_nid_in_ping_info(lnet_nid_to_nid4(&lp->lp_primary_nid),
                                             &pbuf->pb_info) &&
                    lnet_is_discovery_disabled(lp))) {
                rc = lnet_peer_merge_data(lp, pbuf);
        } else {
-               lpni = lnet_find_peer_ni_locked(nid);
+               lpni = lnet_peer_ni_find_locked(&nid);
                if (!lpni || lp == lpni->lpni_peer_net->lpn_peer) {
-                       rc = lnet_peer_set_primary_nid(lp, nid, flags);
+                       rc = lnet_peer_set_primary_nid(lp, &nid, flags);
                        if (rc) {
                                CERROR("Primary NID error %s versus %s: %d\n",
                                       libcfs_nidstr(&lp->lp_primary_nid),
-                                      libcfs_nid2str(nid), rc);
+                                      libcfs_nidstr(&nid), rc);
                                lnet_ping_buffer_decref(pbuf);
                        } else {
                                rc = lnet_peer_merge_data(lp, pbuf);
@@ -3967,19 +3905,21 @@ void lnet_peer_discovery_stop(void)
 /* Debugging */
 
 void
-lnet_debug_peer(lnet_nid_t nid)
+lnet_debug_peer(lnet_nid_t nid4)
 {
        char                    *aliveness = "NA";
        struct lnet_peer_ni     *lp;
        int                     cpt;
+       struct lnet_nid nid;
 
-       cpt = lnet_cpt_of_nid(nid, NULL);
+       lnet_nid4_to_nid(nid4, &nid);
+       cpt = lnet_nid2cpt(&nid, NULL);
        lnet_net_lock(cpt);
 
-       lp = lnet_nid2peerni_locked(nid, LNET_NID_ANY, cpt);
+       lp = lnet_peerni_by_nid_locked(&nid, NULL, cpt);
        if (IS_ERR(lp)) {
                lnet_net_unlock(cpt);
-               CDEBUG(D_WARNING, "No peer %s\n", libcfs_nid2str(nid));
+               CDEBUG(D_WARNING, "No peer %s\n", libcfs_nidstr(&nid));
                return;
        }
 
@@ -4073,18 +4013,20 @@ int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk)
        struct lnet_peer_ni_credit_info *lpni_info;
        struct lnet_peer_ni *lpni;
        struct lnet_peer *lp;
-       lnet_nid_t nid;
+       lnet_nid_t nid4;
+       struct lnet_nid nid;
        __u32 size;
        int rc;
 
-       lp = lnet_find_peer4(cfg->prcfg_prim_nid);
+       lnet_nid4_to_nid(cfg->prcfg_prim_nid, &nid);
+       lp = lnet_find_peer(&nid);
 
        if (!lp) {
                rc = -ENOENT;
                goto out;
        }
 
-       size = sizeof(nid) + sizeof(*lpni_info) + sizeof(*lpni_stats)
+       size = sizeof(nid4) + sizeof(*lpni_info) + sizeof(*lpni_stats)
                + sizeof(*lpni_msg_stats) + sizeof(*lpni_hstats);
        size *= lp->lp_nnis;
        if (size > cfg->prcfg_size) {
@@ -4121,10 +4063,10 @@ int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk)
        while ((lpni = lnet_get_next_peer_ni_locked(lp, NULL, lpni)) != NULL) {
                if (!nid_is_nid4(&lpni->lpni_nid))
                        continue;
-               nid = lnet_nid_to_nid4(&lpni->lpni_nid);
-               if (copy_to_user(bulk, &nid, sizeof(nid)))
+               nid4 = lnet_nid_to_nid4(&lpni->lpni_nid);
+               if (copy_to_user(bulk, &nid4, sizeof(nid4)))
                        goto out_free_hstats;
-               bulk += sizeof(nid);
+               bulk += sizeof(nid4);
 
                memset(lpni_info, 0, sizeof(*lpni_info));
                snprintf(lpni_info->cr_aliveness, LNET_MAX_STR_LEN, "NA");
@@ -4244,12 +4186,13 @@ lnet_peer_ni_add_to_recoveryq_locked(struct lnet_peer_ni *lpni,
 
 /* Call with the ln_api_mutex held */
 void
-lnet_peer_ni_set_healthv(lnet_nid_t nid, int value, bool all)
+lnet_peer_ni_set_healthv(lnet_nid_t nid4, int value, bool all)
 {
        struct lnet_peer_table *ptable;
        struct lnet_peer *lp;
        struct lnet_peer_net *lpn;
        struct lnet_peer_ni *lpni;
+       struct lnet_nid nid;
        int lncpt;
        int cpt;
        time64_t now;
@@ -4257,11 +4200,12 @@ lnet_peer_ni_set_healthv(lnet_nid_t nid, int value, bool all)
        if (the_lnet.ln_state != LNET_STATE_RUNNING)
                return;
 
+       lnet_nid4_to_nid(nid4, &nid);
        now = ktime_get_seconds();
 
        if (!all) {
                lnet_net_lock(LNET_LOCK_EX);
-               lpni = lnet_find_peer_ni_locked(nid);
+               lpni = lnet_peer_ni_find_locked(&nid);
                if (!lpni) {
                        lnet_net_unlock(LNET_LOCK_EX);
                        return;
index 03502f3..c40b031 100644 (file)
@@ -1237,8 +1237,7 @@ rescan:
                spin_unlock(&rtr->lp_lock);
 
                /* find the peer_ni associated with the primary NID */
-               lpni = lnet_peer_get_ni_locked(
-                       rtr, lnet_nid_to_nid4(&rtr->lp_primary_nid));
+               lpni = lnet_peer_ni_get_locked(rtr, &rtr->lp_primary_nid);
                if (!lpni) {
                        CDEBUG(D_NET, "Expected to find an lpni for %s, but non found\n",
                               libcfs_nidstr(&rtr->lp_primary_nid));
@@ -1725,25 +1724,27 @@ lnet_notify_peer_down(struct lnet_ni *ni, struct lnet_nid *nid)
  * when: notificaiton time.
  */
 int
-lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset,
+lnet_notify(struct lnet_ni *ni, lnet_nid_t nid4, bool alive, bool reset,
            time64_t when)
 {
        struct lnet_peer_ni *lpni = NULL;
        struct lnet_route *route;
        struct lnet_peer *lp;
        time64_t now = ktime_get_seconds();
+       struct lnet_nid nid;
        int cpt;
 
+       lnet_nid4_to_nid(nid4, &nid);
        LASSERT(!in_interrupt());
 
        CDEBUG(D_NET, "%s notifying %s: %s\n",
               (ni == NULL) ? "userspace" : libcfs_nidstr(&ni->ni_nid),
-              libcfs_nid2str(nid), alive ? "up" : "down");
+              libcfs_nidstr(&nid), alive ? "up" : "down");
 
        if (ni != NULL &&
-           LNET_NID_NET(&ni->ni_nid) != LNET_NIDNET(nid)) {
+           LNET_NID_NET(&ni->ni_nid) != LNET_NID_NET(&nid)) {
                CWARN("Ignoring notification of %s %s by %s (different net)\n",
-                     libcfs_nid2str(nid), alive ? "birth" : "death",
+                     libcfs_nidstr(&nid), alive ? "birth" : "death",
                      libcfs_nidstr(&ni->ni_nid));
                return -EINVAL;
        }
@@ -1752,7 +1753,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset,
        if (when > now) {
                CWARN("Ignoring prediction from %s of %s %s %lld seconds in the future\n",
                        ni ? libcfs_nidstr(&ni->ni_nid) :  "userspace",
-                       libcfs_nid2str(nid), alive ? "up" : "down", when - now);
+                       libcfs_nidstr(&nid), alive ? "up" : "down", when - now);
                return -EINVAL;
        }
 
@@ -1770,11 +1771,11 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset,
                return -ESHUTDOWN;
        }
 
-       lpni = lnet_find_peer_ni_locked(nid);
+       lpni = lnet_peer_ni_find_locked(&nid);
        if (lpni == NULL) {
                /* nid not found */
                lnet_net_unlock(0);
-               CDEBUG(D_NET, "%s not found\n", libcfs_nid2str(nid));
+               CDEBUG(D_NET, "%s not found\n", libcfs_nidstr(&nid));
                return 0;
        }
 
index 08c1a7f..bce643b 100644 (file)
@@ -1052,17 +1052,19 @@ lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info)
 {
        struct lnet_ni *ni;
        struct lnet_peer_ni *lpni;
+       struct lnet_nid nid;
 
        lnet_net_lock(0);
+       lnet_nid4_to_nid(info->cud_nid, &nid);
        if (!info->cud_peer) {
-               ni = lnet_nid2ni_locked(info->cud_nid, 0);
+               ni = lnet_nid_to_ni_locked(&nid, 0);
                if (ni)
                        lnet_udsp_get_ni_info(info, ni);
        } else {
-               lpni = lnet_find_peer_ni_locked(info->cud_nid);
+               lpni = lnet_peer_ni_find_locked(&nid);
                if (!lpni) {
                        CDEBUG(D_NET, "nid %s is not found\n",
-                              libcfs_nid2str(info->cud_nid));
+                              libcfs_nidstr(&nid));
                } else {
                        lnet_udsp_get_peer_info(info, lpni);
                        lnet_peer_ni_decref_locked(lpni);