From 03fe49eee6d3ae66042950bfc34239ef2c2a89e0 Mon Sep 17 00:00:00 2001 From: isaac Date: Wed, 27 Jun 2007 06:15:15 +0000 Subject: [PATCH] - signal timer thread at exit. - reset crpc_bulk.bk_pages should happen after brw_check_bulk is done. --- lnet/selftest/brw_test.c | 16 +++++++++------- lnet/selftest/timer.c | 11 +++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lnet/selftest/brw_test.c b/lnet/selftest/brw_test.c index ee2d024..da9d150 100644 --- a/lnet/selftest/brw_test.c +++ b/lnet/selftest/brw_test.c @@ -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 + LASSERT (bk->bk_pages != NULL); 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 + LASSERT (bk->bk_pages != NULL); 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); -#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); - return; + goto out; } 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); - 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", @@ -273,6 +271,10 @@ brw_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) atomic_inc(&sn->sn_brw_errors); } +out: +#ifndef __KERNEL__ + rpc->crpc_bulk.bk_pages = NULL; +#endif return; } diff --git a/lnet/selftest/timer.c b/lnet/selftest/timer.c index 97d9297..388cd8a 100644 --- a/lnet/selftest/timer.c +++ b/lnet/selftest/timer.c @@ -36,6 +36,7 @@ struct st_timer_data { struct list_head stt_hash[STTIMER_NSLOTS]; int stt_shuttingdown; #ifdef __KERNEL__ + cfs_waitq_t stt_waitq; 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); - 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); @@ -216,9 +217,10 @@ stt_startup (void) #ifdef __KERNEL__ stt_data.stt_nthreads = 0; + cfs_waitq_init(&stt_data.stt_waitq); 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; @@ -237,6 +239,7 @@ stt_shutdown (void) 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); -- 1.8.3.1