Whamcloud - gitweb
LU-14217 osd-zfs: allow SEEK_HOLE/DATA only with sync
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_proto.c
index 14bdb45..533e8bb 100644 (file)
@@ -63,8 +63,7 @@ ksocknal_next_tx_carrier(struct ksock_conn *conn)
                 /* no more packets queued */
                 conn->ksnc_tx_carrier = NULL;
         } else {
-               conn->ksnc_tx_carrier = list_entry(tx->tx_list.next,
-                                                  struct ksock_tx, tx_list);
+               conn->ksnc_tx_carrier = list_next_entry(tx, tx_list);
                LASSERT(conn->ksnc_tx_carrier->tx_msg.ksm_type ==
                        tx->tx_msg.ksm_type);
         }
@@ -422,8 +421,8 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2)
 
        spin_lock(&peer_ni->ksnp_lock);
 
-       list_for_each_entry_safe(tx, tmp,
-                                     &peer_ni->ksnp_zc_req_list, tx_zc_list) {
+       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];
 
                 if (c == cookie1 || c == cookie2 || (cookie1 < c && c < cookie2)) {
@@ -437,8 +436,8 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2)
 
        spin_unlock(&peer_ni->ksnp_lock);
 
-       while (!list_empty(&zlist)) {
-               tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list);
+       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);
         }
@@ -489,11 +488,11 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
         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 %pI4h/%d\n",
-                       rc, &conn->ksnc_ipaddr, conn->ksnc_port);
-                goto out;
-        }
+       if (rc != 0) {
+               CNETERR("Error %d sending HELLO hdr to %pISp\n",
+                       rc, &conn->ksnc_peeraddr);
+               goto out;
+       }
 
         if (hello->kshm_nips == 0)
                 goto out;
@@ -503,12 +502,12 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
         }
 
        rc = lnet_sock_write(sock, hello->kshm_ips,
-                               hello->kshm_nips * sizeof(__u32),
-                               lnet_acceptor_timeout());
-        if (rc != 0) {
-                CNETERR("Error %d sending HELLO payload (%d)"
-                       " to %pI4h/%d\n", rc, hello->kshm_nips,
-                       &conn->ksnc_ipaddr, conn->ksnc_port);
+                            hello->kshm_nips * sizeof(__u32),
+                            lnet_acceptor_timeout());
+       if (rc != 0) {
+               CNETERR("Error %d sending HELLO payload (%d) to %pISp\n",
+                       rc, hello->kshm_nips,
+                       &conn->ksnc_peeraddr);
         }
 out:
         LIBCFS_FREE(hdr, sizeof(*hdr));
@@ -534,25 +533,25 @@ ksocknal_send_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello)
        rc = lnet_sock_write(sock, hello, offsetof(struct ksock_hello_msg, kshm_ips),
                                lnet_acceptor_timeout());
 
-        if (rc != 0) {
-               CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
-                       rc, &conn->ksnc_ipaddr, conn->ksnc_port);
-                return rc;
-        }
+       if (rc != 0) {
+               CNETERR("Error %d sending HELLO hdr to %pISp\n",
+                       rc, &conn->ksnc_peeraddr);
+               return rc;
+       }
 
         if (hello->kshm_nips == 0)
                 return 0;
 
        rc = lnet_sock_write(sock, hello->kshm_ips,
-                               hello->kshm_nips * sizeof(__u32),
-                               lnet_acceptor_timeout());
-        if (rc != 0) {
-                CNETERR("Error %d sending HELLO payload (%d)"
-                       " to %pI4h/%d\n", rc, hello->kshm_nips,
-                       &conn->ksnc_ipaddr, conn->ksnc_port);
-        }
+                            hello->kshm_nips * sizeof(__u32),
+                            lnet_acceptor_timeout());
+       if (rc != 0) {
+               CNETERR("Error %d sending HELLO payload (%d) to %pISp\n", rc,
+                       hello->kshm_nips,
+                       &conn->ksnc_peeraddr);
+       }
 
-        return rc;
+       return rc;
 }
 
 static int
@@ -574,21 +573,20 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                              sizeof(*hdr) - offsetof(struct lnet_hdr, src_nid),
                              timeout);
        if (rc != 0) {
-               CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
-                      rc, &conn->ksnc_ipaddr);
+               CERROR("Error %d reading rest of HELLO hdr from %pIS\n",
+                      rc, &conn->ksnc_peeraddr);
                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 %pI4h\n",
-                        le32_to_cpu (hdr->type),
-                       &conn->ksnc_ipaddr);
-                rc = -EPROTO;
-                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 %pIS\n",
+                      le32_to_cpu(hdr->type),
+                      &conn->ksnc_peeraddr);
+               rc = -EPROTO;
+               goto out;
+       }
 
         hello->kshm_src_nid         = le64_to_cpu (hdr->src_nid);
         hello->kshm_src_pid         = le32_to_cpu (hdr->src_pid);
