Whamcloud - gitweb
LU-4423 lnet: don't use iovec instead of kvec
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_lib.c
index a5f63f0..b59e685 100644 (file)
@@ -345,7 +345,7 @@ ksocknal_lib_tunables_fini ()
 int
 ksocknal_lib_get_conn_addrs (ksock_conn_t *conn)
 {
-        int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1,
+       int rc = lnet_sock_getaddr(conn->ksnc_sock, true,
                                      &conn->ksnc_ipaddr,
                                      &conn->ksnc_port);
 
@@ -357,7 +357,7 @@ ksocknal_lib_get_conn_addrs (ksock_conn_t *conn)
                 return rc;
         }
 
-        rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
+       rc = lnet_sock_getaddr(conn->ksnc_sock, false,
                                  &conn->ksnc_myipaddr, NULL);
         if (rc != 0) {
                 CERROR ("Error %d getting sock local IP\n", rc);
@@ -398,12 +398,12 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
 
        {
 #if SOCKNAL_SINGLE_FRAG_TX
-               struct iovec    scratch;
-               struct iovec   *scratchiov = &scratch;
-               unsigned int    niov = 1;
+               struct kvec scratch;
+               struct kvec *scratchiov = &scratch;
+               unsigned int niov = 1;
 #else
-                struct iovec   *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
-               unsigned int    niov = tx->tx_niov;
+               struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+               unsigned int niov = tx->tx_niov;
 #endif
                struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
                 int  i;
@@ -417,8 +417,7 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
                    nob < tx->tx_resid)
                        msg.msg_flags |= MSG_MORE;
 
-               rc = kernel_sendmsg(sock, &msg, (struct kvec *)scratchiov,
-                                   niov, nob);
+               rc = kernel_sendmsg(sock, &msg, scratchiov, niov, nob);
        }
        return rc;
 }
@@ -460,14 +459,14 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
                 }
         } else {
 #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
-               struct iovec    scratch;
-               struct iovec   *scratchiov = &scratch;
+               struct kvec     scratch;
+               struct kvec   *scratchiov = &scratch;
                unsigned int    niov = 1;
 #else
 #ifdef CONFIG_HIGHMEM
 #warning "XXX risk of kmap deadlock on multiple frags..."
 #endif
-               struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+               struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
                unsigned int  niov = tx->tx_nkiov;
 #endif
                struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
@@ -483,7 +482,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
                    nob < tx->tx_resid)
                        msg.msg_flags |= MSG_MORE;
 
-               rc = kernel_sendmsg(sock, &msg, (struct kvec *)scratchiov, niov, nob);
+               rc = kernel_sendmsg(sock, &msg, scratchiov, niov, nob);
 
                for (i = 0; i < niov; i++)
                        kunmap(kiov[i].kiov_page);
@@ -513,14 +512,14 @@ int
 ksocknal_lib_recv_iov (ksock_conn_t *conn)
 {
 #if SOCKNAL_SINGLE_FRAG_RX
-       struct iovec  scratch;
-       struct iovec *scratchiov = &scratch;
+       struct kvec  scratch;
+       struct kvec *scratchiov = &scratch;
        unsigned int  niov = 1;
 #else
-       struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+       struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
        unsigned int  niov = conn->ksnc_rx_niov;
 #endif
-       struct iovec *iov = conn->ksnc_rx_iov;
+       struct kvec *iov = conn->ksnc_rx_iov;
        struct msghdr msg = {
                .msg_flags      = 0
        };
@@ -541,8 +540,8 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn)
         }
         LASSERT (nob <= conn->ksnc_rx_nob_wanted);
 
-       rc = kernel_recvmsg(conn->ksnc_sock, &msg,
-               (struct kvec *)scratchiov, niov, nob, MSG_DONTWAIT);
+       rc = kernel_recvmsg(conn->ksnc_sock, &msg, scratchiov, niov, nob,
+                           MSG_DONTWAIT);
 
         saved_csum = 0;
         if (conn->ksnc_proto == &ksocknal_protocol_v2x) {
@@ -579,7 +578,7 @@ ksocknal_lib_kiov_vunmap(void *addr)
 
 static void *
 ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
-                       struct iovec *iov, struct page **pages)
+                      struct kvec *iov, struct page **pages)
 {
         void             *addr;
         int               nob;
@@ -618,15 +617,15 @@ int
 ksocknal_lib_recv_kiov (ksock_conn_t *conn)
 {
 #if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK
-        struct iovec   scratch;
-        struct iovec  *scratchiov = &scratch;
+       struct kvec   scratch;
+       struct kvec  *scratchiov = &scratch;
         struct page  **pages      = NULL;
         unsigned int   niov       = 1;
 #else
 #ifdef CONFIG_HIGHMEM
 #warning "XXX risk of kmap deadlock on multiple frags..."
 #endif
-       struct iovec  *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+       struct kvec  *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
        struct page  **pages      = conn->ksnc_scheduler->kss_rx_scratch_pgs;
        unsigned int   niov       = conn->ksnc_rx_nkiov;
 #endif
@@ -660,8 +659,8 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
 
        LASSERT (nob <= conn->ksnc_rx_nob_wanted);
 
-       rc = kernel_recvmsg(conn->ksnc_sock, &msg,
-                       (struct kvec *)scratchiov, n, nob, MSG_DONTWAIT);
+       rc = kernel_recvmsg(conn->ksnc_sock, &msg, scratchiov, n, nob,
+                           MSG_DONTWAIT);
 
         if (conn->ksnc_msg.ksm_csum != 0) {
                 for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
@@ -747,7 +746,7 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int
                 return (-ESHUTDOWN);
         }
 
-        rc = libcfs_sock_getbuf(sock, txmem, rxmem);
+       rc = lnet_sock_getbuf(sock, txmem, rxmem);
         if (rc == 0) {
                 len = sizeof(*nagle);
                 set_fs(KERNEL_DS);
@@ -818,9 +817,9 @@ ksocknal_lib_setup_sock (struct socket *sock)
                 }
         }
 
-        rc = libcfs_sock_setbuf(sock,
-                                *ksocknal_tunables.ksnd_tx_buffer_size,
-                                *ksocknal_tunables.ksnd_rx_buffer_size);
+       rc = lnet_sock_setbuf(sock,
+                             *ksocknal_tunables.ksnd_tx_buffer_size,
+                             *ksocknal_tunables.ksnd_rx_buffer_size);
         if (rc != 0) {
                 CERROR ("Can't set buffer tx %d, rx %d buffers: %d\n",
                         *ksocknal_tunables.ksnd_tx_buffer_size,
@@ -1075,7 +1074,7 @@ ksocknal_lib_memory_pressure(ksock_conn_t *conn)
        sched = conn->ksnc_scheduler;
        spin_lock_bh(&sched->kss_lock);
 
-        if (!SOCK_TEST_NOSPACE(conn->ksnc_sock) &&
+       if (!test_bit(SOCK_NOSPACE, &conn->ksnc_sock->flags) &&
             !conn->ksnc_tx_ready) {
                 /* SOCK_NOSPACE is set when the socket fills
                  * and cleared in the write_space callback