Whamcloud - gitweb
LU-10391 lnet: change src_nid arg to lnet_parse() to 16byte 14/43614/9
authorMr NeilBrown <neilb@suse.de>
Fri, 7 Jan 2022 01:13:58 +0000 (20:13 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Jan 2022 05:13:42 +0000 (05:13 +0000)
lnet_parse() now gets the source nid as 'struct lnet_nid *'.

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: I7afac71c97e4564e544695f057fd0b002d97afc9
Reviewed-on: https://review.whamcloud.com/43614
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-lnet.h
lnet/klnds/gnilnd/gnilnd_cb.c
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd_cb.c
lnet/lnet/lib-move.c
lnet/lnet/lo.c

index e0f604d..c3c55cd 100644 (file)
@@ -748,7 +748,7 @@ void lnet_portals_destroy(void);
 
 /* message functions */
 int lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr,
-              lnet_nid_t fromnid, void *private, int rdma_req);
+              struct lnet_nid *fromnid, void *private, int rdma_req);
 int lnet_parse_local(struct lnet_ni *ni, struct lnet_msg *msg);
 int lnet_parse_forward_locked(struct lnet_ni *ni, struct lnet_msg *msg);
 
index 7fa5dcb..0c56311 100644 (file)
@@ -4024,6 +4024,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
        unsigned long timestamp, newest_last_rx, timeout;
        int           last_seq;
        struct lnet_hdr hdr;
+       struct lnet_nid srcnid;
        ENTRY;
 
        /* Short circuit if the ep_handle is null.
@@ -4285,13 +4286,15 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                /* only get SMSG payload for IMMEDIATE */
                atomic64_add(msg->gnm_payload_len, &conn->gnc_device->gnd_short_rxbytes);
                lnet_hdr_from_nid4(&hdr, &msg->gnm_u.immediate.gnim_hdr);
-               rc = lnet_parse(net->gnn_ni, &hdr, msg->gnm_srcnid, rx, 0);
+               lnet_nid4_to_nid(msg->gnm_srcnid, &srcnid);
+               rc = lnet_parse(net->gnn_ni, &hdr, &srcnid, rx, 0);
                repost = rc < 0;
                break;
        case GNILND_MSG_GET_REQ_REV:
        case GNILND_MSG_PUT_REQ:
                lnet_hdr_from_nid4(&hdr, &msg->gnm_u.putreq.gnprm_hdr);
-               rc = lnet_parse(net->gnn_ni, &hdr, msg->gnm_srcnid, rx, 1);
+               lnet_nid4_to_nid(msg->gnm_srcnid, &srcnid);
+               rc = lnet_parse(net->gnn_ni, &hdr, &srcnid, rx, 1);
                repost = rc < 0;
                break;
        case GNILND_MSG_GET_NAK_REV:
@@ -4397,7 +4400,8 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
        case GNILND_MSG_PUT_REQ_REV:
        case GNILND_MSG_GET_REQ:
                lnet_hdr_from_nid4(&hdr, &msg->gnm_u.get.gngm_hdr);
-               rc = lnet_parse(net->gnn_ni, &hdr, msg->gnm_srcnid, rx, 1);
+               lnet_nid4_to_nid(msg->gnm_srcnid, &srcnid);
+               rc = lnet_parse(net->gnn_ni, &hdr, &srcnid, rx, 1);
                repost = rc < 0;
                break;
 
index 78a772b..e96110d 100644 (file)
@@ -333,6 +333,7 @@ kiblnd_handle_rx(struct kib_rx *rx)
        int rc2;
        int post_credit;
        struct lnet_hdr hdr;
+       struct lnet_nid srcnid;
 
         LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
@@ -393,7 +394,8 @@ kiblnd_handle_rx(struct kib_rx *rx)
        case IBLND_MSG_IMMEDIATE:
                post_credit = IBLND_POSTRX_DONT_POST;
                lnet_hdr_from_nid4(&hdr, &msg->ibm_u.immediate.ibim_hdr);
-               rc = lnet_parse(ni, &hdr, msg->ibm_srcnid, rx, 0);
+               lnet_nid4_to_nid(msg->ibm_srcnid, &srcnid);
+               rc = lnet_parse(ni, &hdr, &srcnid, rx, 0);
                if (rc < 0)                     /* repost on error */
                        post_credit = IBLND_POSTRX_PEER_CREDIT;
                break;
@@ -401,7 +403,8 @@ kiblnd_handle_rx(struct kib_rx *rx)
        case IBLND_MSG_PUT_REQ:
                post_credit = IBLND_POSTRX_DONT_POST;
                lnet_hdr_from_nid4(&hdr, &msg->ibm_u.putreq.ibprm_hdr);
