Whamcloud - gitweb
LU-6142 lnet: Fix style issues for socklnd_proto.c 26/55826/4
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Mon, 22 Jul 2024 04:37:54 +0000 (00:37 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 21:55:32 +0000 (21:55 +0000)
This patch fixes issues reported by checkpatch
for files lnet/klnds/socklnd/socklnd_proto.c

Test-Parameters: trivial testlist=sanity-lnet
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: Ie1eff17d3287dc5f844f2deba62a6f6ca4a02b4a
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55826
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/socklnd/socklnd_proto.c

index bd54dba..1f41006 100644 (file)
@@ -24,7 +24,7 @@
  *   pro_queue_tx_zcack() : Called holding BH lock: kss_lock
  *                          return 1 if ACK is piggybacked, otherwise return 0
  *   pro_queue_tx_msg()   : Called holding BH lock: kss_lock
- *                          return the ACK that piggybacked by my message, or NULL
+ *                          return ACK that piggybacked by my message, or NULL
  *   pro_handle_zcreq()   : handler of incoming ZC-REQ
  *   pro_handle_zcack()   : handler of incoming ZC-ACK
  *   pro_match_tx()       : Called holding glock
@@ -33,9 +33,9 @@
 static struct ksock_tx *
 ksocknal_queue_tx_msg_v1(struct ksock_conn *conn, struct ksock_tx *tx_msg)
 {
-        /* V1.x, just enqueue it */
+       /* V1.x, just enqueue it */
        list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
-        return NULL;
+       return NULL;
 }
 
 void
@@ -43,19 +43,19 @@ ksocknal_next_tx_carrier(struct ksock_conn *conn)
 {
        struct ksock_tx *tx = conn->ksnc_tx_carrier;
 
-        /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
+       /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
        LASSERT(!list_empty(&conn->ksnc_tx_queue));
        LASSERT(tx != NULL);
 
-        /* Next TX that can carry ZC-ACK or LNet message */
-        if (tx->tx_list.next == &conn->ksnc_tx_queue) {
-                /* no more packets queued */
-                conn->ksnc_tx_carrier = NULL;
-        } else {
+       /* Next TX that can carry ZC-ACK or LNet message */
+       if (tx->tx_list.next == &conn->ksnc_tx_queue) {
+               /* no more packets queued */
+               conn->ksnc_tx_carrier = NULL;
+       } else {
                conn->ksnc_tx_carrier = list_next_entry(tx, tx_list);
                LASSERT(conn->ksnc_tx_carrier->tx_msg.ksm_type ==
                        tx->tx_msg.ksm_type);
-        }
+       }
 }
 
 static int
@@ -64,45 +64,42 @@ ksocknal_queue_tx_zcack_v2(struct ksock_conn *conn,
 {
        struct ksock_tx *tx = conn->ksnc_tx_carrier;
 
-        LASSERT (tx_ack == NULL ||
-                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
-
-        /*
-         * Enqueue or piggyback tx_ack / cookie
-         * . no tx can piggyback cookie of tx_ack (or cookie), just
-         *   enqueue the tx_ack (if tx_ack != NUL) and return NULL.
-         * . There is tx can piggyback cookie of tx_ack (or cookie),
-         *   piggyback the cookie and return the tx.
-         */
-        if (tx == NULL) {
-                if (tx_ack != NULL) {
-                       list_add_tail(&tx_ack->tx_list,
-                                          &conn->ksnc_tx_queue);
-                        conn->ksnc_tx_carrier = tx_ack;
-                }
-                return 0;
-        }
-
-        if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
-                /* tx is noop zc-ack, can't piggyback zc-ack cookie */
-                if (tx_ack != NULL)
-                       list_add_tail(&tx_ack->tx_list,
-                                          &conn->ksnc_tx_queue);
-                return 0;
-        }
-
-        LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET);
-        LASSERT(tx->tx_msg.ksm_zc_cookies[1] == 0);
-
-        if (tx_ack != NULL)
-                cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
-
-        /* piggyback the zc-ack cookie */
-        tx->tx_msg.ksm_zc_cookies[1] = cookie;
-        /* move on to the next TX which can carry cookie */
-        ksocknal_next_tx_carrier(conn);
-
-        return 1;
+       LASSERT(tx_ack == NULL ||
+                tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+
+       /* Enqueue or piggyback tx_ack / cookie
+        * . no tx can piggyback cookie of tx_ack (or cookie), just
+        *   enqueue the tx_ack (if tx_ack != NUL) and return NULL.
+        * . There is tx can piggyback cookie of tx_ack (or cookie),
+        *   piggyback the cookie and return the tx.
+        */
+       if (tx == NULL) {
+               if (tx_ack != NULL) {
+                       list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+                       conn->ksnc_tx_carrier = tx_ack;
+               }
+               return 0;
+       }
+
+       if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
+               /* tx is noop zc-ack, can't piggyback zc-ack cookie */
+               if (tx_ack != NULL)
+                       list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+               return 0;
+       }
+
+       LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET);
+       LASSERT(tx->tx_msg.ksm_zc_cookies[1] == 0);
+
+       if (tx_ack != NULL)
+               cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
+
+       /* piggyback the zc-ack cookie */
+       tx->tx_msg.ksm_zc_cookies[1] = cookie;
+       /* move on to the next TX which can carry cookie */
+       ksocknal_next_tx_carrier(conn);
+
+       return 1;
 }
 
 static struct ksock_tx *
