Whamcloud - gitweb
LU-10391 lnet: change lpni_nid in lnet_peer_ni to lnet_nid 01/42101/13
authorMr NeilBrown <neilb@suse.de>
Mon, 6 Apr 2020 06:31:55 +0000 (16:31 +1000)
committerOleg Drokin <green@whamcloud.com>
Tue, 31 Aug 2021 05:19:30 +0000 (05:19 +0000)
lpni_nid in 'struct lnet_peer_ni' is converted to 'struct lnet_nid'
and various supporting functions updated.

Test-Parameters: trivial
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: I7a99f758b600a0dd0668edd368663ff65f603486
Reviewed-on: https://review.whamcloud.com/42101
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-types.h
lnet/lnet/api-ni.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/net_fault.c
lnet/lnet/peer.c
lnet/lnet/router.c
lnet/lnet/router_proc.c
lnet/lnet/udsp.c

index ecac958..30b87c7 100644 (file)
@@ -499,9 +499,14 @@ lnet_ni_alloc_w_cpt_array(struct lnet_net *net, __u32 *cpts, __u32 ncpts,
                          char *iface);
 
 static inline int
-lnet_nid2peerhash(lnet_nid_t nid)
+lnet_nid2peerhash(struct lnet_nid *nid)
 {
-       return hash_long(nid, LNET_PEER_HASH_BITS);
+       u32 h = 0;
+       int i;
+
+       for (i = 0; i < 4; i++)
+               h = hash_32(nid->nid_addr[i]^h, 32);
+       return hash_32(LNET_NID_NET(nid) ^ h, LNET_PEER_HASH_BITS);
 }
 
 static inline struct list_head *
@@ -516,7 +521,7 @@ extern const struct lnet_lnd the_lolnd;
 extern int avoid_asym_router_failure;
 
 extern unsigned int lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number);
-extern int lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni);
+extern int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni);
 extern int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 extern struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 extern struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
@@ -973,7 +978,8 @@ lnet_peer_ni_is_configured(struct lnet_peer_ni *lpni)
 static inline bool
 lnet_peer_ni_is_primary(struct lnet_peer_ni *lpni)
 {
-       return lpni->lpni_nid == lpni->lpni_peer_net->lpn_peer->lp_primary_nid;
+       return lnet_nid_to_nid4(&lpni->lpni_nid) ==
+                       lpni->lpni_peer_net->lpn_peer->lp_primary_nid;
 }
 
 bool lnet_peer_is_uptodate(struct lnet_peer *lp);
index 3fa482a..6946e90 100644 (file)
@@ -597,7 +597,7 @@ struct lnet_peer_ni {
        /* network peer is on */
        struct lnet_net         *lpni_net;
        /* peer's NID */
-       lnet_nid_t              lpni_nid;
+       struct lnet_nid         lpni_nid;
        /* # refs */
        struct kref             lpni_kref;
        /* health value for the peer */
index 9ad1f84..fb2fbdf 100644 (file)
@@ -1527,9 +1527,11 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
 }
 
 int
-lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni)
+lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni)
 {
        struct lnet_net *net;
+       /* FIXME handle long-addr nid */
+       lnet_nid_t nid4 = lnet_nid_to_nid4(nid);
 
        /* must called with hold of lnet_net_lock */
        if (LNET_CPT_NUMBER == 1)
@@ -1544,34 +1546,36 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni)
         */
        if (ni != NULL) {
                if (ni->ni_cpts != NULL)
-                       return ni->ni_cpts[lnet_nid_cpt_hash(nid,
+                       return ni->ni_cpts[lnet_nid_cpt_hash(nid4,
                                                             ni->ni_ncpts)];
                else
-                       return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
+                       return lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER);
        }
 
        /* no NI provided so look at the net */
-       net = lnet_get_net_locked(LNET_NIDNET(nid));
+       net = lnet_get_net_locked(LNET_NID_NET(nid));
 
        if (net != NULL && net->net_cpts != NULL) {
-               return net->net_cpts[lnet_nid_cpt_hash(nid, net->net_ncpts)];
+               return net->net_cpts[lnet_nid_cpt_hash(nid4, net->net_ncpts)];
        }
 
-       return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
+       return lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER);
 }
 
 int
-lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni)
+lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
 {
        int     cpt;
        int     cpt2;
+       struct lnet_nid nid;
 
        if (LNET_CPT_NUMBER == 1)
                return 0; /* the only one */
 
+       lnet_nid4_to_nid(nid4, &nid);
        cpt = lnet_net_lock_current();
 
-       cpt2 = lnet_cpt_of_nid_locked(nid, ni);
+       cpt2 = lnet_cpt_of_nid_locked(&nid, ni);
 
        lnet_net_unlock(cpt);
 
@@ -1608,18 +1612,16 @@ lnet_islocalnet(__u32 net_id)
 }
 
 struct lnet_ni  *