-               rc = lnet_parse(ni, &hdr, msg->ibm_srcnid, rx, 1);
+               lnet_nid4_to_nid(msg->ibm_srcnid, &srcnid);
+               rc = lnet_parse(ni, &hdr, &srcnid, rx, 1);
                if (rc < 0)                     /* repost on error */
                        post_credit = IBLND_POSTRX_PEER_CREDIT;
                break;
@@ -463,7 +466,8 @@ kiblnd_handle_rx(struct kib_rx *rx)
        case IBLND_MSG_GET_REQ:
                post_credit = IBLND_POSTRX_DONT_POST;
                lnet_hdr_from_nid4(&hdr, &msg->ibm_u.get.ibgm_hdr);
-               rc = lnet_parse(ni, &hdr, msg->ibm_srcnid, rx, 1);
+               lnet_nid4_to_nid(msg->ibm_srcnid, &srcnid);
+               rc = lnet_parse(ni, &hdr, &srcnid, rx, 1);
                if (rc < 0)                     /* repost on error */
                        post_credit = IBLND_POSTRX_PEER_CREDIT;
                break;
index 2f7fc2a..3f9dcf7 100644 (file)
@@ -1281,7 +1281,7 @@ ksocknal_process_receive(struct ksock_conn *conn,
 
                rc = lnet_parse(conn->ksnc_peer->ksnp_ni,
                                &hdr,
-                               lnet_nid_to_nid4(&conn->ksnc_peer->ksnp_id.nid),
+                               &conn->ksnc_peer->ksnp_id.nid,
                                conn, 0);
                if (rc < 0) {
                        /* I just received garbage: give up on this conn */
index 09b4ec6..7d117c7 100644 (file)
@@ -4492,8 +4492,8 @@ lnet_msgtyp2str (int type)
 EXPORT_SYMBOL(lnet_msgtyp2str);
 
 int
-lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
-          void *private, int rdma_req)
+lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr,
+          struct lnet_nid *from_nid, void *private, int rdma_req)
 {
        struct lnet_peer_ni *lpni;
        struct lnet_msg *msg;
@@ -4501,7 +4501,6 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        lnet_pid_t dest_pid;
        struct lnet_nid dest_nid;
        struct lnet_nid src_nid;
-       struct lnet_nid from_nid;
        bool push = false;
        int for_me;
        __u32 type;
@@ -4510,8 +4509,6 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
 
        LASSERT (!in_interrupt ());
 
-       lnet_nid4_to_nid(from_nid4, &from_nid);
-
        type = hdr->type;
        src_nid = hdr->src_nid;
        dest_nid = hdr->dest_nid;
@@ -4519,7 +4516,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        payload_length = hdr->payload_length;
 
        for_me = nid_same(&ni->ni_nid, &dest_nid);
-       cpt = lnet_nid2cpt(&from_nid, ni);
+       cpt = lnet_nid2cpt(from_nid, ni);
 
        CDEBUG(D_NET, "TRACE: %s(%s) <- %s : %s - %s\n",
                libcfs_nidstr(&dest_nid),
@@ -4533,7 +4530,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        case LNET_MSG_GET:
                if (payload_length > 0) {
                        CERROR("%s, src %s: bad %s payload %d (0 expected)\n",
-                              libcfs_nid2str(from_nid4),
+                              libcfs_nidstr(from_nid),
                               libcfs_nidstr(&src_nid),
                               lnet_msgtyp2str(type), payload_length);
                        return -EPROTO;
@@ -4546,7 +4543,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                    (__u32)(for_me ? LNET_MAX_PAYLOAD : LNET_MTU)) {
                        CERROR("%s, src %s: bad %s payload %d "
                               "(%d max expected)\n",
-                              libcfs_nid2str(from_nid4),
+                              libcfs_nidstr(from_nid),
                               libcfs_nidstr(&src_nid),
                               lnet_msgtyp2str(type),
                               payload_length,
@@ -4557,7 +4554,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
 
        default:
                CERROR("%s, src %s: Bad message type 0x%x\n",
-                      libcfs_nid2str(from_nid4),
+                      libcfs_nidstr(from_nid),
                       libcfs_nidstr(&src_nid), type);
                return -EPROTO;
        }
@@ -4584,7 +4581,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                        /* should have gone direct */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(should have been sent direct)\n",
-                               libcfs_nid2str(from_nid4),
+                               libcfs_nidstr(from_nid),
                                libcfs_nidstr(&src_nid),
                                libcfs_nidstr(&dest_nid));
                        return -EPROTO;
@@ -4595,7 +4592,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                         * this node's NID on its own network */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(it's my nid but on a different network)\n",
-                               libcfs_nid2str(from_nid4),
+                               libcfs_nidstr(from_nid),
                                libcfs_nidstr(&src_nid),
                                libcfs_nidstr(&dest_nid));
                        return -EPROTO;