@@ -598,8 +596,8 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                                          sizeof (__u32);
 
        if (hello->kshm_nips > LNET_INTERFACES_NUM) {
-               CERROR("Bad nips %d from ip %pI4h\n",
-                      hello->kshm_nips, &conn->ksnc_ipaddr);
+               CERROR("Bad nips %d from ip %pIS\n",
+                      hello->kshm_nips, &conn->ksnc_peeraddr);
                rc = -EPROTO;
                goto out;
        }
@@ -610,8 +608,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 %pI4h\n",
-                      rc, &conn->ksnc_ipaddr);
+               CERROR("Error %d reading IPs from ip %pIS\n",
+                      rc, &conn->ksnc_peeraddr);
                LASSERT(rc < 0 && rc != -EALREADY);
                 goto out;
         }
@@ -620,8 +618,8 @@ 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 %pI4h\n",
-                              i, &conn->ksnc_ipaddr);
+                       CERROR("Zero IP[%d] from ip %pIS\n",
+                              i, &conn->ksnc_peeraddr);
                         rc = -EPROTO;
                         break;
                 }
@@ -650,8 +648,8 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                                       offsetof(struct ksock_hello_msg, kshm_src_nid),
                               timeout);
         if (rc != 0) {
-               CERROR("Error %d reading HELLO from %pI4h\n",
-                      rc, &conn->ksnc_ipaddr);
+               CERROR("Error %d reading HELLO from %pIS\n",
+                      rc, &conn->ksnc_peeraddr);
                LASSERT(rc < 0 && rc != -EALREADY);
                 return rc;
         }
@@ -668,8 +666,8 @@ 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 %pI4h\n",
-                      hello->kshm_nips, &conn->ksnc_ipaddr);
+               CERROR("Bad nips %d from ip %pIS\n",
+                      hello->kshm_nips, &conn->ksnc_peeraddr);
                return -EPROTO;
        }
 
@@ -678,22 +676,22 @@ 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 %pI4h\n",
-                      rc, &conn->ksnc_ipaddr);
+       if (rc != 0) {
+               CERROR("Error %d reading IPs from ip %pIS\n",
+                      rc, &conn->ksnc_peeraddr);
                LASSERT(rc < 0 && rc != -EALREADY);
-                return rc;
-        }
+               return rc;
+       }
 
         for (i = 0; i < (int) hello->kshm_nips; i++) {
                 if (conn->ksnc_flip)
                         __swab32s(&hello->kshm_ips[i]);
 
-                if (hello->kshm_ips[i] == 0) {
-                       CERROR("Zero IP[%d] from ip %pI4h\n",
-                              i, &conn->ksnc_ipaddr);
-                        return -EPROTO;
-                }
+               if (hello->kshm_ips[i] == 0) {
+                       CERROR("Zero IP[%d] from ip %pIS\n",
+                              i, &conn->ksnc_peeraddr);
+                       return -EPROTO;
+               }
         }
 
         return 0;
@@ -706,8 +704,8 @@ ksocknal_pack_msg_v1(struct ksock_tx *tx)
        LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
        LASSERT(tx->tx_lnetmsg != NULL);
 
-       tx->tx_iov[0].iov_base = (void *)&tx->tx_lnetmsg->msg_hdr;
-       tx->tx_iov[0].iov_len  = sizeof(struct lnet_hdr);
+       tx->tx_hdr.iov_base = (void *)&tx->tx_lnetmsg->msg_hdr;
+       tx->tx_hdr.iov_len  = sizeof(struct lnet_hdr);
 
        tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr);
        tx->tx_resid = tx->tx_nob;
@@ -716,18 +714,19 @@ ksocknal_pack_msg_v1(struct ksock_tx *tx)
 static void
 ksocknal_pack_msg_v2(struct ksock_tx *tx)
 {
-        tx->tx_iov[0].iov_base = (void *)&tx->tx_msg;
+       tx->tx_hdr.iov_base = (void *)&tx->tx_msg;
 
         if (tx->tx_lnetmsg != NULL) {
                 LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
 
                 tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
-               tx->tx_iov[0].iov_len = sizeof(struct ksock_msg);
+               tx->tx_hdr.iov_len = sizeof(struct ksock_msg);
                tx->tx_resid = tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
         } else {
                 LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
-               tx->tx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
+               tx->tx_hdr.iov_len = offsetof(struct ksock_msg,
+                                             ksm_u.lnetmsg.ksnm_hdr);
                tx->tx_resid = tx->tx_nob = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
         }
         /* Don't checksum before start sending, because packet can be piggybacked with ACK */