-lnet_nid2ni_locked(lnet_nid_t nid4, int cpt)
+lnet_nid_to_ni_locked(struct lnet_nid *nid, int cpt)
 {
-       struct lnet_net *net;
+       struct lnet_net  *net;
        struct lnet_ni *ni;
-       struct lnet_nid nid;
 
        LASSERT(cpt != LNET_LOCK_EX);
-       lnet_nid4_to_nid(nid4, &nid);
 
        list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-                       if (nid_same(&ni->ni_nid, &nid))
+                       if (nid_same(&ni->ni_nid, nid))
                                return ni;
                }
        }
@@ -1627,13 +1629,25 @@ lnet_nid2ni_locked(lnet_nid_t nid4, int cpt)
        return NULL;
 }
 
+struct lnet_ni  *
+lnet_nid2ni_locked(lnet_nid_t nid4, int cpt)
+{
+       struct lnet_nid nid;
+
+       lnet_nid4_to_nid(nid4, &nid);
+       return lnet_nid_to_ni_locked(&nid, cpt);
+}
+
 struct lnet_ni *
-lnet_nid2ni_addref(lnet_nid_t nid)
+lnet_nid2ni_addref(lnet_nid_t nid4)
 {
        struct lnet_ni *ni;
+       struct lnet_nid nid;
+
+       lnet_nid4_to_nid(nid4, &nid);
 
        lnet_net_lock(0);
-       ni = lnet_nid2ni_locked(nid, 0);
+       ni = lnet_nid_to_ni_locked(&nid, 0);
        if (ni)
                lnet_ni_addref_locked(ni, 0);
        lnet_net_unlock(0);
@@ -1642,6 +1656,21 @@ lnet_nid2ni_addref(lnet_nid_t nid)
 }
 EXPORT_SYMBOL(lnet_nid2ni_addref);
 