@@ -4604,7 +4601,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                if (rdma_req && type == LNET_MSG_GET) {
                        CERROR("%s, src %s: Bad optimized GET for %s "
                               "(final destination must be me)\n",
-                               libcfs_nid2str(from_nid4),
+                               libcfs_nidstr(from_nid),
                                libcfs_nidstr(&src_nid),
                                libcfs_nidstr(&dest_nid));
                        return -EPROTO;
@@ -4613,7 +4610,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                if (!the_lnet.ln_routing) {
                        CERROR("%s, src %s: Dropping message for %s "
                               "(routing not enabled)\n",
-                               libcfs_nid2str(from_nid4),
+                               libcfs_nidstr(from_nid),
                                libcfs_nidstr(&src_nid),
                                libcfs_nidstr(&dest_nid));
                        goto drop;
@@ -4626,7 +4623,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        if (!list_empty(&the_lnet.ln_test_peers) &&     /* normally we don't */
            fail_peer(&src_nid, 0)) {                   /* shall we now? */
                CERROR("%s, src %s: Dropping %s to simulate failure\n",
-                      libcfs_nid2str(from_nid4), libcfs_nidstr(&src_nid),
+                      libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
                       lnet_msgtyp2str(type));
                goto drop;
        }
@@ -4636,7 +4633,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
            lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&ni->ni_nid), NULL)) {
                CDEBUG(D_NET,
                       "%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
-                      libcfs_nid2str(from_nid4), libcfs_nidstr(&src_nid),
+                      libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
                       libcfs_nidstr(&dest_nid), lnet_msgtyp2str(type));
                goto drop;
        }
@@ -4644,7 +4641,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        msg = lnet_msg_alloc();
        if (msg == NULL) {
                CERROR("%s, src %s: Dropping %s (out of memory)\n",
-                      libcfs_nid2str(from_nid4), libcfs_nidstr(&src_nid),
+                      libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
                       lnet_msgtyp2str(type));
                goto drop;
        }
@@ -4660,7 +4657,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        msg->msg_offset = 0;
        msg->msg_hdr = *hdr;
        /* for building message event */
-       msg->msg_from = from_nid;
+       msg->msg_from = *from_nid;
        if (!for_me) {
                msg->msg_target.pid = dest_pid;
                msg->msg_target.nid = dest_nid;
@@ -4668,12 +4665,12 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
        }
 
        lnet_net_lock(cpt);
-       lpni = lnet_peerni_by_nid_locked(&from_nid, &ni->ni_nid, cpt);
+       lpni = lnet_peerni_by_nid_locked(from_nid, &ni->ni_nid, cpt);
        if (IS_ERR(lpni)) {
                lnet_net_unlock(cpt);
                rc = PTR_ERR(lpni);
                CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n",
-                      libcfs_nid2str(from_nid4), libcfs_nidstr(&src_nid),
+                      libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
                       lnet_msgtyp2str(type), rc);
                lnet_msg_free(msg);
                if (rc == -ESHUTDOWN)
@@ -4688,7 +4685,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
         */
        if (((lnet_drop_asym_route && for_me) ||
             !lpni->lpni_peer_net->lpn_peer->lp_alive) &&
-           LNET_NID_NET(&src_nid) != LNET_NIDNET(from_nid4)) {
+           LNET_NID_NET(&src_nid) != LNET_NID_NET(from_nid)) {
                __u32 src_net_id = LNET_NID_NET(&src_nid);
                struct lnet_peer *gw = lpni->lpni_peer_net->lpn_peer;
                struct lnet_route *route;
@@ -4723,7 +4720,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                         * => asymmetric routing detected but forbidden
                         */
                        CERROR("%s, src %s: Dropping asymmetrical route %s\n",
-                              libcfs_nid2str(from_nid4),
+                              libcfs_nidstr(from_nid),
                               libcfs_nidstr(&src_nid), lnet_msgtyp2str(type));
                        lnet_msg_free(msg);
                        goto drop;
index 82b723c..d4c9ed1 100644 (file)
@@ -38,8 +38,7 @@ lolnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        LASSERT(!lntmsg->msg_routing);
        LASSERT(!lntmsg->msg_target_is_router);
 
-       return lnet_parse(ni, &lntmsg->msg_hdr,
-                         lnet_nid_to_nid4(&ni->ni_nid), lntmsg, 0);
+       return lnet_parse(ni, &lntmsg->msg_hdr, &ni->ni_nid, lntmsg, 0);
 }
 
 static int