@@ -110,29 +107,28 @@ ksocknal_queue_tx_msg_v2(struct ksock_conn *conn, struct ksock_tx *tx_msg)
 {
        struct ksock_tx  *tx  = conn->ksnc_tx_carrier;
 
-        /*
-         * Enqueue tx_msg:
-         * . If there is no NOOP on the connection, just enqueue
-         *   tx_msg and return NULL
-         * . If there is NOOP on the connection, piggyback the cookie
-         *   and replace the NOOP tx, and return the NOOP tx.
-         */
-        if (tx == NULL) { /* nothing on queue */
+       /* Enqueue tx_msg:
+        * . If there is no NOOP on the connection, just enqueue
+        *   tx_msg and return NULL
+        * . If there is NOOP on the connection, piggyback the cookie
+        *   and replace the NOOP tx, and return the NOOP tx.
+        */
+       if (tx == NULL) { /* nothing on queue */
                list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
-                conn->ksnc_tx_carrier = tx_msg;
-                return NULL;
-        }
+               conn->ksnc_tx_carrier = tx_msg;
+               return NULL;
+       }
 
-        if (tx->tx_msg.ksm_type == KSOCK_MSG_LNET) { /* nothing to carry */
+       if (tx->tx_msg.ksm_type == KSOCK_MSG_LNET) { /* nothing to carry */
                list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
-                return NULL;
-        }
+               return NULL;
+       }
 
-        LASSERT (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+       LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
-        /* There is a noop zc-ack can be piggybacked */
-        tx_msg->tx_msg.ksm_zc_cookies[1] = tx->tx_msg.ksm_zc_cookies[1];
-        ksocknal_next_tx_carrier(conn);
+       /* There is a noop zc-ack can be piggybacked */
+       tx_msg->tx_msg.ksm_zc_cookies[1] = tx->tx_msg.ksm_zc_cookies[1];
+       ksocknal_next_tx_carrier(conn);
 
        /* use new_tx to replace the noop zc-ack packet */
        list_splice(&tx->tx_list, &tx_msg->tx_list);
@@ -146,36 +142,36 @@ ksocknal_queue_tx_zcack_v3(struct ksock_conn *conn,
 {
        struct ksock_tx *tx;
 
-        if (conn->ksnc_type != SOCKLND_CONN_ACK)
-                return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie);
+       if (conn->ksnc_type != SOCKLND_CONN_ACK)
+               return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie);
 
-        /* non-blocking ZC-ACK (to router) */
-        LASSERT (tx_ack == NULL ||
-                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+       /* non-blocking ZC-ACK (to router) */
+       LASSERT(tx_ack == NULL ||
+                tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
-        if ((tx = conn->ksnc_tx_carrier) == NULL) {
-                if (tx_ack != NULL) {
-                       list_add_tail(&tx_ack->tx_list,
-                                          &conn->ksnc_tx_queue);
-                        conn->ksnc_tx_carrier = tx_ack;
-                }
-                return 0;
-        }
+       tx = conn->ksnc_tx_carrier;
+       if (tx == NULL) {
+               if (tx_ack != NULL) {
+                       list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+                       conn->ksnc_tx_carrier = tx_ack;
+               }
+               return 0;
+       }
 
-        /* conn->ksnc_tx_carrier != NULL */
+       /* conn->ksnc_tx_carrier != NULL */
 
-        if (tx_ack != NULL)
-                cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
+       if (tx_ack != NULL)
+               cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
 
-        if (cookie == SOCKNAL_KEEPALIVE_PING) /* ignore keepalive PING */
-                return 1;
+       if (cookie == SOCKNAL_KEEPALIVE_PING) /* ignore keepalive PING */
+               return 1;
 
-        if (tx->tx_msg.ksm_zc_cookies[1] == SOCKNAL_KEEPALIVE_PING) {
-                /* replace the keepalive PING with a real ACK */
-                LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0);
-                tx->tx_msg.ksm_zc_cookies[1] = cookie;
-                return 1;
-        }
+       if (tx->tx_msg.ksm_zc_cookies[1] == SOCKNAL_KEEPALIVE_PING) {
+               /* replace the keepalive PING with a real ACK */
+               LASSERT(tx->tx_msg.ksm_zc_cookies[0] == 0);
+               tx->tx_msg.ksm_zc_cookies[1] = cookie;
+               return 1;
+       }
 
        if (cookie == tx->tx_msg.ksm_zc_cookies[0] ||
            cookie == tx->tx_msg.ksm_zc_cookies[1]) {
@@ -184,50 +180,53 @@ ksocknal_queue_tx_zcack_v3(struct ksock_conn *conn,
                return 1; /* XXX return error in the future */
        }
 
-        if (tx->tx_msg.ksm_zc_cookies[0] == 0) {
-                /* NOOP tx has only one ZC-ACK cookie, can carry at least one more */
-                if (tx->tx_msg.ksm_zc_cookies[1] > cookie) {
-                        tx->tx_msg.ksm_zc_cookies[0] = tx->tx_msg.ksm_zc_cookies[1];
-                        tx->tx_msg.ksm_zc_cookies[1] = cookie;
-                } else {
-                        tx->tx_msg.ksm_zc_cookies[0] = cookie;
-                }
-
-                if (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] > 2) {
-                        /* not likely to carry more ACKs, skip it to simplify logic */
-                        ksocknal_next_tx_carrier(conn);
-                }
+       if (tx->tx_msg.ksm_zc_cookies[0] == 0) {
+               /* NOOP tx has only one ZC-ACK cookie, can carry at least one
+                * more
+                */
+               if (tx->tx_msg.ksm_zc_cookies[1] > cookie) {
+                       tx->tx_msg.ksm_zc_cookies[0] = tx->tx_msg.ksm_zc_cookies[1];
+                       tx->tx_msg.ksm_zc_cookies[1] = cookie;
+               } else {
+                       tx->tx_msg.ksm_zc_cookies[0] = cookie;
+               }
 
-                return 1;
-        }
+               if (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] > 2) {
+                       /* not likely to carry more ACKs, skip it to simplify
+                        * logic
+                        */
+                       ksocknal_next_tx_carrier(conn);
+               }
 
-        /* takes two or more cookies already */
+               return 1;
+       }
 
-        if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) {
-                __u64   tmp = 0;
+       /* takes two or more cookies already */
+       if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) {
+               __u64   tmp = 0;
 
                /* two separated cookies: (a+2, a) or (a+1, a) */
-                LASSERT (tx->tx_msg.ksm_zc_cookies[0] -
-                         tx->tx_msg.ksm_zc_cookies[1] <= 2);
-
-                if (tx->tx_msg.ksm_zc_cookies[0] -
-                    tx->tx_msg.ksm_zc_cookies[1] == 2) {
-                        if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1)
-                                tmp = cookie;
-                } else if (cookie == tx->tx_msg.ksm_zc_cookies[1] - 1) {
-                        tmp = tx->tx_msg.ksm_zc_cookies[1];
-                } else if (cookie == tx->tx_msg.ksm_zc_cookies[0] + 1) {
-                        tmp = tx->tx_msg.ksm_zc_cookies[0];
-                }
-
-                if (tmp != 0) {
-                        /* range of cookies */
-                        tx->tx_msg.ksm_zc_cookies[0] = tmp - 1;
-                        tx->tx_msg.ksm_zc_cookies[1] = tmp + 1;
-                        return 1;
-                }
-
-        } else {
+               LASSERT(tx->tx_msg.ksm_zc_cookies[0] -
+                        tx->tx_msg.ksm_zc_cookies[1] <= 2);
+
+               if (tx->tx_msg.ksm_zc_cookies[0] -
+                   tx->tx_msg.ksm_zc_cookies[1] == 2) {
+                       if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1)
+                               tmp = cookie;
+               } else if (cookie == tx->tx_msg.ksm_zc_cookies[1] - 1) {
+                       tmp = tx->tx_msg.ksm_zc_cookies[1];
+               } else if (cookie == tx->tx_msg.ksm_zc_cookies[0] + 1) {
+                       tmp = tx->tx_msg.ksm_zc_cookies[0];
+               }
+
+               if (tmp != 0) {
+                       /* range of cookies */
+                       tx->tx_msg.ksm_zc_cookies[0] = tmp - 1;
+                       tx->tx_msg.ksm_zc_cookies[1] = tmp + 1;
+                       return 1;
+               }
+
+       } else {
                /* ksm_zc_cookies[0] < ksm_zc_cookies[1], it is a range
                 * of cookies
                 */
@@ -239,35 +238,35 @@ ksocknal_queue_tx_zcack_v3(struct ksock_conn *conn,
                        return 1; /* XXX: return error in the future */
                }
 
-                if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1) {
-                        tx->tx_msg.ksm_zc_cookies[1] = cookie;
-                        return 1;
-                }
+               if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1) {
+                       tx->tx_msg.ksm_zc_cookies[1] = cookie;
+                       return 1;
+               }
 