+struct lnet_ni *
+lnet_nid_to_ni_addref(struct lnet_nid *nid)
+{
+       struct lnet_ni *ni;
+
+       lnet_net_lock(0);
+       ni = lnet_nid_to_ni_locked(nid, 0);
+       if (ni)
+               lnet_ni_addref_locked(ni, 0);
+       lnet_net_unlock(0);
+
+       return ni;
+}
+EXPORT_SYMBOL(lnet_nid_to_ni_addref);
+
 int
 lnet_islocalnid(lnet_nid_t nid)
 {
@@ -3830,7 +3859,7 @@ lnet_get_peer_ni_recovery_list(struct lnet_ioctl_recovery_list *list)
 
        lnet_net_lock(LNET_LOCK_EX);
        list_for_each_entry(lpni, &the_lnet.ln_mt_peerNIRecovq, lpni_recovery) {
-               list->rlst_nid_array[i] = lpni->lpni_nid;
+               list->rlst_nid_array[i] = lnet_nid_to_nid4(&lpni->lpni_nid);
                i++;
                if (i >= LNET_MAX_SHOW_NUM_NID)
                        break;
@@ -4729,7 +4758,7 @@ lnet_discover(struct lnet_process_id id, __u32 force,
        p = NULL;
        while ((p = lnet_get_next_peer_ni_locked(lp, NULL, p)) != NULL) {
                buf[i].pid = id.pid;
-               buf[i].nid = p->lpni_nid;
+               buf[i].nid = lnet_nid_to_nid4(&p->lpni_nid);
                if (++i >= n_ids)
                        break;
        }
index 957c8ba..9479cfa 100644 (file)
@@ -759,7 +759,7 @@ lnet_ni_eager_recv(struct lnet_ni *ni, struct lnet_msg *msg)
        if (rc != 0) {
                CERROR("recv from %s / send to %s aborted: "
                       "eager_recv failed %d\n",
-                      libcfs_nid2str(msg->msg_rxpeer->lpni_nid),
+                      libcfs_nidstr(&msg->msg_rxpeer->lpni_nid),
                       libcfs_id2str(msg->msg_target), rc);
                LASSERT(rc < 0); /* required by my callers */
        }
@@ -843,8 +843,7 @@ lnet_post_send_locked(struct lnet_msg *msg, int do_send)
 
        /* can't get here if we're sending to the loopback interface */
        if (the_lnet.ln_loni)
-               LASSERT(lp->lpni_nid !=
-                       lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
+               LASSERT(!nid_same(&lp->lpni_nid, &the_lnet.ln_loni->ni_nid));
 
        /* NB 'lp' is always the next hop */
        if ((msg->msg_target.pid & LNET_PID_USERFLAG) == 0 &&
@@ -1338,8 +1337,8 @@ lnet_select_peer_ni(struct lnet_ni *best_ni, lnet_nid_t dst_nid,
 
                if (best_lpni)
                        CDEBUG(D_NET, "n:[%s, %s] h:[%d, %d] p:[%d, %d] c:[%d, %d] s:[%d, %d]\n",
-                               libcfs_nid2str(lpni->lpni_nid),
-                               libcfs_nid2str(best_lpni->lpni_nid),
+                               libcfs_nidstr(&lpni->lpni_nid),
+                               libcfs_nidstr(&best_lpni->lpni_nid),
                                lpni_healthv, best_lpni_healthv,
                                lpni_sel_prio, best_sel_prio,
                                lpni->lpni_txcredits, best_lpni_credits,
@@ -1408,7 +1407,7 @@ select_lpni:
        }
 
        CDEBUG(D_NET, "sd_best_lpni = %s\n",
-              libcfs_nid2str(best_lpni->lpni_nid));
+              libcfs_nidstr(&best_lpni->lpni_nid));
 
        return best_lpni;
 }
@@ -1848,7 +1847,7 @@ lnet_handle_send(struct lnet_send_data *sd)
               best_ni->ni_seq, best_ni->ni_net->net_seq,
               atomic_read(&best_ni->ni_tx_credits),
               best_ni->ni_sel_priority,
-              libcfs_nid2str(best_lpni->lpni_nid),
+              libcfs_nidstr(&best_lpni->lpni_nid),
               best_lpni->lpni_seq, best_lpni->lpni_peer_net->lpn_seq,
               best_lpni->lpni_txcredits,
               best_lpni->lpni_sel_priority);
@@ -1868,7 +1867,7 @@ lnet_handle_send(struct lnet_send_data *sd)
         * the configuration has changed. We don't have a hold on the best_ni
         * yet, and it may have vanished.
         */
-       cpt2 = lnet_cpt_of_nid_locked(best_lpni->lpni_nid, best_ni);
+       cpt2 = lnet_cpt_of_nid_locked(&best_lpni->lpni_nid, best_ni);
        if (sd->sd_cpt != cpt2) {
                __u32 seq = lnet_get_dlc_seq_locked();
                lnet_net_unlock(sd->sd_cpt);
@@ -1899,7 +1898,8 @@ lnet_handle_send(struct lnet_send_data *sd)
         * what was originally set in the target or it will be the NID of
         * a router if this message should be routed
         */
-       msg->msg_target.nid = msg->msg_txpeer->lpni_nid;
+       /* FIXME handle large-addr nids */
+       msg->msg_target.nid = lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid);
 
        /*
         * lnet_msg_commit assigns the correct cpt to the message, which
@@ -1930,13 +1930,16 @@ lnet_handle_send(struct lnet_send_data *sd)
                 * lnet_select_pathway() function and is never changed.
                 * It's safe to use it here.
                 */
-               msg->msg_hdr.dest_nid = cpu_to_le64(final_dst_lpni->lpni_nid);
+               /* FIXME handle large-addr nid */
+               msg->msg_hdr.dest_nid =
+                       cpu_to_le64(lnet_nid_to_nid4(&final_dst_lpni->lpni_nid));
        } else {
                /*
                 * if we're not routing set the dest_nid to the best peer
                 * ni NID that we picked earlier in the algorithm.
                 */
-               msg->msg_hdr.dest_nid = cpu_to_le64(msg->msg_txpeer->lpni_nid);
+               msg->msg_hdr.dest_nid =
+                       cpu_to_le64(lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid));
        }
 
        /*
@@ -1946,7 +1949,8 @@ lnet_handle_send(struct lnet_send_data *sd)
        if (msg->msg_md) {
                rspt = msg->msg_md->md_rspt_ptr;
                if (rspt) {
-                       rspt->rspt_next_hop_nid = msg->msg_txpeer->lpni_nid;
+                       rspt->rspt_next_hop_nid =
+                               lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid);
                        CDEBUG(D_NET, "rspt_next_hop_nid = %s\n",
                               libcfs_nid2str(rspt->rspt_next_hop_nid));
                }
@@ -1961,7 +1965,7 @@ lnet_handle_send(struct lnet_send_data *sd)
                       libcfs_nid2str(sd->sd_src_nid),
                       libcfs_nid2str(msg->msg_hdr.dest_nid),
                       libcfs_nid2str(sd->sd_dst_nid),
-                      libcfs_nid2str(msg->msg_txpeer->lpni_nid),
+                      libcfs_nidstr(&msg->msg_txpeer->lpni_nid),
                       libcfs_nid2str(sd->sd_rtr_nid),
                       lnet_msgtyp2str(msg->msg_type), msg->msg_retry_count);
 
@@ -1976,7 +1980,7 @@ lnet_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, struct lnet_ni *lni,
            !lnet_msg_is_response(msg) && lpni->lpni_pref_nnids == 0) {
                CDEBUG(D_NET, "Setting preferred local NID %s on NMR peer %s\n",
                       libcfs_nidstr(&lni->ni_nid),
-                      libcfs_nid2str(lpni->lpni_nid));
+                      libcfs_nidstr(&lpni->lpni_nid));
                lnet_peer_ni_set_non_mr_pref_nid(
                        lpni, lnet_nid_to_nid4(&lni->ni_nid));
        }
@@ -2031,8 +2035,8 @@ lnet_handle_spec_local_mr_dst(struct lnet_send_data *sd)
        }
 
        if (sd->sd_best_lpni &&
-           sd->sd_best_lpni->lpni_nid ==
-           lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid))
+           nid_same(&sd->sd_best_lpni->lpni_nid,
+                     &the_lnet.ln_loni->ni_nid))
                return lnet_handle_lo_send(sd);
        else if (sd->sd_best_lpni)
                return lnet_handle_send(sd);
@@ -2100,7 +2104,7 @@ lnet_initiate_peer_discovery(struct lnet_peer_ni *lpni, struct lnet_msg *msg,
                return rc;
        }
 
-       new_lpni = lnet_find_peer_ni_locked(lpni->lpni_nid);
+       new_lpni = lnet_find_peer_ni_locked(lnet_nid_to_nid4(&lpni->lpni_nid));
        if (!new_lpni) {
                lnet_peer_ni_decref_locked(lpni);
                return -ENOENT;
@@ -2554,7 +2558,7 @@ lnet_select_preferred_best_ni(struct lnet_send_data *sd)
                /* If there is no best_ni we don't have a route */
                if (!best_ni) {
                        CERROR("no path to %s from net %s\n",
-                               libcfs_nid2str(best_lpni->lpni_nid),
+                               libcfs_nidstr(&best_lpni->lpni_nid),
                                libcfs_net2str(best_lpni->lpni_net->net_id));
                        return -EHOSTUNREACH;
                }
@@ -2680,8 +2684,8 @@ lnet_handle_any_mr_dsta(struct lnet_send_data *sd)
                 * network
                 */
                if (sd->sd_best_lpni &&
-                   sd->sd_best_lpni->lpni_nid ==
-                   lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid)) {
+                   nid_same(&sd->sd_best_lpni->lpni_nid,
+                            &the_lnet.ln_loni->ni_nid)) {
                        /*
                         * in case we initially started with a routed
                         * destination, let's reset to local
@@ -3722,7 +3726,7 @@ lnet_recover_peer_nis(void)
                        LIBCFS_ALLOC(ev_info, sizeof(*ev_info));
                        if (!ev_info) {
                                CERROR("out of memory. Can't recover %s\n",
-                                      libcfs_nid2str(lpni->lpni_nid));
+                                      libcfs_nidstr(&lpni->lpni_nid));
                                spin_lock(&lpni->lpni_lock);
                                lpni->lpni_state &= ~LNET_PEER_NI_RECOVERY_PENDING;
                                spin_unlock(&lpni->lpni_lock);
@@ -3732,7 +3736,8 @@ lnet_recover_peer_nis(void)
                        /* look at the comments in lnet_recover_local_nis() */
                        mdh = lpni->lpni_recovery_ping_mdh;
                        LNetInvalidateMDHandle(&lpni->lpni_recovery_ping_mdh);
-                       nid = lpni->lpni_nid;
+                       /* FIXME handle large-addr nid */
+                       nid = lnet_nid_to_nid4(&lpni->lpni_nid);
                        lnet_net_lock(0);
                        list_del_init(&lpni->lpni_recovery);
                        lnet_peer_ni_decref_locked(lpni);
index b20690b..607001b 100644 (file)
@@ -832,7 +832,7 @@ lnet_health_check(struct lnet_msg *msg)
 
        CDEBUG(D_NET, "health check: %s->%s: %s: %s\n",
               libcfs_nidstr(&ni->ni_nid),
-              (lo) ? "self" : libcfs_nid2str(lpni->lpni_nid),
+              (lo) ? "self" : libcfs_nidstr(&lpni->lpni_nid),
               lnet_msgtyp2str(msg->msg_type),
               lnet_health_error2str(hstatus));
 
index dde84cf..efe69d9 100644 (file)
@@ -683,7 +683,7 @@ delayed_msg_process(struct list_head *msg_list, bool drop)
                        ni = msg->msg_txni;
                        CDEBUG(D_NET, "TRACE: msg %p %s -> %s : %s\n", msg,
                               libcfs_nidstr(&ni->ni_nid),
-                              libcfs_nid2str(msg->msg_txpeer->lpni_nid),
+                              libcfs_nidstr(&msg->msg_txpeer->lpni_nid),
                               lnet_msgtyp2str(msg->msg_type));
                        lnet_ni_send(ni, msg);
                        continue;
index bc6e250..a2b339b 100644 (file)
@@ -65,7 +65,7 @@ lnet_peer_net_added(struct lnet_net *net)
        list_for_each_entry_safe(lpni, tmp, &the_lnet.ln_remote_peer_ni_list,
                                 lpni_on_remote_peer_ni_list) {
 
-               if (LNET_NIDNET(lpni->lpni_nid) == net->net_id) {
+               if (LNET_NID_NET(&lpni->lpni_nid) == net->net_id) {
                        lpni->lpni_net = net;
 
                        spin_lock(&lpni->lpni_lock);
@@ -178,7 +178,7 @@ lnet_peer_ni_alloc(lnet_nid_t nid)
        else
                lpni->lpni_ns_status = LNET_NI_STATUS_UP;
        lpni->lpni_ping_feats = LNET_PING_FEAT_INVAL;
-       lpni->lpni_nid = nid;
+       lnet_nid4_to_nid(nid, &lpni->lpni_nid);
        lpni->lpni_cpt = cpt;
        atomic_set(&lpni->lpni_healthv, LNET_MAX_HEALTH_VALUE);
 
@@ -202,7 +202,7 @@ lnet_peer_ni_alloc(lnet_nid_t nid)
                              &the_lnet.ln_remote_peer_ni_list);
        }
 
-       CDEBUG(D_NET, "%p nid %s\n", lpni, libcfs_nid2str(lpni->lpni_nid));
+       CDEBUG(D_NET, "%p nid %s\n", lpni, libcfs_nidstr(&lpni->lpni_nid));
 
        return lpni;
 }
@@ -379,7 +379,7 @@ lnet_peer_detach_peer_ni_locked(struct lnet_peer_ni *lpni)
        }
        CDEBUG(D_NET, "peer %s NID %s\n",
                libcfs_nid2str(lp->lp_primary_nid),
-               libcfs_nid2str(lpni->lpni_nid));
+               libcfs_nidstr(&lpni->lpni_nid));
 }
 
 /* called with lnet_net_lock LNET_LOCK_EX held */
