From 50f6bb62987c54ea9a5d622df4871ad9a416c018 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 10 Jul 2020 15:19:38 +1000 Subject: [PATCH] LU-10391 lnet: convert LNetPut to take 16byte nid and pid. LNetPut() now takes a 16byte nid for self and similar process_id for target. 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 Change-Id: I240caf6fb8b02b1814b9d4883aceda33894786a4 Reviewed-on: https://review.whamcloud.com/43619 Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Amir Shehata Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lnet/include/lnet/api.h | 16 +++++++------- lnet/lnet/lib-move.c | 28 ++++++++++-------------- lnet/lnet/peer.c | 10 ++++----- lnet/selftest/rpc.c | 17 ++++++++++----- lustre/ptlrpc/niobuf.c | 58 +++++++++++++++++++++++++++++-------------------- 5 files changed, 69 insertions(+), 60 deletions(-) diff --git a/lnet/include/lnet/api.h b/lnet/include/lnet/api.h index 930485a..382d3f8 100644 --- a/lnet/include/lnet/api.h +++ b/lnet/include/lnet/api.h @@ -135,14 +135,14 @@ void lnet_assert_handler_unused(lnet_handler_t handler); * The LNet API provides two data movement operations: LNetPut() * and LNetGet(). * @{ */ -int LNetPut(lnet_nid_t self, - struct lnet_handle_md md_in, - enum lnet_ack_req ack_req_in, - struct lnet_process_id target_in, - unsigned int portal_in, - __u64 match_bits_in, - unsigned int offset_in, - __u64 hdr_data_in); +int LNetPut(struct lnet_nid *self, + struct lnet_handle_md md_in, + enum lnet_ack_req ack_req_in, + struct lnet_processid *target_in, + unsigned int portal_in, + __u64 match_bits_in, + unsigned int offset_in, + __u64 hdr_data_in); int LNetGet(lnet_nid_t self, struct lnet_handle_md md_in, diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index 01aab3e..d3b7c30 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -4978,8 +4978,8 @@ lnet_attach_rsp_tracker(struct lnet_rsp_tracker *rspt, int cpt, * \see struct lnet_event::hdr_data and lnet_event_kind_t. */ int -LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, - struct lnet_process_id target4, unsigned int portal, +LNetPut(struct lnet_nid *self, struct lnet_handle_md mdh, enum lnet_ack_req ack, + struct lnet_processid *target, unsigned int portal, __u64 match_bits, unsigned int offset, __u64 hdr_data) { @@ -4987,27 +4987,21 @@ LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, struct lnet_libmd *md; int cpt; int rc; - struct lnet_processid target; struct lnet_rsp_tracker *rspt = NULL; - struct lnet_nid self; LASSERT(the_lnet.ln_refcount > 0); - lnet_nid4_to_nid(self4, &self); - lnet_nid4_to_nid(target4.nid, &target.nid); - target.pid = target4.pid; - if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */ - fail_peer(&target.nid, 1)) { /* shall we now? */ + fail_peer(&target->nid, 1)) { /* shall we now? */ CERROR("Dropping PUT to %s: simulated failure\n", - libcfs_id2str(target4)); + libcfs_idstr(target)); return -EIO; } msg = lnet_msg_alloc(); if (msg == NULL) { CERROR("Dropping PUT to %s: ENOMEM on struct lnet_msg\n", - libcfs_id2str(target4)); + libcfs_idstr(target)); return -ENOMEM; } msg->msg_vmflush = !!(current->flags & PF_MEMALLOC); @@ -5018,7 +5012,7 @@ LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, rspt = lnet_rspt_alloc(cpt); if (!rspt) { CERROR("Dropping PUT to %s: ENOMEM on response tracker\n", - libcfs_id2str(target4)); + libcfs_idstr(target)); return -ENOMEM; } INIT_LIST_HEAD(&rspt->rspt_on_list); @@ -5029,7 +5023,7 @@ LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, md = lnet_handle2md(&mdh); if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) { CERROR("Dropping PUT (%llu:%d:%s): MD (%d) invalid\n", - match_bits, portal, libcfs_id2str(target4), + match_bits, portal, libcfs_idstr(target), md == NULL ? -1 : md->md_threshold); if (md != NULL && md->md_me != NULL) CERROR("Source MD also attached to portal %d\n", @@ -5043,11 +5037,11 @@ LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, return -ENOENT; } - CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_id2str(target4)); + CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_idstr(target)); lnet_msg_attach_md(msg, md, 0, 0); - lnet_prep_send(msg, LNET_MSG_PUT, &target, 0, md->md_length); + lnet_prep_send(msg, LNET_MSG_PUT, target, 0, md->md_length); msg->msg_hdr.msg.put.match_bits = cpu_to_le64(match_bits); msg->msg_hdr.msg.put.ptl_index = cpu_to_le32(portal); @@ -5081,11 +5075,11 @@ LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, CFS_FAIL_ONCE)) rc = -EIO; else - rc = lnet_send(&self, msg, NULL); + rc = lnet_send(self, msg, NULL); if (rc != 0) { CNETERR("Error sending PUT to %s: %d\n", - libcfs_id2str(target4), rc); + libcfs_idstr(target), rc); msg->msg_no_resend = true; lnet_finalize(msg, rc); } diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index 7ac343b..50b64d2 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -3579,7 +3579,7 @@ static int lnet_peer_send_push(struct lnet_peer *lp) __must_hold(&lp->lp_lock) { struct lnet_ping_buffer *pbuf; - struct lnet_process_id id; + struct lnet_processid id; struct lnet_md md; int cpt; int rc; @@ -3626,13 +3626,13 @@ __must_hold(&lp->lp_lock) lnet_peer_addref_locked(lp); id.pid = LNET_PID_LUSTRE; if (!LNET_NID_IS_ANY(&lp->lp_disc_dst_nid)) - id.nid = lnet_nid_to_nid4(&lp->lp_disc_dst_nid); + id.nid = lp->lp_disc_dst_nid; else - id.nid = lnet_nid_to_nid4(&lp->lp_primary_nid); + id.nid = lp->lp_primary_nid; lnet_net_unlock(cpt); - rc = LNetPut(lnet_nid_to_nid4(&lp->lp_disc_src_nid), lp->lp_push_mdh, - LNET_ACK_REQ, id, LNET_RESERVED_PORTAL, + rc = LNetPut(&lp->lp_disc_src_nid, lp->lp_push_mdh, + LNET_ACK_REQ, &id, LNET_RESERVED_PORTAL, LNET_PROTO_PING_MATCHBITS, 0, 0); /* diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index d0bdd01..c51167a 100644 --- a/lnet/selftest/rpc.c +++ b/lnet/selftest/rpc.c @@ -394,12 +394,17 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf, static int srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, - int options, struct lnet_process_id peer, - lnet_nid_t self, struct lnet_handle_md *mdh, + int options, struct lnet_process_id peer4, + lnet_nid_t self4, struct lnet_handle_md *mdh, struct srpc_event *ev) { int rc; struct lnet_md md; + struct lnet_nid self; + struct lnet_processid peer; + + lnet_nid4_to_nid(self4, &self); + lnet_pid4_to_pid(peer4, &peer); md.user_ptr = ev; md.start = buf; @@ -420,18 +425,18 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, * buffers... */ if ((options & LNET_MD_OP_PUT) != 0) { - rc = LNetPut(self, *mdh, LNET_NOACK_REQ, peer, + rc = LNetPut(&self, *mdh, LNET_NOACK_REQ, &peer, portal, matchbits, 0, 0); } else { LASSERT((options & LNET_MD_OP_GET) != 0); - rc = LNetGet(self, *mdh, peer, portal, matchbits, 0, false); + rc = LNetGet(self4, *mdh, peer4, portal, matchbits, 0, false); } if (rc != 0) { CERROR("LNet%s(%s, %d, %lld) failed: %d\n", ((options & LNET_MD_OP_PUT) != 0) ? "Put" : "Get", - libcfs_id2str(peer), portal, matchbits, rc); + libcfs_id2str(peer4), portal, matchbits, rc); /* The forthcoming unlink event will complete this operation * with failure, so fall through and return success here. @@ -441,7 +446,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, } else { CDEBUG(D_NET, "Posted active RDMA: peer %s, portal %u, matchbits %#llx\n", - libcfs_id2str(peer), portal, matchbits); + libcfs_id2str(peer4), portal, matchbits); } return 0; } diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c index cfd16ff..b847174 100644 --- a/lustre/ptlrpc/niobuf.c +++ b/lustre/ptlrpc/niobuf.c @@ -46,16 +46,21 @@ */ static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len, enum lnet_ack_req ack, struct ptlrpc_cb_id *cbid, - lnet_nid_t self, struct lnet_process_id peer_id, + lnet_nid_t self4, struct lnet_process_id peer_id4, int portal, __u64 xid, unsigned int offset, struct lnet_handle_md *bulk_cookie) { - int rc; - struct lnet_md md; + int rc; + struct lnet_md md; + struct lnet_nid self; + struct lnet_processid peer_id; ENTRY; - LASSERT (portal != 0); - CDEBUG (D_INFO, "peer_id %s\n", libcfs_id2str(peer_id)); + lnet_nid4_to_nid(self4, &self); + lnet_pid4_to_pid(peer_id4, &peer_id); + + LASSERT(portal != 0); + CDEBUG(D_INFO, "peer_id %s\n", libcfs_id2str(peer_id4)); md.start = base; md.length = len; md.threshold = (ack == LNET_ACK_REQ) ? 2 : 1; @@ -87,15 +92,15 @@ static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len, percpu_ref_get(&ptlrpc_pending); - rc = LNetPut(self, *mdh, ack, - peer_id, portal, xid, offset, 0); + rc = LNetPut(&self, *mdh, ack, + &peer_id, portal, xid, offset, 0); if (unlikely(rc != 0)) { int rc2; /* We're going to get an UNLINK event when I unlink below, * which will complete just like any other failed send, so * I fall through and return success here! */ CERROR("LNetPut(%s, %d, %lld) failed: %d\n", - libcfs_id2str(peer_id), portal, xid, rc); + libcfs_id2str(peer_id4), portal, xid, rc); rc2 = LNetMDUnlink(*mdh); LASSERTF(rc2 == 0, "rc2 = %d\n", rc2); } @@ -159,14 +164,16 @@ EXPORT_SYMBOL(ptlrpc_prep_bulk_exp); */ int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc) { - struct obd_export *exp = desc->bd_export; - lnet_nid_t self_nid; - struct lnet_process_id peer_id; - int rc = 0; - __u64 mbits; - int posted_md; - int total_md; - struct lnet_md md; + struct obd_export *exp = desc->bd_export; + lnet_nid_t self_nid4; + struct lnet_nid self_nid; + struct lnet_process_id peer_id4; + struct lnet_processid peer_id; + int rc = 0; + __u64 mbits; + int posted_md; + int total_md; + struct lnet_md md; ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_PUT_NET)) @@ -183,8 +190,10 @@ int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc) * request, so they are based on the route taken by the * message. */ - self_nid = desc->bd_req->rq_self; - peer_id = desc->bd_req->rq_source; + self_nid4 = desc->bd_req->rq_self; + peer_id4 = desc->bd_req->rq_source; + lnet_nid4_to_nid(self_nid4, &self_nid); + lnet_pid4_to_pid(peer_id4, &peer_id); /* NB total length may be 0 for a read past EOF, so we send 0 * length bulks, since the client expects bulk events. @@ -228,18 +237,19 @@ int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc) /* Network is about to get at the memory */ if (ptlrpc_is_bulk_put_source(desc->bd_type)) - rc = LNetPut(self_nid, desc->bd_mds[posted_md], - LNET_ACK_REQ, peer_id, + rc = LNetPut(&self_nid, desc->bd_mds[posted_md], + LNET_ACK_REQ, &peer_id, desc->bd_portal, mbits, 0, 0); else - rc = LNetGet(self_nid, desc->bd_mds[posted_md], - peer_id, desc->bd_portal, mbits, 0, false); + rc = LNetGet(self_nid4, desc->bd_mds[posted_md], + peer_id4, desc->bd_portal, + mbits, 0, false); posted_md++; if (rc != 0) { CERROR("%s: failed bulk transfer with %s:%u x%llu: " "rc = %d\n", exp->exp_obd->obd_name, - libcfs_id2str(peer_id), desc->bd_portal, + libcfs_id2str(peer_id4), desc->bd_portal, mbits, rc); break; } @@ -260,7 +270,7 @@ int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc) CDEBUG(D_NET, "Transferring %u pages %u bytes via portal %d " "id %s mbits %#llx-%#llx\n", desc->bd_iov_count, - desc->bd_nob, desc->bd_portal, libcfs_id2str(peer_id), + desc->bd_nob, desc->bd_portal, libcfs_id2str(peer_id4), mbits - posted_md, mbits - 1); RETURN(0); -- 1.8.3.1