-                if (cookie == tx->tx_msg.ksm_zc_cookies[0] - 1) {
-                        tx->tx_msg.ksm_zc_cookies[0] = cookie;
-                        return 1;
-                }
-        }
+               if (cookie == tx->tx_msg.ksm_zc_cookies[0] - 1) {
+                       tx->tx_msg.ksm_zc_cookies[0] = cookie;
+                       return 1;
+               }
+       }
 
-        /* failed to piggyback ZC-ACK */
-        if (tx_ack != NULL) {
+       /* failed to piggyback ZC-ACK */
+       if (tx_ack != NULL) {
                list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
-                /* the next tx can piggyback at least 1 ACK */
-                ksocknal_next_tx_carrier(conn);
-        }
+               /* the next tx can piggyback at least 1 ACK */
+               ksocknal_next_tx_carrier(conn);
+       }
 
-        return 0;
+       return 0;
 }
 
 static int
 ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
 {
-        int nob;
+       int nob;
 
 #if SOCKNAL_VERSION_DEBUG
-        if (!*ksocknal_tunables.ksnd_typed_conns)
-                return SOCKNAL_MATCH_YES;
+       if (!*ksocknal_tunables.ksnd_typed_conns)
+               return SOCKNAL_MATCH_YES;
 #endif
 
        if (tx == NULL || tx->tx_lnetmsg == NULL) {
@@ -280,35 +279,35 @@ ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
                        sizeof(struct lnet_hdr_nid4);
        }
 
-        /* default checking for typed connection */
-        switch (conn->ksnc_type) {
-        default:
-                CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
-                LBUG();
-        case SOCKLND_CONN_ANY:
-                return SOCKNAL_MATCH_YES;
-
-        case SOCKLND_CONN_BULK_IN:
-                return SOCKNAL_MATCH_MAY;
-
-        case SOCKLND_CONN_BULK_OUT:
-                if (nob < *ksocknal_tunables.ksnd_min_bulk)
-                        return SOCKNAL_MATCH_MAY;
-                else
-                        return SOCKNAL_MATCH_YES;
-
-        case SOCKLND_CONN_CONTROL:
-                if (nob >= *ksocknal_tunables.ksnd_min_bulk)
-                        return SOCKNAL_MATCH_MAY;
-                else
-                        return SOCKNAL_MATCH_YES;
-        }
+       /* default checking for typed connection */
+       switch (conn->ksnc_type) {
+       default:
+               CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
+               LBUG();
+       case SOCKLND_CONN_ANY:
+               return SOCKNAL_MATCH_YES;
+
+       case SOCKLND_CONN_BULK_IN:
+               return SOCKNAL_MATCH_MAY;
+
+       case SOCKLND_CONN_BULK_OUT:
+               if (nob < *ksocknal_tunables.ksnd_min_bulk)
+                       return SOCKNAL_MATCH_MAY;
+               else
+                       return SOCKNAL_MATCH_YES;
+
+       case SOCKLND_CONN_CONTROL:
+               if (nob >= *ksocknal_tunables.ksnd_min_bulk)
+                       return SOCKNAL_MATCH_MAY;
+               else
+                       return SOCKNAL_MATCH_YES;
+       }
 }
 
 static int
 ksocknal_match_tx_v3(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
 {
-        int nob;
+       int nob;
 
        if (tx == NULL || tx->tx_lnetmsg == NULL)
                nob = sizeof(struct ksock_msg_hdr);
@@ -317,37 +316,37 @@ ksocknal_match_tx_v3(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
                        sizeof(struct lnet_hdr_nid4) +
                        tx->tx_lnetmsg->msg_len;
 
-        switch (conn->ksnc_type) {
-        default:
-                CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
-                LBUG();
-        case SOCKLND_CONN_ANY:
-                return SOCKNAL_MATCH_NO;
-
-        case SOCKLND_CONN_ACK:
-                if (nonblk)
-                        return SOCKNAL_MATCH_YES;
-                else if (tx == NULL || tx->tx_lnetmsg == NULL)
-                        return SOCKNAL_MATCH_MAY;
-                else
-                        return SOCKNAL_MATCH_NO;
-
-        case SOCKLND_CONN_BULK_OUT:
-                if (nonblk)
-                        return SOCKNAL_MATCH_NO;
-                else if (nob < *ksocknal_tunables.ksnd_min_bulk)
-                        return SOCKNAL_MATCH_MAY;
-                else
-                        return SOCKNAL_MATCH_YES;
-
-        case SOCKLND_CONN_CONTROL:
-                if (nonblk)
-                        return SOCKNAL_MATCH_NO;
-                else if (nob >= *ksocknal_tunables.ksnd_min_bulk)
-                        return SOCKNAL_MATCH_MAY;
-                else
-                        return SOCKNAL_MATCH_YES;
-        }
+       switch (conn->ksnc_type) {
+       default:
+               CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
+               LBUG();
+       case SOCKLND_CONN_ANY:
+               return SOCKNAL_MATCH_NO;
+
+       case SOCKLND_CONN_ACK:
+               if (nonblk)
+                       return SOCKNAL_MATCH_YES;
+               else if (tx == NULL || tx->tx_lnetmsg == NULL)
+                       return SOCKNAL_MATCH_MAY;
+               else
+                       return SOCKNAL_MATCH_NO;
+
+       case SOCKLND_CONN_BULK_OUT:
+               if (nonblk)
+                       return SOCKNAL_MATCH_NO;
+               else if (nob < *ksocknal_tunables.ksnd_min_bulk)
+                       return SOCKNAL_MATCH_MAY;
+               else
+                       return SOCKNAL_MATCH_YES;
+
+       case SOCKLND_CONN_CONTROL:
+               if (nonblk)
+                       return SOCKNAL_MATCH_NO;
+               else if (nob >= *ksocknal_tunables.ksnd_min_bulk)
+                       return SOCKNAL_MATCH_MAY;
+               else
+                       return SOCKNAL_MATCH_YES;
+       }
 }
 
 static int
@@ -426,10 +425,10 @@ ksocknal_handle_zcreq(struct ksock_conn *c, __u64 cookie, int remote)
 
        read_unlock(&ksocknal_data.ksnd_global_lock);
 
-        /* ACK connection is not ready, or can't piggyback the ACK */
-        tx = ksocknal_alloc_tx_noop(cookie, !!remote);
-        if (tx == NULL)
-                return -ENOMEM;
+       /* ACK connection is not ready, or can't piggyback the ACK */
+       tx = ksocknal_alloc_tx_noop(cookie, !!remote);
+       if (tx == NULL)
+               return -ENOMEM;
 
        rc = ksocknal_launch_packet(peer_ni->ksnp_ni, tx, &peer_ni->ksnp_id);
        if (rc == 0)
@@ -449,10 +448,10 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2)
        LIST_HEAD(zlist);
        int count;
 
-        if (cookie1 == 0)
-                cookie1 = cookie2;
+       if (cookie1 == 0)
+               cookie1 = cookie2;
 
-        count = (cookie1 > cookie2) ? 2 : (cookie2 - cookie1 + 1);
+       count = (cookie1 > cookie2) ? 2 : (cookie2 - cookie1 + 1);
 
        if (cookie2 == SOCKNAL_KEEPALIVE_PING &&
            (conn->ksnc_proto == &ksocknal_protocol_v3x ||
@@ -465,26 +464,27 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2)
 
        list_for_each_entry_safe(tx, tmp, &peer_ni->ksnp_zc_req_list,
                                 tx_zc_list) {
-                __u64 c = tx->tx_msg.ksm_zc_cookies[0];
+               __u64 c = tx->tx_msg.ksm_zc_cookies[0];
 
-                if (c == cookie1 || c == cookie2 || (cookie1 < c && c < cookie2)) {
-                        tx->tx_msg.ksm_zc_cookies[0] = 0;
+               if (c == cookie1 || c == cookie2 ||
+                   (cookie1 < c && c < cookie2)) {
+                       tx->tx_msg.ksm_zc_cookies[0] = 0;
                        list_move(&tx->tx_zc_list, &zlist);
 
-                        if (--count == 0)
-                                break;
-                }
-        }
+                       if (--count == 0)
+                               break;
+               }
+       }
 
        spin_unlock(&peer_ni->ksnp_lock);
 
        while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx,
                                              tx_zc_list)) != NULL) {
                list_del(&tx->tx_zc_list);
-                ksocknal_tx_decref(tx);
-        }
+               ksocknal_tx_decref(tx);
+       }
 
-        return count == 0 ? 0 : -EPROTO;
+       return count == 0 ? 0 : -EPROTO;
 }
 
 static int
@@ -501,8 +501,9 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
 
        LIBCFS_ALLOC(hdr, sizeof(*hdr));
        if (hdr == NULL) {
-               CERROR("Can't allocate struct lnet_hdr_nid4\n");
-               return -ENOMEM;
+               rc = -ENOMEM;
+               CERROR("Can't allocate struct lnet_hdr_nid4: rc = %d\n", rc);
+               return rc;
        }
 
        hmv = (struct lnet_magicversion *)&hdr->dest_nid;
@@ -523,17 +524,17 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
                        hmv->magic = LNET_PROTO_MAGIC;
        }
 
-       hdr->src_nid        = cpu_to_le64(lnet_nid_to_nid4(&hello->kshm_src_nid));
-       hdr->src_pid        = cpu_to_le32 (hello->kshm_src_pid);
-       hdr->type           = cpu_to_le32 (LNET_MSG_HELLO);
+       hdr->src_nid = cpu_to_le64(lnet_nid_to_nid4(&hello->kshm_src_nid));
+       hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid);
+       hdr->type = cpu_to_le32 (LNET_MSG_HELLO);
        hdr->payload_length = cpu_to_le32 (hello->kshm_nips * sizeof(__u32));
        hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
        hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
 
        rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
        if (rc != 0) {
-               CNETERR("Error %d sending HELLO hdr to %pIScp\n",
-                       rc, &conn->ksnc_peeraddr);
+               CNETERR("Error sending HELLO hdr to %pIScp: rc = %d\n",
+                       &conn->ksnc_peeraddr, rc);
                goto out;
        }
 
