diff mbox series

[03/24] lnet: o2iblnd: cleanup

Message ID 1642124283-10148-4-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to OpenSFS Jan 13, 2022 | expand

Commit Message

James Simmons Jan. 14, 2022, 1:37 a.m. UTC
From: Alexey Lyashkov <alexey.lyashkov@hpe.com>

simplify kiblnd_send by avoid code duplication.
lets pickup idle tx first.

HPE-bug-id: LUS-1796
WC-bug-id: https://jira.whamcloud.com/browse/LU-14008
Lustre-commit: 3916b9d7226ebb21c ("LU-14008 o2iblnd: cleanup")
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Reviewed-on: https://review.whamcloud.com/40260
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 43 ++++++++++++++-----------------------
 net/lnet/lnet/lib-move.c            |  1 +
 2 files changed, 17 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
index db13f41..7560fe1 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1543,6 +1543,15 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 
 	iov_iter_advance(&from, payload_offset);
 
+	tx = kiblnd_get_idle_tx(ni, target.nid);
+	if (!tx) {
+		CERROR("Can't allocate %s txd for %s\n",
+		       lnet_msgtyp2str(type),
+		       libcfs_nid2str(target.nid));
+		return -ENOMEM;
+	}
+	ibmsg = tx->tx_msg;
+
 	switch (type) {
 	default:
 		LBUG();
@@ -1561,14 +1570,6 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		if (nob <= IBLND_MSG_SIZE && !lntmsg->msg_rdma_force)
 			break;		/* send IMMEDIATE */
 
-		tx = kiblnd_get_idle_tx(ni, target.nid);
-		if (!tx) {
-			CERROR("Can't allocate txd for GET to %s\n",
-			       libcfs_nid2str(target.nid));
-			return -ENOMEM;
-		}
-
-		ibmsg = tx->tx_msg;
 		rd = &ibmsg->ibm_u.get.ibgm_rd;
 		rc = kiblnd_setup_rd_kiov(ni, tx, rd,
 					  payload_niov, payload_kiov,
@@ -1595,7 +1596,8 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 			return -EIO;
 		}
 
-		tx->tx_lntmsg[0] = lntmsg;	/* finalise lntmsg[0,1] on completion */
+		/* finalise lntmsg[0,1] on completion */
+		tx->tx_lntmsg[0] = lntmsg;
 		tx->tx_waiting = 1;		/* waiting for GET_DONE */
 		kiblnd_launch_tx(ni, tx, target.nid);
 		return 0;
@@ -1607,14 +1609,6 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		if (nob <= IBLND_MSG_SIZE && !lntmsg->msg_rdma_force)
 			break;			/* send IMMEDIATE */
 
-		tx = kiblnd_get_idle_tx(ni, target.nid);
-		if (!tx) {
-			CERROR("Can't allocate %s txd for %s\n",
-			       type == LNET_MSG_PUT ? "PUT" : "REPLY",
-			       libcfs_nid2str(target.nid));
-			return -ENOMEM;
-		}
-
 		rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
 					  payload_niov, payload_kiov,
 					  payload_offset, payload_nob);
@@ -1625,12 +1619,12 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 			return -EIO;
 		}
 
-		ibmsg = tx->tx_msg;
 		ibmsg->ibm_u.putreq.ibprm_hdr = *hdr;
 		ibmsg->ibm_u.putreq.ibprm_cookie = tx->tx_cookie;
 		kiblnd_init_tx_msg(ni, tx, IBLND_MSG_PUT_REQ, sizeof(struct kib_putreq_msg));
 
-		tx->tx_lntmsg[0] = lntmsg;	/* finalise lntmsg on completion */
+		/* finalise lntmsg on completion */
+		tx->tx_lntmsg[0] = lntmsg;
 		tx->tx_waiting = 1;		/* waiting for PUT_{ACK,NAK} */
 		kiblnd_launch_tx(ni, tx, target.nid);
 		return 0;
@@ -1641,13 +1635,6 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	LASSERT(offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[payload_nob])
 		 <= IBLND_MSG_SIZE);
 
-	tx = kiblnd_get_idle_tx(ni, target.nid);
-	if (!tx) {
-		CERROR("Can't send %d to %s: tx descs exhausted\n",
-		       type, libcfs_nid2str(target.nid));
-		return -ENOMEM;
-	}
-
 	ibmsg = tx->tx_msg;
 	ibmsg->ibm_u.immediate.ibim_hdr = *hdr;
 
@@ -1661,7 +1648,9 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	nob = offsetof(struct kib_immediate_msg, ibim_payload[payload_nob]);
 	kiblnd_init_tx_msg(ni, tx, IBLND_MSG_IMMEDIATE, nob);
 
-	tx->tx_lntmsg[0] = lntmsg;		/* finalise lntmsg on completion */
+	/* finalise lntmsg on completion */
+	tx->tx_lntmsg[0] = lntmsg;
+
 	kiblnd_launch_tx(ni, tx, target.nid);
 	return 0;
 }
diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index caffa30..133397e 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -4215,6 +4215,7 @@  void lnet_monitor_thr_stop(void)
 		return "<UNKNOWN>";
 	}
 }
+EXPORT_SYMBOL(lnet_msgtyp2str);
 
 int
 lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,