@@ -391,7 +391,7 @@ lnet_peer_ni_del_locked(struct lnet_peer_ni *lpni, bool force)
        /* don't remove a peer_ni if it's also a gateway */
        if (lnet_isrouter(lpni) && !force) {
                CERROR("Peer NI %s is a gateway. Can not delete it\n",
-                      libcfs_nid2str(lpni->lpni_nid));
+                      libcfs_nidstr(&lpni->lpni_nid));
                return -EBUSY;
        }
 
@@ -577,7 +577,7 @@ lnet_peer_del_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags)
                /* assign the next peer_ni to be the primary */
                lpni2 = lnet_get_next_peer_ni_locked(lp, NULL, lpni);
                LASSERT(lpni2);
-               lp->lp_primary_nid = lpni2->lpni_nid;
+               lp->lp_primary_nid = lnet_nid_to_nid4(&lpni2->lpni_nid);
        }
        rc = lnet_peer_ni_del_locked(lpni, force);
 
@@ -606,7 +606,8 @@ lnet_peer_table_cleanup_locked(struct lnet_net *net,
                                continue;
 
                        peer = lpni->lpni_peer_net->lpn_peer;
-                       if (peer->lp_primary_nid != lpni->lpni_nid) {
+                       if (peer->lp_primary_nid !=
+                           lnet_nid_to_nid4(&lpni->lpni_nid)) {
                                lnet_peer_ni_del_locked(lpni, false);
                                continue;
                        }
@@ -688,7 +689,7 @@ lnet_peer_tables_cleanup(struct lnet_net *net)
 }
 
 static struct lnet_peer_ni *
-lnet_get_peer_ni_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
+lnet_get_peer_ni_locked(struct lnet_peer_table *ptable, struct lnet_nid *nid)
 {
        struct list_head        *peers;
        struct lnet_peer_ni     *lp;
@@ -698,7 +699,7 @@ lnet_get_peer_ni_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
 
        peers = &ptable->pt_hash[lnet_nid2peerhash(nid)];
        list_for_each_entry(lp, peers, lpni_hashlist) {
-               if (lp->lpni_nid == nid) {
+               if (nid_same(&lp->lpni_nid, nid)) {
                        lnet_peer_ni_addref_locked(lp);
                        return lp;
                }
@@ -708,16 +709,19 @@ lnet_get_peer_ni_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
 }
 
 struct lnet_peer_ni *
-lnet_find_peer_ni_locked(lnet_nid_t nid)
+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;
 
-       cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
+       lnet_nid4_to_nid(nid4, &nid);
+
+       cpt = lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER);
 
        ptable = the_lnet.ln_peer_tables[cpt];
-       lpni = lnet_get_peer_ni_locked(ptable, nid);
+       lpni = lnet_get_peer_ni_locked(ptable, &nid);
 
        return lpni;
 }
@@ -733,7 +737,7 @@ lnet_peer_get_ni_locked(struct lnet_peer *lp, lnet_nid_t nid)
                return NULL;
 
        list_for_each_entry(lpni, &lpn->lpn_peer_nis, lpni_peer_nis) {
-               if (lpni->lpni_nid == nid)
+               if (lnet_nid_to_nid4(&lpni->lpni_nid) == nid)
                        return lpni;
        }
 
@@ -958,7 +962,7 @@ lnet_peer_is_pref_rtr_locked(struct lnet_peer_ni *lpni,
        struct lnet_nid_list *ne;
 
        CDEBUG(D_NET, "%s: rtr pref emtpy: %d\n",
-              libcfs_nid2str(lpni->lpni_nid),
+              libcfs_nidstr(&lpni->lpni_nid),
               list_empty(&lpni->lpni_rtr_pref_nids));
 
        if (list_empty(&lpni->lpni_rtr_pref_nids))
@@ -1076,7 +1080,7 @@ lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
        spin_unlock(&lpni->lpni_lock);
 
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
-              libcfs_nid2str(lpni->lpni_nid), libcfs_nid2str(nid), rc);
+              libcfs_nidstr(&lpni->lpni_nid), libcfs_nid2str(nid), rc);
        return rc;
 }
 
