Whamcloud - gitweb
LU-13004 socklnd: discard tx_iov.
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_cb.c
index 51415ec..9641431 100644 (file)
@@ -81,7 +81,6 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk)
        tx->tx_lnetmsg  = NULL;
        tx->tx_kiov     = NULL;
        tx->tx_nkiov    = 0;
-       tx->tx_iov      = &tx->tx_hdr;
        tx->tx_niov     = 1;
        tx->tx_nonblk   = nonblk;
 
@@ -112,17 +111,17 @@ ksocknal_free_tx(struct ksock_tx *tx)
 }
 
 static int
-ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx,
+ksocknal_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx,
                  struct kvec *scratch_iov)
 {
-       struct kvec *iov = tx->tx_iov;
+       struct kvec *iov = &tx->tx_hdr;
        int    nob;
        int    rc;
 
        LASSERT(tx->tx_niov > 0);
 
-       /* Never touch tx->tx_iov inside ksocknal_lib_send_iov() */
-       rc = ksocknal_lib_send_iov(conn, tx, scratch_iov);
+       /* Never touch tx->tx_hdr inside ksocknal_lib_send_hdr() */
+       rc = ksocknal_lib_send_hdr(conn, tx, scratch_iov);
 
        if (rc <= 0)                            /* sent nothing? */
                return rc;
@@ -132,19 +131,16 @@ ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx,
        tx->tx_resid -= nob;
 
        /* "consume" iov */
-       do {
-               LASSERT(tx->tx_niov > 0);
+       LASSERT(tx->tx_niov == 1);
 
-               if (nob < (int) iov->iov_len) {
-                       iov->iov_base += nob;
-                       iov->iov_len -= nob;
-                       return rc;
-               }
+       if (nob < (int) iov->iov_len) {
+               iov->iov_base += nob;
+               iov->iov_len -= nob;
+               return rc;
+       }
 
-               nob -= iov->iov_len;
-               tx->tx_iov = ++iov;
-               tx->tx_niov--;
-       } while (nob != 0);
+       LASSERT(nob == iov->iov_len);
+       tx->tx_niov--;
 
        return rc;
 }
@@ -213,7 +209,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx,
                        ksocknal_data.ksnd_enomem_tx--;
                        rc = -EAGAIN;
                } else if (tx->tx_niov != 0) {
-                       rc = ksocknal_send_iov(conn, tx, scratch_iov);
+                       rc = ksocknal_send_hdr(conn, tx, scratch_iov);
                } else {
                        rc = ksocknal_send_kiov(conn, tx, scratch_iov);
                }
@@ -764,17 +760,18 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 
         ksocknal_tx_prep(conn, tx);
 
-        /* Ensure the frags we've been given EXACTLY match the number of
-         * bytes we want to send.  Many TCP/IP stacks disregard any total
+       /* Ensure the frags we've been given EXACTLY match the number of
+        * bytes we want to send.  Many TCP/IP stacks disregard any total
         * size parameters passed to them and just look at the frags.
-         *
-         * We always expect at least 1 mapped fragment containing the
-         * complete ksocknal message header. */
-        LASSERT (lnet_iov_nob (tx->tx_niov, tx->tx_iov) +
-                 lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
-                 (unsigned int)tx->tx_nob);
-        LASSERT (tx->tx_niov >= 1);
-        LASSERT (tx->tx_resid == tx->tx_nob);
+        *
+        * We always expect at least 1 mapped fragment containing the
+        * complete ksocknal message header.
+        */
+       LASSERT(lnet_iov_nob(tx->tx_niov, &tx->tx_hdr) +
+               lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
+               (unsigned int)tx->tx_nob);
+       LASSERT(tx->tx_niov >= 1);
+       LASSERT(tx->tx_resid == tx->tx_nob);
 
         CDEBUG (D_NET, "Packet %p type %d, nob %d niov %d nkiov %d\n",
                 tx, (tx->tx_lnetmsg != NULL) ? tx->tx_lnetmsg->msg_hdr.type:
@@ -1024,7 +1021,6 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        tx->tx_lnetmsg = lntmsg;
 
        tx->tx_niov = 1;
-       tx->tx_iov = &tx->tx_hdr;
        tx->tx_kiov = tx->tx_payload;
        tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
                                         payload_niov, payload_kiov,