Whamcloud - gitweb
LU-17705 ptlrpc: replace synchronize_rcu() with rcu_barrier()
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_lib.c
index 023ca82..f5e4b87 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #include "socklnd.h"
  */
 
 #include "socklnd.h"
@@ -110,6 +109,25 @@ ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx,
        return rc;
 }
 
        return rc;
 }
 
+static int
+ksocknal_lib_sendpage(struct socket *sock, struct bio_vec *kiov, int msgflg)
+{
+#ifdef MSG_SPLICE_PAGES
+       struct msghdr msg = {.msg_flags = msgflg | MSG_SPLICE_PAGES};
+
+       iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, kiov, 1, kiov->bv_len);
+
+       return sock_sendmsg(sock, &msg);
+#else
+       struct sock   *sk = sock->sk;
+       struct page *page = kiov->bv_page;
+       int offset = kiov->bv_offset;
+       int fragsize = kiov->bv_len;
+
+       return sk->sk_prot->sendpage(sk, page, offset, fragsize, msgflg);
+#endif
+}
+
 int
 ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx,
                       struct kvec *scratchiov)
 int
 ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx,
                       struct kvec *scratchiov)
@@ -126,21 +144,16 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx,
         * or leave them alone. */
        if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
                /* Zero copy is enabled */
         * or leave them alone. */
        if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
                /* Zero copy is enabled */
-               struct sock   *sk = sock->sk;
-               struct page   *page = kiov->bv_page;
-               int            offset = kiov->bv_offset;
-               int            fragsize = kiov->bv_len;
                int            msgflg = MSG_DONTWAIT;
 
                CDEBUG(D_NET, "page %p + offset %x for %d\n",
                int            msgflg = MSG_DONTWAIT;
 
                CDEBUG(D_NET, "page %p + offset %x for %d\n",
-                              page, offset, kiov->bv_len);
+                              kiov->bv_page, kiov->bv_offset, kiov->bv_len);
 
                if (!list_empty(&conn->ksnc_tx_queue) ||
 
                if (!list_empty(&conn->ksnc_tx_queue) ||
-                   fragsize < tx->tx_resid)
+                   kiov->bv_len < tx->tx_resid)
                        msgflg |= MSG_MORE;
 
                        msgflg |= MSG_MORE;
 
-               rc = sk->sk_prot->sendpage(sk, page,
-                                          offset, fragsize, msgflg);
+               rc = ksocknal_lib_sendpage(sock, kiov, msgflg);
        } else {
 #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
                struct kvec     scratch;
        } else {
 #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
                struct kvec     scratch;
@@ -427,7 +440,7 @@ ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem, int *rxmem,
 }
 
 int
 }
 
 int
-ksocknal_lib_setup_sock (struct socket *sock)
+ksocknal_lib_setup_sock(struct socket *sock, struct lnet_ni *ni)
 {
        int rc;
        int keep_idle;
 {
        int rc;
        int keep_idle;
@@ -435,6 +448,7 @@ ksocknal_lib_setup_sock (struct socket *sock)
        int keep_count;
        int do_keepalive;
        struct tcp_sock *tp = tcp_sk(sock->sk);
        int keep_count;
        int do_keepalive;
        struct tcp_sock *tp = tcp_sk(sock->sk);
+       struct lnet_ioctl_config_socklnd_tunables *lndtun;
 
        sock->sk->sk_allocation = GFP_NOFS;
 
 
        sock->sk->sk_allocation = GFP_NOFS;
 
@@ -530,6 +544,10 @@ ksocknal_lib_setup_sock (struct socket *sock)
                return rc;
        }
 
                return rc;
        }
 
+       lndtun = &ni->ni_lnd_tunables.lnd_tun_u.lnd_sock;
+       if (lndtun->lnd_tos >= 0)
+               ip_sock_set_tos(sock->sk, lndtun->lnd_tos);
+
        return (0);
 }
 
        return (0);
 }
 
@@ -575,11 +593,10 @@ ksocknal_data_ready(struct sock *sk, int n)
 #endif
 {
        struct ksock_conn  *conn;
 #endif
 {
        struct ksock_conn  *conn;
-       ENTRY;
 
         /* interleave correctly with closing sockets... */
         LASSERT(!in_irq());
 
         /* interleave correctly with closing sockets... */
         LASSERT(!in_irq());
-       read_lock(&ksocknal_data.ksnd_global_lock);
+       read_lock_bh(&ksocknal_data.ksnd_global_lock);
 
        conn = sk->sk_user_data;
        if (conn == NULL) {     /* raced with ksocknal_terminate_conn */
 
        conn = sk->sk_user_data;
        if (conn == NULL) {     /* raced with ksocknal_terminate_conn */
@@ -592,9 +609,7 @@ ksocknal_data_ready(struct sock *sk, int n)
        } else
                ksocknal_read_callback(conn);
 
        } else
                ksocknal_read_callback(conn);
 
-       read_unlock(&ksocknal_data.ksnd_global_lock);
-
-       EXIT;
+       read_unlock_bh(&ksocknal_data.ksnd_global_lock);
 }
 
 static void
 }
 
 static void