@@ -1101,7 +1105,7 @@ lnet_peer_ni_clr_non_mr_pref_nid(struct lnet_peer_ni *lpni)
        spin_unlock(&lpni->lpni_lock);
 
        CDEBUG(D_NET, "peer %s: %d\n",
-              libcfs_nid2str(lpni->lpni_nid), rc);
+              libcfs_nidstr(&lpni->lpni_nid), rc);
        return rc;
 }
 
@@ -1482,7 +1486,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp,
        lnet_net_lock(LNET_LOCK_EX);
        /* Add peer_ni to global peer table hash, if necessary. */
        if (list_empty(&lpni->lpni_hashlist)) {
-               int hash = lnet_nid2peerhash(lpni->lpni_nid);
+               int hash = lnet_nid2peerhash(&lpni->lpni_nid);
 
                ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt];
                list_add_tail(&lpni->lpni_hashlist, &ptable->pt_hash[hash]);
@@ -1501,7 +1505,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp,
 
        /* Add peer_ni to peer_net */
        lpni->lpni_peer_net = lpn;
-       if (lp->lp_primary_nid == lpni->lpni_nid)
+       if (lp->lp_primary_nid == lnet_nid_to_nid4(&lpni->lpni_nid))
                list_add(&lpni->lpni_peer_nis, &lpn->lpn_peer_nis);
        else
                list_add_tail(&lpni->lpni_peer_nis, &lpn->lpn_peer_nis);
