Whamcloud - gitweb
i=liangzhen
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_lib-linux.c
index e702476..0689d9d 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "socklnd.h"
 
-# if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM
+# if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
 static cfs_sysctl_table_t ksocknal_ctl_table[21];
 
 cfs_sysctl_table_t ksocknal_top_ctl_table[] = {
@@ -129,7 +129,7 @@ ksocknal_lib_tunables_init ()
                 .mode     = 0644,
                 .proc_handler = &proc_dointvec
         };
-#if CPU_AFFINITY
+#ifdef CPU_AFFINITY
         ksocknal_ctl_table[i++] = (cfs_sysctl_table_t) {
                 .ctl_name = j++,
                 .procname = "irq_affinity",
@@ -191,8 +191,10 @@ ksocknal_lib_tunables_init ()
                 .proc_handler = &proc_dointvec
         };
 #endif
-        LASSERT (j == i+1);
-        LASSERT (i < sizeof(ksocknal_ctl_table)/sizeof(ksocknal_ctl_table[0]));
+        ksocknal_ctl_table[i++] =  (cfs_sysctl_table_t) { 0 };
+
+        LASSERT (j == i);
+        LASSERT (i <= sizeof(ksocknal_ctl_table)/sizeof(ksocknal_ctl_table[0]));
 
         ksocknal_tunables.ksnd_sysctl =
                 cfs_register_sysctl_table(ksocknal_top_ctl_table, 0);
@@ -225,7 +227,7 @@ ksocknal_lib_tunables_fini ()
 void
 ksocknal_lib_bind_irq (unsigned int irq)
 {
-#if (defined(CONFIG_SMP) && CPU_AFFINITY)
+#if (defined(CONFIG_SMP) && defined(CPU_AFFINITY))
         int              bind;
         int              cpu;
         char             cmdline[64];
@@ -298,7 +300,7 @@ unsigned int
 ksocknal_lib_sock_irq (struct socket *sock)
 {
         int                irq = 0;
-#if CPU_AFFINITY
+#ifdef CPU_AFFINITY
         struct dst_entry  *dst;
 
         if (!*ksocknal_tunables.ksnd_irq_affinity)
@@ -398,6 +400,7 @@ ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
         if (kiov->kiov_len >= *ksocknal_tunables.ksnd_zc_min_frag &&
             tx->tx_msg.ksm_zc_req_cookie != 0) {
                 /* Zero copy is enabled */
+                struct sock   *sk = sock->sk;
                 struct page   *page = kiov->kiov_page;
                 int            offset = kiov->kiov_offset;
                 int            fragsize = kiov->kiov_len;
@@ -410,7 +413,12 @@ ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
                     fragsize < tx->tx_resid)
                         msgflg |= MSG_MORE;
 
-                rc = tcp_sendpage(sock, page, offset, fragsize, msgflg);
+                if (sk->sk_prot->sendpage != NULL) {
+                        rc = sk->sk_prot->sendpage(sk, page,
+                                                   offset, fragsize, msgflg);
+                } else {
+                        rc = tcp_sendpage(sock, page, offset, fragsize, msgflg);
+                }
         } else {
 #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
                 struct iovec  scratch;
@@ -611,7 +619,8 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
         return (rc);
 }
 
-void ksocknal_lib_csum_tx(ksock_tx_t *tx)
+void
+ksocknal_lib_csum_tx(ksock_tx_t *tx)
 {
         int          i;
         __u32        csum;