Whamcloud - gitweb
LU-12678 lnet: socklnd: mark all ksock_proto struct 'const'.
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_cb.c
index 390185d..f73039e 100644 (file)
@@ -194,10 +194,9 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx,
        int     rc;
        int     bufnob;
 
-       if (ksocknal_data.ksnd_stall_tx != 0) {
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_tx));
-       }
+       if (ksocknal_data.ksnd_stall_tx != 0)
+               schedule_timeout_uninterruptible(
+                       cfs_time_seconds(ksocknal_data.ksnd_stall_tx));
 
        LASSERT(tx->tx_resid != 0);
 
@@ -354,10 +353,9 @@ ksocknal_receive(struct ksock_conn *conn, struct page **rx_scratch_pgs,
        int     rc;
        ENTRY;
 
-       if (ksocknal_data.ksnd_stall_rx != 0) {
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_rx));
-       }
+       if (ksocknal_data.ksnd_stall_rx != 0)
+               schedule_timeout_uninterruptible(
+                       cfs_time_seconds(ksocknal_data.ksnd_stall_rx));
 
        rc = ksocknal_connsock_addref(conn);
        if (rc != 0) {
@@ -1145,22 +1143,22 @@ ksocknal_new_packet(struct ksock_conn *conn, int nob_to_skip)
         /* Set up to skip as much as possible now.  If there's more left
          * (ran out of iov entries) we'll get called again */
 
-        conn->ksnc_rx_state = SOCKNAL_RX_SLOP;
-        conn->ksnc_rx_nob_left = nob_to_skip;
+       conn->ksnc_rx_state = SOCKNAL_RX_SLOP;
+       conn->ksnc_rx_nob_left = nob_to_skip;
        conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
-        skipped = 0;
-        niov = 0;
+       skipped = 0;
+       niov = 0;
 
-        do {
-                nob = MIN (nob_to_skip, sizeof (ksocknal_slop_buffer));
+       do {
+               nob = min_t(int, nob_to_skip, sizeof(ksocknal_slop_buffer));
 
-                conn->ksnc_rx_iov[niov].iov_base = ksocknal_slop_buffer;
-                conn->ksnc_rx_iov[niov].iov_len  = nob;
-                niov++;
-                skipped += nob;
-                nob_to_skip -=nob;
+               conn->ksnc_rx_iov[niov].iov_base = ksocknal_slop_buffer;
+               conn->ksnc_rx_iov[niov].iov_len  = nob;
+               niov++;
+               skipped += nob;
+               nob_to_skip -= nob;
 
-        } while (nob_to_skip != 0 &&    /* mustn't overflow conn's rx iov */
+       } while (nob_to_skip != 0 &&    /* mustn't overflow conn's rx iov */
                 niov < sizeof(conn->ksnc_rx_iov_space) / sizeof(struct kvec));
 
         conn->ksnc_rx_niov = niov;
@@ -1702,8 +1700,8 @@ void ksocknal_write_callback(struct ksock_conn *conn)
        EXIT;
 }
 
-static struct ksock_proto *
-ksocknal_parse_proto_version (struct ksock_hello_msg *hello)
+static const struct ksock_proto *
+ksocknal_parse_proto_version(struct ksock_hello_msg *hello)
 {
         __u32   version = 0;
 
@@ -1801,7 +1799,7 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
         int                  timeout;
         int                  proto_match;
         int                  rc;
-       struct ksock_proto *proto;
+       const struct ksock_proto *proto;
        struct lnet_process_id recv_id;
 
        /* socket type set on active connections - not set on passive */
@@ -1873,11 +1871,11 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
 
         *incarnation = hello->kshm_src_incarnation;
 
-        if (hello->kshm_src_nid == LNET_NID_ANY) {
-                CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY"
-                      "from %pI4h\n", &conn->ksnc_ipaddr);
-                return -EPROTO;
-        }
+       if (hello->kshm_src_nid == LNET_NID_ANY) {
+               CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY from %pI4h\n",
+                      &conn->ksnc_ipaddr);
+               return -EPROTO;
+       }
 
         if (!active &&
             conn->ksnc_port > LNET_ACCEPTOR_MAX_RESERVED_PORT) {
@@ -2315,7 +2313,6 @@ ksocknal_connd(void *arg)
                nloops = 0;
                schedule_timeout(timeout);
 
-               set_current_state(TASK_RUNNING);
                remove_wait_queue(&ksocknal_data.ksnd_connd_waitq, &wait);
                spin_lock_bh(connd_lock);
        }
@@ -2608,7 +2605,7 @@ int ksocknal_reaper(void *arg)
        wait_queue_entry_t wait;
        struct ksock_conn *conn;
        struct ksock_sched *sched;
-       struct list_head enomem_conns;
+       LIST_HEAD(enomem_conns);
        int nenomem_conns;
        time64_t timeout;
        int i;
@@ -2617,7 +2614,6 @@ int ksocknal_reaper(void *arg)
 
         cfs_block_allsigs ();
 
-       INIT_LIST_HEAD(&enomem_conns);
        init_waitqueue_entry(&wait, current);
 
        spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);