@@ -1512,7 +1516,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp,
        if (!lpn->lpn_peer) {
                new_lpn = true;
                lpn->lpn_peer = lp;
-               if (lp->lp_primary_nid == lpni->lpni_nid)
+               if (lp->lp_primary_nid == lnet_nid_to_nid4(&lpni->lpni_nid))
                        list_add(&lpn->lpn_peer_nets, &lp->lp_peer_nets);
                else
                        list_add_tail(&lpn->lpn_peer_nets, &lp->lp_peer_nets);
@@ -1555,11 +1559,11 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp,
        rc = lnet_udsp_apply_policies_on_lpni(lpni);
        if (rc)
                CERROR("Failed to apply UDSPs on lpni %s\n",
-                      libcfs_nid2str(lpni->lpni_nid));
+                      libcfs_nidstr(&lpni->lpni_nid));
 
        CDEBUG(D_NET, "peer %s NID %s flags %#x\n",
               libcfs_nid2str(lp->lp_primary_nid),
-              libcfs_nid2str(lpni->lpni_nid), flags);
+              libcfs_nidstr(&lpni->lpni_nid), flags);
        lnet_peer_ni_decref_locked(lpni);
        lnet_net_unlock(LNET_LOCK_EX);
 
@@ -1989,7 +1993,7 @@ lnet_destroy_peer_ni_locked(struct kref *ref)
        struct lnet_peer_table *ptable;
        struct lnet_peer_net *lpn;
 
-       CDEBUG(D_NET, "%p nid %s\n", lpni, libcfs_nid2str(lpni->lpni_nid));
+       CDEBUG(D_NET, "%p nid %s\n", lpni, libcfs_nidstr(&lpni->lpni_nid));
 
        LASSERT(kref_read(&lpni->lpni_kref) == 0);
        LASSERT(list_empty(&lpni->lpni_txq));
@@ -2585,7 +2589,7 @@ again:
 
        CDEBUG(D_NET, "peer %s NID %s: %d. %s\n",
               (lp ? libcfs_nid2str(lp->lp_primary_nid) : "(none)"),
-              libcfs_nid2str(lpni->lpni_nid), rc,
+              libcfs_nidstr(&lpni->lpni_nid), rc,
               (!block) ? "pending discovery" : "discovery complete");
 
        return rc;
@@ -2969,7 +2973,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
        /* Construct the list of NIDs present in peer. */
        lpni = NULL;
        while ((lpni = lnet_get_next_peer_ni_locked(lp, NULL, lpni)) != NULL)