@@ -547,9 +548,8 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
                             hello->kshm_nips * sizeof(__u32),
                             lnet_acceptor_timeout());
        if (rc != 0) {
-               CNETERR("Error %d sending HELLO payload (%d) to %pIScp\n",
-                       rc, hello->kshm_nips,
-                       &conn->ksnc_peeraddr);
+               CNETERR("Error sending HELLO payload (%d) to %pIScp: rc = %d\n",
+                       hello->kshm_nips, &conn->ksnc_peeraddr, rc);
        }
 out:
        LIBCFS_FREE(hdr, sizeof(*hdr));
@@ -561,13 +561,15 @@ static int
 ksocknal_send_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello)
 {
        struct socket *sock = conn->ksnc_sock;
-       int rc;
        struct ksock_hello_msg_nid4 *hello4;
+       int rc;
 
        CFS_ALLOC_PTR(hello4);
        if (!hello4) {
-               CERROR("Can't allocate struct ksock_hello_msg_nid4\n");
-               return -ENOMEM;
+               rc = -ENOMEM;
+               CERROR("Can't allocate struct ksock_hello_msg_nid4: rc = %d\n",
+                      rc);
+               return rc;
        }
 
        hello->kshm_magic = LNET_PROTO_MAGIC;
@@ -604,8 +606,8 @@ ksocknal_send_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello)
                             lnet_acceptor_timeout());
        CFS_FREE_PTR(hello4);
        if (rc) {
-               CNETERR("Error %d sending HELLO hdr to %pIScp\n",
-                       rc, &conn->ksnc_peeraddr);
+               CNETERR("Error sending HELLO hdr to %pIScp: rc = %d\n",
+                       &conn->ksnc_peeraddr, rc);
                return rc;
        }
 
