Whamcloud - gitweb
LU-4629 lov: fix sscanf format specification
[fs/lustre-release.git] / lnet / selftest / conrpc.c
index 27ad326..37455a2 100644 (file)
@@ -66,25 +66,25 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
                 * I'm just a poor body and nobody loves me */
                spin_unlock(&rpc->crpc_lock);
 
-                /* release it */
-                lstcon_rpc_put(crpc);
-                return;
-        }
+               /* release it */
+               lstcon_rpc_put(crpc);
+               return;
+       }
 
-        /* not an orphan RPC */
-        crpc->crp_finished = 1;
+       /* not an orphan RPC */
+       crpc->crp_finished = 1;
 
-        if (crpc->crp_stamp == 0) {
-                /* not aborted */
-                LASSERT (crpc->crp_status == 0);
+       if (crpc->crp_stamp == 0) {
+               /* not aborted */
+               LASSERT (crpc->crp_status == 0);
 
-                crpc->crp_stamp  = cfs_time_current();
-                crpc->crp_status = rpc->crpc_status;
-        }
+               crpc->crp_stamp  = cfs_time_current();
+               crpc->crp_status = rpc->crpc_status;
+       }
 
-        /* wakeup (transaction)thread if I'm the last RPC in the transaction */
-        if (cfs_atomic_dec_and_test(&crpc->crp_trans->tas_remaining))
-                cfs_waitq_signal(&crpc->crp_trans->tas_waitq);
+       /* wakeup (transaction)thread if I'm the last RPC in the transaction */
+       if (atomic_dec_and_test(&crpc->crp_trans->tas_remaining))
+               wake_up(&crpc->crp_trans->tas_waitq);
 
        spin_unlock(&rpc->crpc_lock);
 }
@@ -109,7 +109,7 @@ lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
        crpc->crp_embedded = embedded;
         CFS_INIT_LIST_HEAD(&crpc->crp_link);
 
-        cfs_atomic_inc(&console_session.ses_rpc_counter);
+       atomic_inc(&console_session.ses_rpc_counter);
 
         return 0;
 }
@@ -180,7 +180,7 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
        }
 
        /* RPC is not alive now */
-       cfs_atomic_dec(&console_session.ses_rpc_counter);
+       atomic_dec(&console_session.ses_rpc_counter);
 }
 
 void
@@ -190,7 +190,7 @@ lstcon_rpc_post(lstcon_rpc_t *crpc)
 
         LASSERT (trans != NULL);
 
-        cfs_atomic_inc(&trans->tas_remaining);
+       atomic_inc(&trans->tas_remaining);
         crpc->crp_posted = 1;
 
         sfw_post_rpc(crpc->crp_rpc);
@@ -265,9 +265,9 @@ lstcon_rpc_trans_prep(cfs_list_t *translist,
 
         cfs_list_add_tail(&trans->tas_link, &console_session.ses_trans_list);
 
-        CFS_INIT_LIST_HEAD(&trans->tas_rpcs_list);
-        cfs_atomic_set(&trans->tas_remaining, 0);
-        cfs_waitq_init(&trans->tas_waitq);
+       CFS_INIT_LIST_HEAD(&trans->tas_rpcs_list);
+       atomic_set(&trans->tas_remaining, 0);
+       init_waitqueue_head(&trans->tas_waitq);
 
        spin_lock(&console_session.ses_rpc_lock);
        trans->tas_features = console_session.ses_features;
@@ -333,7 +333,7 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
             !cfs_list_empty(&trans->tas_olink)) /* Not an end session RPC */
                 return 1;
 
-        return (cfs_atomic_read(&trans->tas_remaining) == 0) ? 1: 0;
+       return (atomic_read(&trans->tas_remaining) == 0) ? 1: 0;
 }
 
 int
@@ -361,9 +361,9 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
 
        mutex_unlock(&console_session.ses_mutex);
 
-        cfs_waitq_wait_event_interruptible_timeout(trans->tas_waitq,
-                                              lstcon_rpc_trans_check(trans),
-                                              cfs_time_seconds(timeout), rc);
+       rc = wait_event_interruptible_timeout(trans->tas_waitq,
+                                             lstcon_rpc_trans_check(trans),
+                                             cfs_time_seconds(timeout));
 
         rc = (rc > 0)? 0: ((rc < 0)? -EINTR: -ETIMEDOUT);
 