-               curnis[ncurnis++] = lpni->lpni_nid;
+               curnis[ncurnis++] = lnet_nid_to_nid4(&lpni->lpni_nid);
 
        /*
         * Check for NIDs in pbuf not present in curnis[].
@@ -3930,7 +3934,7 @@ lnet_debug_peer(lnet_nid_t nid)
                aliveness = (lnet_is_peer_ni_alive(lp)) ? "up" : "down";
 
        CDEBUG(D_WARNING, "%-24s %4d %5s %5d %5d %5d %5d %5d %ld\n",
-              libcfs_nid2str(lp->lpni_nid), kref_read(&lp->lpni_kref),
+              libcfs_nidstr(&lp->lpni_nid), kref_read(&lp->lpni_kref),
               aliveness, lp->lpni_net->net_tunables.lct_peer_tx_credits,
               lp->lpni_rtrcredits, lp->lpni_minrtrcredits,
               lp->lpni_txcredits, lp->lpni_mintxcredits, lp->lpni_txqnob);
@@ -3976,6 +3980,8 @@ int lnet_get_peer_ni_info(__u32 peer_index, __u64 *nid,
                struct list_head *peers = &peer_table->pt_hash[j];
 
                list_for_each_entry(lp, peers, lpni_hashlist) {
+                       if (!nid_is_nid4(&lp->lpni_nid))
+                               continue;
                        if (peer_index-- > 0)
                                continue;
 
@@ -3985,7 +3991,7 @@ int lnet_get_peer_ni_info(__u32 peer_index, __u64 *nid,
                                snprintf(aliveness, LNET_MAX_STR_LEN,
                                         lnet_is_peer_ni_alive(lp) ? "up" : "down");
 
-                       *nid = lp->lpni_nid;
+                       *nid = lnet_nid_to_nid4(&lp->lpni_nid);
                        *refcount = kref_read(&lp->lpni_kref);
                        *ni_peer_tx_credits =
                                lp->lpni_net->net_tunables.lct_peer_tx_credits;
@@ -4060,7 +4066,9 @@ int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk)
        lpni = NULL;
        rc = -EFAULT;
        while ((lpni = lnet_get_next_peer_ni_locked(lp, NULL, lpni)) != NULL) {
-               nid = lpni->lpni_nid;
+               if (!nid_is_nid4(&lpni->lpni_nid))
+                       continue;
+               nid = lnet_nid_to_nid4(&lpni->lpni_nid);
                if (copy_to_user(bulk, &nid, sizeof(nid)))
                        goto out_free_hstats;
                bulk += sizeof(nid);
@@ -4149,7 +4157,7 @@ lnet_peer_ni_add_to_recoveryq_locked(struct lnet_peer_ni *lpni,
        if (!lpni->lpni_last_alive) {
                CDEBUG(D_NET,
                       "lpni %s(%p) not eligible for recovery last alive %lld\n",
-                      libcfs_nid2str(lpni->lpni_nid), lpni,
+                      libcfs_nidstr(&lpni->lpni_nid), lpni,
                       lpni->lpni_last_alive);
                return;
        }
@@ -4157,7 +4165,7 @@ lnet_peer_ni_add_to_recoveryq_locked(struct lnet_peer_ni *lpni,
        if (lnet_recovery_limit &&
            now > lpni->lpni_last_alive + lnet_recovery_limit) {
                CDEBUG(D_NET, "lpni %s aged out last alive %lld\n",
-                      libcfs_nid2str(lpni->lpni_nid),
+                      libcfs_nidstr(&lpni->lpni_nid),
                       lpni->lpni_last_alive);
                /* Reset the ping count so that if this peer NI is added back to
                 * the recovery queue we will send the first ping right away.
@@ -4172,7 +4180,7 @@ lnet_peer_ni_add_to_recoveryq_locked(struct lnet_peer_ni *lpni,
        lnet_peer_ni_set_next_ping(lpni, now);
 
        CDEBUG(D_NET, "%s added to recovery queue. ping count: %u next ping: %lld last alive: %lld health: %d\n",
-              libcfs_nid2str(lpni->lpni_nid),
+              libcfs_nidstr(&lpni->lpni_nid),
               lpni->lpni_ping_count,
               lpni->lpni_next_ping,
               lpni->lpni_last_alive,
index b75a515..4837d02 100644 (file)
@@ -1233,7 +1233,7 @@ rescan:
 
                /* discover the router */
                CDEBUG(D_NET, "discover %s, cpt = %d\n",
-                      libcfs_nid2str(lpni->lpni_nid), cpt);
+                      libcfs_nidstr(&lpni->lpni_nid), cpt);
                rc = lnet_discover_peer_locked(lpni, cpt, false);
 
                /* drop ref taken above */
@@ -1794,7 +1794,8 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset,
                 */
                if (lnet_is_discovery_disabled(lp)) {
                        list_for_each_entry(route, &lp->lp_routes, lr_gwlist) {
-                               if (route->lr_nid == lpni->lpni_nid)
+                               if (route->lr_nid ==
+                                   lnet_nid_to_nid4(&lpni->lpni_nid))
                                        lnet_set_route_aliveness(route, alive);
                        }
                }
@@ -1803,7 +1804,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset,
        lnet_net_unlock(0);
 
        if (ni != NULL && !alive)
-               lnet_notify_peer_down(ni, lpni->lpni_nid);
+               lnet_notify_peer_down(ni, lnet_nid_to_nid4(&lpni->lpni_nid));
 
        cpt = lpni->lpni_cpt;
        lnet_net_lock(cpt);