@@ -616,9 +618,8 @@ ksocknal_send_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello)
                             hello->kshm_nips * sizeof(__u32),
                             lnet_acceptor_timeout());
        if (rc != 0) {
-               CNETERR("Error %d sending HELLO payload (%d) to %pIScp\n", rc,
-                       hello->kshm_nips,
-                       &conn->ksnc_peeraddr);
+               CNETERR("Error sending HELLO payload (%d) to %pIScp: rc = %d\n",
+                       hello->kshm_nips, &conn->ksnc_peeraddr, rc);
        }
 
        return rc;
@@ -637,8 +638,8 @@ ksocknal_send_hello_v4(struct ksock_conn *conn, struct ksock_hello_msg *hello)
                             lnet_acceptor_timeout());
 
        if (rc != 0)
-               CNETERR("Error %d sending HELLO hdr to %pIScp\n",
-                       rc, &conn->ksnc_peeraddr);
+               CNETERR("Error sending HELLO hdr to %pIScp: rc = %d\n",
+                       &conn->ksnc_peeraddr, rc);
        return rc;
 }
 
@@ -653,8 +654,9 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
 
        CFS_ALLOC_PTR(hdr);
        if (!hdr) {
-               CERROR("Can't allocate struct lnet_hdr_nid4\n");
-               return -ENOMEM;
+               rc = -ENOMEM;
+               CERROR("Can't allocate struct lnet_hdr_nid4: rc = %d\n", rc);
+               return rc;
        }
 
        rc = lnet_sock_read(sock, &hdr->src_nid,
@@ -662,18 +664,17 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                                                    src_nid),
                            timeout);
        if (rc != 0) {
-               CERROR("Error %d reading rest of HELLO hdr from %pISc\n",
-                      rc, &conn->ksnc_peeraddr);
+               CERROR("Error reading rest of HELLO hdr from %pISc: rc = %d\n",
+                      &conn->ksnc_peeraddr, rc);
                LASSERT(rc < 0 && rc != -EALREADY);
                goto out;
        }
 
        /* ...and check we got what we expected */
        if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) {
-               CERROR("Expecting a HELLO hdr, but got type %d from %pISc\n",
-                      le32_to_cpu(hdr->type),
-                      &conn->ksnc_peeraddr);
                rc = -EPROTO;
+               CERROR("Expecting a HELLO hdr, but got type %d from %pISc: rc = %d\n",
+                      le32_to_cpu(hdr->type), &conn->ksnc_peeraddr, rc);
                goto out;
        }
 
