Whamcloud - gitweb
LU-13004 lnet: simplify ksock_tx. 50/37850/8
authorMr NeilBrown <neilb@suse.de>
Wed, 4 Dec 2019 05:40:12 +0000 (16:40 +1100)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 08:25:01 +0000 (08:25 +0000)
The tx_frags union in 'struct ksock_tx' is largely unnecessary.  The
payload is always lnet_kiov_t, the only kvec is a header.  So replace
the union with just those two fields.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I2c4bd5397ddf412b11e9f741406de617c534c736
Reviewed-on: https://review.whamcloud.com/37850
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c

index 7e9b38d..c55a3bd 100644 (file)
@@ -262,24 +262,17 @@ struct ksock_tx {                 /* transmit packet */
         unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */
         unsigned short tx_nonblk:1;    /* it's a non-blocking ACK */
        struct bio_vec *tx_kiov;        /* packet page frags */
-       struct ksock_conn *tx_conn;        /* owning conn */
-       struct lnet_msg   *tx_lnetmsg;  /* lnet message for lnet_finalize() */
-       time64_t           tx_deadline; /* when (in secs) tx times out */
-       struct ksock_msg   tx_msg;         /* socklnd message buffer */
-        int            tx_desc_size;   /* size of this descriptor */
+       struct ksock_conn *tx_conn;     /* owning conn */
+       struct lnet_msg *tx_lnetmsg;    /* lnet message for lnet_finalize() */
+       time64_t        tx_deadline;    /* when (in secs) tx times out */
+       struct ksock_msg tx_msg;        /* socklnd message buffer */
+       int             tx_desc_size;   /* size of this descriptor */
        enum lnet_msg_hstatus tx_hstatus; /* health status of tx */
-        union {
-                struct {
-                       struct kvec iov;        /* virt hdr */
-                       struct bio_vec kiov[0]; /* paged payload */
-                }                  paged;
-                struct {
-                       struct kvec iov[1];     /* virt hdr + payload */
-                }                  virt;
-        }                       tx_frags;
+       struct kvec     tx_hdr;         /* virt hdr */
+       struct bio_vec  tx_payload[0];  /* paged payload */
 };
 
-#define KSOCK_NOOP_TX_SIZE  ((int)offsetof(struct ksock_tx, tx_frags.paged.kiov[0]))
+#define KSOCK_NOOP_TX_SIZE  ((int)offsetof(struct ksock_tx, tx_payload[0]))
 
 /* network zero copy callback descriptor embedded in struct ksock_tx */
 
index c878b2b..51415ec 100644 (file)
@@ -71,26 +71,26 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk)
 {
        struct ksock_tx *tx;
 
-        tx = ksocknal_alloc_tx(KSOCK_MSG_NOOP, KSOCK_NOOP_TX_SIZE);
-        if (tx == NULL) {
-                CERROR("Can't allocate noop tx desc\n");
-                return NULL;
-        }
+       tx = ksocknal_alloc_tx(KSOCK_MSG_NOOP, KSOCK_NOOP_TX_SIZE);
+       if (tx == NULL) {
+               CERROR("Can't allocate noop tx desc\n");
+               return NULL;
+       }
 
-        tx->tx_conn     = NULL;
-        tx->tx_lnetmsg  = NULL;
-        tx->tx_kiov     = NULL;
-        tx->tx_nkiov    = 0;
-        tx->tx_iov      = tx->tx_frags.virt.iov;
-        tx->tx_niov     = 1;
-        tx->tx_nonblk   = nonblk;
+       tx->tx_conn     = NULL;
+       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;
 
        tx->tx_msg.ksm_csum = 0;
        tx->tx_msg.ksm_type = KSOCK_MSG_NOOP;
        tx->tx_msg.ksm_zc_cookies[0] = 0;
-        tx->tx_msg.ksm_zc_cookies[1] = cookie;
+       tx->tx_msg.ksm_zc_cookies[1] = cookie;
 
-        return tx;
+       return tx;
 }
 
 
@@ -1006,7 +1006,7 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
        LASSERT (!in_interrupt ());
 
        desc_size = offsetof(struct ksock_tx,
-                            tx_frags.paged.kiov[payload_niov]);
+                            tx_payload[payload_niov]);
 
         if (lntmsg->msg_vmflush)
                mpflag = memalloc_noreclaim_save();
@@ -1024,8 +1024,8 @@ 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_frags.paged.iov;
-       tx->tx_kiov = tx->tx_frags.paged.kiov;
+       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,
                                         payload_offset, payload_nob);