index 69fb21c..1627940 100644 (file)
@@ -477,7 +477,7 @@ proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer,
                 }
 
                if (peer != NULL) {
-                       lnet_nid_t nid = peer->lpni_nid;
+                       struct lnet_nid nid = peer->lpni_nid;
                        int nrefs = kref_read(&peer->lpni_kref);
                        time64_t lastalive = -1;
                        char *aliveness = "NA";
@@ -498,7 +498,7 @@ proc_lnet_peers(struct ctl_table *table, int write, void __user *buffer,
 
                        s += scnprintf(s, tmpstr + tmpsiz - s,
                                       "%-24s %4d %5s %5lld %5d %5d %5d %5d %5d %d\n",
-                                      libcfs_nid2str(nid), nrefs, aliveness,
+                                      libcfs_nidstr(&nid), nrefs, aliveness,
                                       lastalive, maxcr, rtrcr, minrtrcr, txcr,
                                       mintxcr, txqnob);
                        LASSERT(tmpstr + tmpsiz - s > 0);
index e5741b2..29cdbdd 100644 (file)
@@ -255,7 +255,7 @@ lnet_udsp_apply_rte_list_on_net(struct lnet_net *net,
                                                                            lpni)) != NULL) {
                                        if (!lnet_get_net_locked(lpni->lpni_peer_net->lpn_net_id))
                                                continue;
-                                       gw_nid = lpni->lpni_nid;
+                                       gw_nid = lnet_nid_to_nid4(&lpni->lpni_nid);
                                        rc = cfs_match_nid_net(gw_nid,
                                                rte_action->ud_net_id.udn_net_type,
                                                &rte_action->ud_net_id.udn_net_num_range,
@@ -435,7 +435,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
                                if (!cleared || revert) {
                                        CDEBUG(D_NET, "%spref rtr nids from lpni %s\n",
                                               (revert) ? "revert " : "clear ",
-                                              libcfs_nid2str(lpni->lpni_nid));
+                                              libcfs_nidstr(&lpni->lpni_nid));
                                        lnet_peer_clr_pref_rtrs(lpni);
                                        cleared = true;
                                        if (revert) {
@@ -445,7 +445,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
                                }
                                CDEBUG(D_NET, "add gw nid %s as preferred for peer %s\n",
                                       libcfs_nid2str(gw_nid),
-                                      libcfs_nid2str(lpni->lpni_nid));
+                                      libcfs_nidstr(&lpni->lpni_nid));
                                /* match. Add to pref NIDs */
                                rc = lnet_peer_add_pref_rtr(lpni, gw_nid);
                                lnet_net_lock(LNET_LOCK_EX);
@@ -453,7 +453,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
                                if (rc && rc != -EEXIST) {
                                        CERROR("Failed to add %s to %s pref rtr list\n",
                                               libcfs_nid2str(gw_nid),
-                                              libcfs_nid2str(lpni->lpni_nid));
+                                              libcfs_nidstr(&lpni->lpni_nid));
                                        return rc;
                                }
                        }
@@ -489,7 +489,7 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                                lnet_peer_clr_pref_nids(lpni);
                                CDEBUG(D_NET, "%spref nids from lpni %s\n",
                                        (revert) ? "revert " : "clear ",
-                                       libcfs_nid2str(lpni->lpni_nid));
+                                       libcfs_nidstr(&lpni->lpni_nid));
                                cleared = true;
                                if (revert) {
                                        lnet_net_lock(LNET_LOCK_EX);
@@ -498,7 +498,7 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                        }
                        CDEBUG(D_NET, "add nid %s as preferred for peer %s\n",
                                libcfs_nidstr(&ni->ni_nid),
-                               libcfs_nid2str(lpni->lpni_nid));
+                               libcfs_nidstr(&lpni->lpni_nid));
                        /* match. Add to pref NIDs */
                        rc = lnet_peer_add_pref_nid(
                                lpni, lnet_nid_to_nid4(&ni->ni_nid));
@@ -507,7 +507,7 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                        if (rc && rc != -EEXIST) {
                                CERROR("Failed to add %s to %s pref nid list\n",
                                        libcfs_nidstr(&ni->ni_nid),
-                                       libcfs_nid2str(lpni->lpni_nid));
+                                       libcfs_nidstr(&lpni->lpni_nid));
                                return rc;
                        }
                }
@@ -527,7 +527,7 @@ lnet_udsp_apply_rule_on_lpni(struct udsp_info *udi)
        bool local = udi->udi_local;
        enum lnet_udsp_action_type type = udi->udi_type;
 
-       rc = cfs_match_nid_net(lpni->lpni_nid,
+       rc = cfs_match_nid_net(lnet_nid_to_nid4(&lpni->lpni_nid),
                lp_match->ud_net_id.udn_net_type,
                &lp_match->ud_net_id.udn_net_num_range,
                &lp_match->ud_addr_range);
@@ -625,7 +625,7 @@ lnet_udsp_apply_rule_on_lpnis(struct udsp_info *udi)
                                                    &lpn->lpn_peer_nis,
                                                    lpni_peer_nis) {
                                        CDEBUG(D_NET, "udsp examining lpni %s\n",
-                                              libcfs_nid2str(lpni->lpni_nid));
+                                              libcfs_nidstr(&lpni->lpni_nid));
                                        udi->udi_lpni = lpni;
                                        rc = lnet_udsp_apply_rule_on_lpni(udi);
                                        if (rc)
@@ -1012,7 +1012,7 @@ lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info,
 
        info->cud_nid_priority = lpni->lpni_sel_priority;
        CDEBUG(D_NET, "lpni %s has %d pref nids\n",
-              libcfs_nid2str(lpni->lpni_nid),
+              libcfs_nidstr(&lpni->lpni_nid),
               lpni->lpni_pref_nnids);
        if (lpni->lpni_pref_nnids == 1) {
                info->cud_pref_nid[0] = lpni->lpni_pref.nid;