@@ -684,9 +685,9 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
        hello->kshm_nips = le32_to_cpu(hdr->payload_length) / sizeof(__u32);
 
        if (hello->kshm_nips > LNET_INTERFACES_NUM) {
-               CERROR("Bad nips %d from ip %pISc\n",
-                      hello->kshm_nips, &conn->ksnc_peeraddr);
                rc = -EPROTO;
+               CERROR("Bad nips %d from ip %pISc: rc = %d\n",
+                      hello->kshm_nips, &conn->ksnc_peeraddr, rc);
                goto out;
        }
 
@@ -696,8 +697,8 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
        rc = lnet_sock_read(sock, hello->kshm_ips,
                            hello->kshm_nips * sizeof(__u32), timeout);
        if (rc != 0) {
-               CERROR("Error %d reading IPs from ip %pISc\n",
-                      rc, &conn->ksnc_peeraddr);
+               CERROR("Error reading IPs from ip %pISc: rc = %d\n",
+                      &conn->ksnc_peeraddr, rc);
                LASSERT(rc < 0 && rc != -EALREADY);
                goto out;
        }
@@ -706,9 +707,9 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]);
 
                if (hello->kshm_ips[i] == 0) {
-                       CERROR("Zero IP[%d] from ip %pISc\n",
-                              i, &conn->ksnc_peeraddr);
                        rc = -EPROTO;
+                       CERROR("Zero IP[%d] from ip %pISc: rc = %d\n",
+                              i, &conn->ksnc_peeraddr, rc);
                        break;
                }
        }
@@ -737,8 +738,8 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                            offsetof(struct ksock_hello_msg_nid4, kshm_src_nid),
                            timeout);
        if (rc != 0) {
-               CERROR("Error %d reading HELLO from %pISc\n",
-                      rc, &conn->ksnc_peeraddr);
+               CERROR("Error reading HELLO from %pISc: rc = %d\n",
+                      &conn->ksnc_peeraddr, rc);
                LASSERT(rc < 0 && rc != -EALREADY);
                return rc;
        }
@@ -766,9 +767,10 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello,
        }
 
        if (hello->kshm_nips > LNET_INTERFACES_NUM) {
-               CERROR("Bad nips %d from ip %pISc\n",
-                      hello->kshm_nips, &conn->ksnc_peeraddr);
-               return -EPROTO;
+               rc = -EPROTO;
+               CERROR("Bad nips %d from ip %pISc: rc = %d\n",
+                      hello->kshm_nips, &conn->ksnc_peeraddr, rc);
+               return rc;
        }
 
        if (hello->kshm_nips == 0)
@@ -777,8 +779,8 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello,
        rc = lnet_sock_read(sock, hello->kshm_ips,
                            hello->kshm_nips * sizeof(__u32), timeout);
        if (rc != 0) {
-               CERROR("Error %d reading IPs from ip %pISc\n",
-                      rc, &conn->ksnc_peeraddr);
+               CERROR("Error reading IPs from ip %pISc: rc = %d\n",
+                      &conn->ksnc_peeraddr, rc);
                LASSERT(rc < 0 && rc != -EALREADY);
                return rc;
        }
@@ -788,9 +790,10 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                        __swab32s(&hello->kshm_ips[i]);
 
                if (hello->kshm_ips[i] == 0) {
-                       CERROR("Zero IP[%d] from ip %pISc\n",
-                              i, &conn->ksnc_peeraddr);
-                       return -EPROTO;
+                       rc = -EPROTO;
+                       CERROR("Zero IP[%d] from ip %pISc: rc = %d\n",
+                              i, &conn->ksnc_peeraddr, rc);
+                       return rc;
                }
        }
 
@@ -814,8 +817,8 @@ ksocknal_recv_hello_v4(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                            offsetof(struct ksock_hello_msg, kshm_src_nid),
                            timeout);
        if (rc) {
-               CERROR("Error %d reading HELLO from %pISc\n",
-                      rc, &conn->ksnc_peeraddr);
+               CERROR("Error reading HELLO from %pISc: rc = %d\n",
+                      &conn->ksnc_peeraddr, rc);
                LASSERT(rc < 0 && rc != -EALREADY);
                return rc;
        }
