Whamcloud - gitweb
LU-10391 lnet: switch to large lnet_processid for matching
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index 9f67e03..c4d6e6c 100644 (file)
@@ -883,6 +883,15 @@ static void lnet_assert_wire_constants(void)
        BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq, acr_nid) != 8);
        BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq *)0)->acr_nid) != 8);
 
+       /* Checks for struct lnet_acceptor_connreq_v2 */
+       BUILD_BUG_ON((int)sizeof(struct lnet_acceptor_connreq_v2) != 28);
+       BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_magic) != 0);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_magic) != 4);
+       BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_version) != 4);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_version) != 4);
+       BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_nid) != 8);
+       BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_nid) != 20);
+
        /* Checks for struct lnet_counters_common */
        BUILD_BUG_ON((int)sizeof(struct lnet_counters_common) != 60);
        BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_msgs_alloc) != 0);
@@ -1453,7 +1462,7 @@ lnet_net_clr_pref_rtrs(struct lnet_net *net)
 
 int
 lnet_net_add_pref_rtr(struct lnet_net *net,
-                     lnet_nid_t gw_nid)
+                     struct lnet_nid *gw_nid)
 __must_hold(&the_lnet.ln_api_mutex)
 {
        struct lnet_nid_list *ne;
@@ -1464,7 +1473,7 @@ __must_hold(&the_lnet.ln_api_mutex)
         * lock.
         */
        list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
-               if (ne->nl_nid == gw_nid)
+               if (nid_same(&ne->nl_nid, gw_nid))
                        return -EEXIST;
        }
 
@@ -1472,7 +1481,7 @@ __must_hold(&the_lnet.ln_api_mutex)
        if (!ne)
                return -ENOMEM;
 
-       ne->nl_nid = gw_nid;
+       ne->nl_nid = *gw_nid;
 
        /* Lock the cpt to protect against addition and checks in the
         * selection algorithm
@@ -1485,11 +1494,11 @@ __must_hold(&the_lnet.ln_api_mutex)
 }
 
 bool
-lnet_net_is_pref_rtr_locked(struct lnet_net *net, lnet_nid_t rtr_nid)
+lnet_net_is_pref_rtr_locked(struct lnet_net *net, struct lnet_nid *rtr_nid)
 {
        struct lnet_nid_list *ne;
 
-       CDEBUG(D_NET, "%s: rtr pref emtpy: %d\n",
+       CDEBUG(D_NET, "%s: rtr pref empty: %d\n",
               libcfs_net2str(net->net_id),
               list_empty(&net->net_rtr_pref_nids));
 
@@ -1498,9 +1507,9 @@ lnet_net_is_pref_rtr_locked(struct lnet_net *net, lnet_nid_t rtr_nid)
 
        list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
                CDEBUG(D_NET, "Comparing pref %s with gw %s\n",
-                      libcfs_nid2str(ne->nl_nid),
-                      libcfs_nid2str(rtr_nid));
-               if (rtr_nid == ne->nl_nid)
+                      libcfs_nidstr(&ne->nl_nid),
+                      libcfs_nidstr(rtr_nid));
+               if (nid_same(rtr_nid, &ne->nl_nid))
                        return true;
        }
 
@@ -1584,24 +1593,35 @@ lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni)
 }
 
 int
-lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
+lnet_nid2cpt(struct lnet_nid *nid, 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);
 
        return cpt2;
 }
+EXPORT_SYMBOL(lnet_nid2cpt);
+
+int
+lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
+{
+       struct lnet_nid nid;
+
+       if (LNET_CPT_NUMBER == 1)
+               return 0; /* the only one */
+
+       lnet_nid4_to_nid(nid4, &nid);
+       return lnet_nid2cpt(&nid, ni);
+}
 EXPORT_SYMBOL(lnet_cpt_of_nid);
 
 int
@@ -1693,7 +1713,7 @@ lnet_nid_to_ni_addref(struct lnet_nid *nid)
 EXPORT_SYMBOL(lnet_nid_to_ni_addref);
 
 int
-lnet_islocalnid(lnet_nid_t nid)
+lnet_islocalnid4(lnet_nid_t nid)
 {
        struct lnet_ni  *ni;
        int             cpt;
@@ -1706,6 +1726,19 @@ lnet_islocalnid(lnet_nid_t nid)
 }
 
 int
+lnet_islocalnid(struct lnet_nid *nid)
+{
+       struct lnet_ni  *ni;
+       int             cpt;
+
+       cpt = lnet_net_lock_current();
+       ni = lnet_nid_to_ni_locked(nid, cpt);
+       lnet_net_unlock(cpt);
+
+       return ni != NULL;
+}
+
+int
 lnet_count_acceptor_nets(void)
 {
        /* Return the # of NIs that need the acceptor. */
@@ -1885,8 +1918,8 @@ lnet_ping_target_setup(struct lnet_ping_buffer **ppbuf,
                       struct lnet_handle_md *ping_mdh,
                       int ni_count, bool set_eq)
 {
-       struct lnet_process_id id = {
-               .nid = LNET_NID_ANY,
+       struct lnet_processid id = {
+               .nid = LNET_ANY_NID,
                .pid = LNET_PID_ANY
        };
        struct lnet_me *me;
@@ -1904,7 +1937,7 @@ lnet_ping_target_setup(struct lnet_ping_buffer **ppbuf,
        }
 
        /* Ping target ME/MD */
-       me = LNetMEAttach(LNET_RESERVED_PORTAL, id,
+       me = LNetMEAttach(LNET_RESERVED_PORTAL, &id,
                          LNET_PROTO_PING_MATCHBITS, 0,
                          LNET_UNLINK, LNET_INS_AFTER);
        if (IS_ERR(me)) {
@@ -2102,12 +2135,12 @@ again:
 int lnet_push_target_post(struct lnet_ping_buffer *pbuf,
                          struct lnet_handle_md *mdhp)
 {
-       struct lnet_process_id id = { LNET_NID_ANY, LNET_PID_ANY };
+       struct lnet_processid id = { LNET_ANY_NID, LNET_PID_ANY };
        struct lnet_md md = { NULL };
        struct lnet_me *me;
        int rc;
 
-       me = LNetMEAttach(LNET_RESERVED_PORTAL, id,
+       me = LNetMEAttach(LNET_RESERVED_PORTAL, &id,
                          LNET_PROTO_PING_MATCHBITS, 0,
                          LNET_UNLINK, LNET_INS_AFTER);
        if (IS_ERR(me)) {
@@ -3902,6 +3935,7 @@ LNetCtl(unsigned int cmd, void *arg)
        struct lnet_ioctl_config_data *config;
        struct lnet_process_id    id = {0};
        struct lnet_ni           *ni;
+       struct lnet_nid           nid;
        int                       rc;
 
        BUILD_BUG_ON(sizeof(struct lnet_ioctl_net_config) +
@@ -3929,10 +3963,11 @@ LNetCtl(unsigned int cmd, void *arg)
                          config->cfg_config_u.cfg_route.rtr_sensitivity;
                }
 
+               lnet_nid4_to_nid(config->cfg_nid, &nid);
                mutex_lock(&the_lnet.ln_api_mutex);
                rc = lnet_add_route(config->cfg_net,
                                    config->cfg_config_u.cfg_route.rtr_hop,
-                                   config->cfg_nid,
+                                   &nid,
                                    config->cfg_config_u.cfg_route.
                                        rtr_priority, sensitivity);
                mutex_unlock(&the_lnet.ln_api_mutex);