@@ -586,10 +586,10 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
 
                spin_unlock(&rpc->crpc_lock);
 
-                cfs_atomic_dec(&trans->tas_remaining);
+               atomic_dec(&trans->tas_remaining);
         }
 
-        LASSERT (cfs_atomic_read(&trans->tas_remaining) == 0);
+       LASSERT (atomic_read(&trans->tas_remaining) == 0);
 
         cfs_list_del(&trans->tas_link);
         if (!cfs_list_empty(&trans->tas_olink))
@@ -949,8 +949,12 @@ lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
                return status;
 
        if (!trans->tas_feats_updated) {
-               trans->tas_feats_updated = 1;
-               trans->tas_features = reply->msg_ses_feats;
+               spin_lock(&console_session.ses_rpc_lock);
+               if (!trans->tas_feats_updated) { /* recheck with lock */
+                       trans->tas_feats_updated = 1;
+                       trans->tas_features = reply->msg_ses_feats;
+               }
+               spin_unlock(&console_session.ses_rpc_lock);
        }
 
        if (reply->msg_ses_feats != trans->tas_features) {
@@ -1300,7 +1304,7 @@ lstcon_rpc_pinger_start(void)
         int             rc;
 
         LASSERT (cfs_list_empty(&console_session.ses_rpc_freelist));
-        LASSERT (cfs_atomic_read(&console_session.ses_rpc_counter) == 0);
+       LASSERT (atomic_read(&console_session.ses_rpc_counter) == 0);
 
         rc = lstcon_rpc_trans_prep(NULL, LST_TRANS_SESPING,
                                    &console_session.ses_ping);
@@ -1350,11 +1354,11 @@ lstcon_rpc_cleanup_wait(void)
                         trans = cfs_list_entry(pacer, lstcon_rpc_trans_t,
                                                tas_link);
 
-                        CDEBUG(D_NET, "Session closed, wakeup transaction %s\n",
-                               lstcon_rpc_trans_name(trans->tas_opc));
+                       CDEBUG(D_NET, "Session closed, wakeup transaction %s\n",
+                              lstcon_rpc_trans_name(trans->tas_opc));
 
-                        cfs_waitq_signal(&trans->tas_waitq);
-                }
+                       wake_up(&trans->tas_waitq);
+               }
 
                mutex_unlock(&console_session.ses_mutex);
 
@@ -1367,11 +1371,11 @@ lstcon_rpc_cleanup_wait(void)
 
        spin_lock(&console_session.ses_rpc_lock);
 
-        lst_wait_until((cfs_atomic_read(&console_session.ses_rpc_counter) == 0),
+       lst_wait_until((atomic_read(&console_session.ses_rpc_counter) == 0),
                        console_session.ses_rpc_lock,
                        "Network is not accessable or target is down, "
                        "waiting for %d console RPCs to being recycled\n",
-                       cfs_atomic_read(&console_session.ses_rpc_counter));
+                      atomic_read(&console_session.ses_rpc_counter));
 
         cfs_list_add(&zlist, &console_session.ses_rpc_freelist);
         cfs_list_del_init(&console_session.ses_rpc_freelist);
@@ -1396,7 +1400,7 @@ lstcon_rpc_module_init(void)
         console_session.ses_ping = NULL;
 
        spin_lock_init(&console_session.ses_rpc_lock);
-       cfs_atomic_set(&console_session.ses_rpc_counter, 0);
+       atomic_set(&console_session.ses_rpc_counter, 0);
        CFS_INIT_LIST_HEAD(&console_session.ses_rpc_freelist);
 
        return 0;
@@ -1406,7 +1410,7 @@ void
 lstcon_rpc_module_fini(void)
 {
         LASSERT (cfs_list_empty(&console_session.ses_rpc_freelist));
-        LASSERT (cfs_atomic_read(&console_session.ses_rpc_counter) == 0);
+       LASSERT (atomic_read(&console_session.ses_rpc_counter) == 0);
 }
 
 #endif