@@ -934,46 +937,46 @@ ksocknal_unpack_msg_v4(struct ksock_msg *msg, struct lnet_hdr *hdr)
        lnet_hdr_from_nid16(hdr, &msg->ksm_u.lnetmsg_nid16);
 }
 
-const struct ksock_proto ksocknal_protocol_v1x =
-{
-        .pro_version            = KSOCK_PROTO_V1,
-        .pro_send_hello         = ksocknal_send_hello_v1,
-        .pro_recv_hello         = ksocknal_recv_hello_v1,
-        .pro_pack               = ksocknal_pack_msg_v1,
-        .pro_unpack             = ksocknal_unpack_msg_v1,
-        .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v1,
-        .pro_handle_zcreq       = NULL,
-        .pro_handle_zcack       = NULL,
-        .pro_queue_tx_zcack     = NULL,
-        .pro_match_tx           = ksocknal_match_tx
+const struct ksock_proto ksocknal_protocol_v1x = {
+
+       .pro_version            = KSOCK_PROTO_V1,
+       .pro_send_hello         = ksocknal_send_hello_v1,
+       .pro_recv_hello         = ksocknal_recv_hello_v1,
+       .pro_pack               = ksocknal_pack_msg_v1,
+       .pro_unpack             = ksocknal_unpack_msg_v1,
+       .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v1,
+       .pro_handle_zcreq       = NULL,
+       .pro_handle_zcack       = NULL,
+       .pro_queue_tx_zcack     = NULL,
+       .pro_match_tx           = ksocknal_match_tx
 };
 
-const struct ksock_proto ksocknal_protocol_v2x =
-{
-        .pro_version            = KSOCK_PROTO_V2,
-        .pro_send_hello         = ksocknal_send_hello_v2,
-        .pro_recv_hello         = ksocknal_recv_hello_v2,
-        .pro_pack               = ksocknal_pack_msg_v2,
-        .pro_unpack             = ksocknal_unpack_msg_v2,
-        .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v2,
-        .pro_queue_tx_zcack     = ksocknal_queue_tx_zcack_v2,
-        .pro_handle_zcreq       = ksocknal_handle_zcreq,
-        .pro_handle_zcack       = ksocknal_handle_zcack,
-        .pro_match_tx           = ksocknal_match_tx
+const struct ksock_proto ksocknal_protocol_v2x = {
+
+       .pro_version            = KSOCK_PROTO_V2,
+       .pro_send_hello         = ksocknal_send_hello_v2,
+       .pro_recv_hello         = ksocknal_recv_hello_v2,
+       .pro_pack               = ksocknal_pack_msg_v2,
+       .pro_unpack             = ksocknal_unpack_msg_v2,
+       .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v2,
+       .pro_queue_tx_zcack     = ksocknal_queue_tx_zcack_v2,
+       .pro_handle_zcreq       = ksocknal_handle_zcreq,
+       .pro_handle_zcack       = ksocknal_handle_zcack,
+       .pro_match_tx           = ksocknal_match_tx
 };
 
-const struct ksock_proto ksocknal_protocol_v3x =
-{
-        .pro_version            = KSOCK_PROTO_V3,
-        .pro_send_hello         = ksocknal_send_hello_v2,
-        .pro_recv_hello         = ksocknal_recv_hello_v2,
-        .pro_pack               = ksocknal_pack_msg_v2,
-        .pro_unpack             = ksocknal_unpack_msg_v2,
-        .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v2,
-        .pro_queue_tx_zcack     = ksocknal_queue_tx_zcack_v3,
-        .pro_handle_zcreq       = ksocknal_handle_zcreq,
-        .pro_handle_zcack       = ksocknal_handle_zcack,
-        .pro_match_tx           = ksocknal_match_tx_v3
+const struct ksock_proto ksocknal_protocol_v3x = {
+
+       .pro_version            = KSOCK_PROTO_V3,
+       .pro_send_hello         = ksocknal_send_hello_v2,
+       .pro_recv_hello         = ksocknal_recv_hello_v2,
+       .pro_pack               = ksocknal_pack_msg_v2,
+       .pro_unpack             = ksocknal_unpack_msg_v2,
+       .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v2,
+       .pro_queue_tx_zcack     = ksocknal_queue_tx_zcack_v3,
+       .pro_handle_zcreq       = ksocknal_handle_zcreq,
+       .pro_handle_zcack       = ksocknal_handle_zcack,
+       .pro_match_tx           = ksocknal_match_tx_v3
 };
 
 const struct ksock_proto ksocknal_protocol_v4x = {