Whamcloud - gitweb
LU-14159 build: fix gcc8 warnings on kthread_run calls
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_cb.c
index a7441fa..3cad0fd 100644 (file)
@@ -54,7 +54,7 @@ ksocknal_alloc_tx(int type, int size)
         if (tx == NULL)
                 return NULL;
 
-       atomic_set(&tx->tx_refcount, 1);
+       refcount_set(&tx->tx_refcount, 1);
        tx->tx_zc_aborted = 0;
        tx->tx_zc_capable = 0;
        tx->tx_zc_checked = 0;
@@ -455,7 +455,7 @@ ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error)
                                tx->tx_hstatus = LNET_MSG_STATUS_LOCAL_ERROR;
                }
 
-               LASSERT(atomic_read(&tx->tx_refcount) == 1);
+               LASSERT(refcount_read(&tx->tx_refcount) == 1);
                ksocknal_tx_done(ni, tx, error);
        }
 }
@@ -565,8 +565,8 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx,
 
                counter++;   /* exponential backoff warnings */
                if ((counter & (-counter)) == counter)
-                       CWARN("%u ENOMEM tx %p (%u allocated)\n",
-                             counter, conn, atomic_read(&libcfs_kmemory));
+                       CWARN("%u ENOMEM tx %p (%lld allocated)\n",
+                             counter, conn, libcfs_kmem_read());
 
                /* Queue on ksnd_enomem_conns for retry after a timeout */
                spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
@@ -1054,24 +1054,20 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 int
 ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name)
 {
-       struct task_struct *task = kthread_run(fn, arg, name);
+       struct task_struct *task = kthread_run(fn, arg, "%s", name);
 
        if (IS_ERR(task))
                return PTR_ERR(task);
 
-       write_lock_bh(&ksocknal_data.ksnd_global_lock);
-       ksocknal_data.ksnd_nthreads++;
-       write_unlock_bh(&ksocknal_data.ksnd_global_lock);
+       atomic_inc(&ksocknal_data.ksnd_nthreads);
        return 0;
 }
 
 void
 ksocknal_thread_fini (void)
 {
-       write_lock_bh(&ksocknal_data.ksnd_global_lock);
-       if (--ksocknal_data.ksnd_nthreads == 0)
+       if (atomic_dec_and_test(&ksocknal_data.ksnd_nthreads))
                wake_up_var(&ksocknal_data.ksnd_nthreads);
-       write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 }
 
 int
@@ -1164,7 +1160,7 @@ ksocknal_process_receive(struct ksock_conn *conn,
        struct lnet_process_id *id;
        int rc;
 
-       LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0);
+       LASSERT(refcount_read(&conn->ksnc_conn_refcount) > 0);
 
        /* NB: sched lock NOT held */
        /* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */