Whamcloud - gitweb
- signal timer thread at exit.
authorisaac <isaac>
Wed, 27 Jun 2007 06:15:15 +0000 (06:15 +0000)
committerisaac <isaac>
Wed, 27 Jun 2007 06:15:15 +0000 (06:15 +0000)
-   reset crpc_bulk.bk_pages should happen after brw_check_bulk is done.

lnet/selftest/brw_test.c
lnet/selftest/timer.c

index ee2d024..da9d150 100644 (file)
@@ -164,6 +164,7 @@ brw_fill_bulk (srpc_bulk_t *bk, int pattern, __u64 magic)
 #ifdef __KERNEL__
                 pg = bk->bk_iovs[i].kiov_page;
 #else
 #ifdef __KERNEL__
                 pg = bk->bk_iovs[i].kiov_page;
 #else
+                LASSERT (bk->bk_pages != NULL);
                 pg = bk->bk_pages[i];
 #endif
                 brw_fill_page(pg, pattern, magic);
                 pg = bk->bk_pages[i];
 #endif
                 brw_fill_page(pg, pattern, magic);
@@ -180,6 +181,7 @@ brw_check_bulk (srpc_bulk_t *bk, int pattern, __u64 magic)
 #ifdef __KERNEL__
                 pg = bk->bk_iovs[i].kiov_page;
 #else
 #ifdef __KERNEL__
                 pg = bk->bk_iovs[i].kiov_page;
 #else
+                LASSERT (bk->bk_pages != NULL);
                 pg = bk->bk_pages[i];
 #endif
                 if (brw_check_page(pg, pattern, magic) != 0) {
                 pg = bk->bk_pages[i];
 #endif
                 if (brw_check_page(pg, pattern, magic) != 0) {
@@ -237,14 +239,10 @@ brw_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
 
         LASSERT (sn != NULL);
 
 
         LASSERT (sn != NULL);
 
-#ifndef __KERNEL__
-        rpc->crpc_bulk.bk_pages = NULL;
-#endif
-
         if (rpc->crpc_status != 0) {
                 CERROR ("BRW RPC to %s failed with %d\n",
                         libcfs_id2str(rpc->crpc_dest), rpc->crpc_status);
         if (rpc->crpc_status != 0) {
                 CERROR ("BRW RPC to %s failed with %d\n",
                         libcfs_id2str(rpc->crpc_dest), rpc->crpc_status);
-                return;
+                goto out;
         }
 
         if (msg->msg_magic != SRPC_MSG_MAGIC) {
         }
 
         if (msg->msg_magic != SRPC_MSG_MAGIC) {
@@ -261,10 +259,10 @@ brw_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
 
         if (reply->brw_status != 0) {
                 atomic_inc(&sn->sn_brw_errors);
 
         if (reply->brw_status != 0) {
                 atomic_inc(&sn->sn_brw_errors);
-                return;
+                goto out;
         }
 
         }
 
-        if (reqst->brw_rw == LST_BRW_WRITE) return;
+        if (reqst->brw_rw == LST_BRW_WRITE) goto out;
 
         if (brw_check_bulk(&rpc->crpc_bulk, reqst->brw_flags, magic) != 0) {
                 CERROR ("Bulk data from %s is corrupted!\n",
 
         if (brw_check_bulk(&rpc->crpc_bulk, reqst->brw_flags, magic) != 0) {
                 CERROR ("Bulk data from %s is corrupted!\n",
@@ -273,6 +271,10 @@ brw_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
                 atomic_inc(&sn->sn_brw_errors);
         }
 
                 atomic_inc(&sn->sn_brw_errors);
         }
 
+out:
+#ifndef __KERNEL__
+        rpc->crpc_bulk.bk_pages = NULL;
+#endif
         return;
 }
 
         return;
 }
 
index 97d9297..388cd8a 100644 (file)
@@ -36,6 +36,7 @@ struct st_timer_data {
         struct list_head stt_hash[STTIMER_NSLOTS];
         int              stt_shuttingdown;
 #ifdef __KERNEL__
         struct list_head stt_hash[STTIMER_NSLOTS];
         int              stt_shuttingdown;
 #ifdef __KERNEL__
+        cfs_waitq_t      stt_waitq;
         int              stt_nthreads;
 #endif
 } stt_data;
         int              stt_nthreads;
 #endif
 } stt_data;
@@ -157,9 +158,9 @@ stt_timer_main (void *arg)
         while (!stt_data.stt_shuttingdown) {
                 stt_check_timers(&stt_data.stt_prev_slot);
 
         while (!stt_data.stt_shuttingdown) {
                 stt_check_timers(&stt_data.stt_prev_slot);
 
-                set_current_state(CFS_TASK_INTERRUPTIBLE);
-                cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE,
-                                     cfs_time_seconds(STTIMER_SLOTTIME));
+                wait_event_timeout(stt_data.stt_waitq,
+                                   stt_data.stt_shuttingdown,
+                                   cfs_time_seconds(STTIMER_SLOTTIME));
         }
 
         spin_lock(&stt_data.stt_lock);
         }
 
         spin_lock(&stt_data.stt_lock);
@@ -216,9 +217,10 @@ stt_startup (void)
 
 #ifdef __KERNEL__
         stt_data.stt_nthreads = 0;
 
 #ifdef __KERNEL__
         stt_data.stt_nthreads = 0;
+        cfs_waitq_init(&stt_data.stt_waitq);
         rc = stt_start_timer_thread();
         if (rc != 0)
         rc = stt_start_timer_thread();
         if (rc != 0)
-                CERROR ("Can't spawn timer, stt_startup() has failed: %d\n", rc);
+                CERROR ("Can't spawn timer thread: %d\n", rc);
 #endif
 
         return rc;
 #endif
 
         return rc;
@@ -237,6 +239,7 @@ stt_shutdown (void)
         stt_data.stt_shuttingdown = 1;
 
 #ifdef __KERNEL__
         stt_data.stt_shuttingdown = 1;
 
 #ifdef __KERNEL__
+        cfs_waitq_signal(&stt_data.stt_waitq);
         lst_wait_until(stt_data.stt_nthreads == 0, stt_data.stt_lock,
                        "waiting for %d threads to terminate\n",
                        stt_data.stt_nthreads);
         lst_wait_until(stt_data.stt_nthreads == 0, stt_data.stt_lock,
                        "waiting for %d threads to terminate\n",
                        stt_data.stt_nthreads);