1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5 * Authors: Isaac Huang <isaac@clusterfs.com>
6 * Liang Zhen <liangzhen@clusterfs.com>
9 #define DEBUG_SUBSYSTEM S_LNET
13 int brw_inject_errors = 0;
14 CFS_MODULE_PARM(brw_inject_errors, "i", int, 0644,
15 "# data errors to inject randomly, zero by default");
17 static int session_timeout = 100;
18 CFS_MODULE_PARM(session_timeout, "i", int, 0444,
19 "test session timeout in seconds (100 by default, 0 == never)");
21 #define SFW_TEST_CONCURRENCY 128
22 #define SFW_TEST_RPC_TIMEOUT 64
23 #define SFW_CLIENT_RPC_TIMEOUT 64 /* in seconds */
24 #define SFW_EXTRA_TEST_BUFFERS 8 /* tolerate buggy peers with extra buffers */
26 #define sfw_test_buffers(tsi) ((tsi)->tsi_loop + SFW_EXTRA_TEST_BUFFERS)
28 #define sfw_unpack_id(id) \
30 __swab64s(&(id).nid); \
31 __swab32s(&(id).pid); \
34 #define sfw_unpack_sid(sid) \
36 __swab64s(&(sid).ses_nid); \
37 __swab64s(&(sid).ses_stamp); \
40 #define sfw_unpack_fw_counters(fc) \
42 __swab32s(&(fc).brw_errors); \
43 __swab32s(&(fc).ping_errors); \
44 __swab32s(&(fc).active_tests); \
45 __swab32s(&(fc).active_batches); \
46 __swab32s(&(fc).zombie_sessions); \
49 #define sfw_unpack_rpc_counters(rc) \
51 __swab32s(&(rc).errors); \
52 __swab32s(&(rc).rpcs_sent); \
53 __swab32s(&(rc).rpcs_rcvd); \
54 __swab32s(&(rc).rpcs_dropped); \
55 __swab32s(&(rc).rpcs_expired); \
56 __swab64s(&(rc).bulk_get); \
57 __swab64s(&(rc).bulk_put); \
60 #define sfw_unpack_lnet_counters(lc) \
62 __swab32s(&(lc).errors); \
63 __swab32s(&(lc).msgs_max); \
64 __swab32s(&(lc).msgs_alloc); \
65 __swab32s(&(lc).send_count); \
66 __swab32s(&(lc).recv_count); \
67 __swab32s(&(lc).drop_count); \
68 __swab32s(&(lc).route_count); \
69 __swab64s(&(lc).send_length); \
70 __swab64s(&(lc).recv_length); \
71 __swab64s(&(lc).drop_length); \
72 __swab64s(&(lc).route_length); \
75 #define sfw_test_active(t) (atomic_read(&(t)->tsi_nactive) != 0)
76 #define sfw_batch_active(b) (atomic_read(&(b)->bat_nactive) != 0)
78 struct smoketest_framework {
79 struct list_head fw_zombie_rpcs; /* RPCs to be recycled */
80 struct list_head fw_zombie_sessions; /* stopping sessions */
81 struct list_head fw_tests; /* registered test cases */
82 atomic_t fw_nzombies; /* # zombie sessions */
83 spinlock_t fw_lock; /* serialise */
84 sfw_session_t *fw_session; /* _the_ session */
85 int fw_shuttingdown; /* shutdown in progress */
86 srpc_server_rpc_t *fw_active_srpc; /* running RPC */
90 int sfw_stop_batch (sfw_batch_t *tsb, int force);
91 void sfw_destroy_session (sfw_session_t *sn);
93 static inline sfw_test_case_t *
94 sfw_find_test_case(int id)
98 LASSERT (id <= SRPC_SERVICE_MAX_ID);
99 LASSERT (id > SRPC_FRAMEWORK_SERVICE_MAX_ID);
101 list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
102 if (tsc->tsc_srv_service->sv_id == id)
110 sfw_register_test (srpc_service_t *service, sfw_test_client_ops_t *cliops)
112 sfw_test_case_t *tsc;
114 if (sfw_find_test_case(service->sv_id) != NULL) {
115 CERROR ("Failed to register test %s (%d)\n",
116 service->sv_name, service->sv_id);
120 LIBCFS_ALLOC(tsc, sizeof(sfw_test_case_t));
124 memset(tsc, 0, sizeof(sfw_test_case_t));
125 tsc->tsc_cli_ops = cliops;
126 tsc->tsc_srv_service = service;
128 list_add_tail(&tsc->tsc_list, &sfw_data.fw_tests);
133 sfw_add_session_timer (void)
135 sfw_session_t *sn = sfw_data.fw_session;
136 stt_timer_t *timer = &sn->sn_timer;
138 LASSERT (!sfw_data.fw_shuttingdown);
140 if (sn == NULL || sn->sn_timeout == 0)
143 LASSERT (!sn->sn_timer_active);
145 sn->sn_timer_active = 1;
146 timer->stt_expires = cfs_time_add(sn->sn_timeout,
147 cfs_time_current_sec());
148 stt_add_timer(timer);
153 sfw_del_session_timer (void)
155 sfw_session_t *sn = sfw_data.fw_session;
157 if (sn == NULL || !sn->sn_timer_active)
160 LASSERT (sn->sn_timeout != 0);
162 if (stt_del_timer(&sn->sn_timer)) { /* timer defused */
163 sn->sn_timer_active = 0;
168 /* Racing is impossible in single-threaded userland selftest */
171 return EBUSY; /* racing with sfw_session_expired() */
174 /* called with sfw_data.fw_lock held */
176 sfw_deactivate_session (void)
178 sfw_session_t *sn = sfw_data.fw_session;
182 if (sn == NULL) return;
184 LASSERT (!sn->sn_timer_active);
186 sfw_data.fw_session = NULL;
187 atomic_inc(&sfw_data.fw_nzombies);
188 list_add(&sn->sn_list, &sfw_data.fw_zombie_sessions);
190 list_for_each_entry (tsb, &sn->sn_batches, bat_list) {
191 if (sfw_batch_active(tsb)) {
193 sfw_stop_batch(tsb, 1);
198 return; /* wait for active batches to stop */
200 list_del_init(&sn->sn_list);
201 spin_unlock(&sfw_data.fw_lock);
203 sfw_destroy_session(sn);
205 spin_lock(&sfw_data.fw_lock);
212 sfw_session_removed (void)
214 return (sfw_data.fw_session == NULL) ? 1 : 0;
220 sfw_session_expired (void *data)
222 sfw_session_t *sn = data;
224 spin_lock(&sfw_data.fw_lock);
226 LASSERT (sn->sn_timer_active);
227 LASSERT (sn == sfw_data.fw_session);
229 CWARN ("Session expired! sid: %s-"LPU64", name: %s\n",
230 libcfs_nid2str(sn->sn_id.ses_nid),
231 sn->sn_id.ses_stamp, &sn->sn_name[0]);
233 sn->sn_timer_active = 0;
234 sfw_deactivate_session();
236 spin_unlock(&sfw_data.fw_lock);
241 sfw_init_session (sfw_session_t *sn, lst_sid_t sid, const char *name)
243 stt_timer_t *timer = &sn->sn_timer;
245 memset(sn, 0, sizeof(sfw_session_t));
246 CFS_INIT_LIST_HEAD(&sn->sn_list);
247 CFS_INIT_LIST_HEAD(&sn->sn_batches);
248 atomic_set(&sn->sn_brw_errors, 0);
249 atomic_set(&sn->sn_ping_errors, 0);
250 strncpy(&sn->sn_name[0], name, LST_NAME_SIZE);
252 sn->sn_timer_active = 0;
254 sn->sn_timeout = session_timeout;
256 timer->stt_data = sn;
257 timer->stt_func = sfw_session_expired;
258 CFS_INIT_LIST_HEAD(&timer->stt_list);
261 /* completion handler for incoming framework RPCs */
263 sfw_server_rpc_done (srpc_server_rpc_t *rpc)
265 srpc_service_t *sv = rpc->srpc_service;
266 int status = rpc->srpc_status;
269 "Incoming framework RPC done: "
270 "service %s, peer %s, status %s:%d\n",
271 sv->sv_name, libcfs_id2str(rpc->srpc_peer),
272 swi_state2str(rpc->srpc_wi.wi_state),
275 if (rpc->srpc_bulk != NULL)
281 sfw_client_rpc_fini (srpc_client_rpc_t *rpc)
283 LASSERT (rpc->crpc_bulk.bk_niov == 0);
284 LASSERT (list_empty(&rpc->crpc_list));
285 LASSERT (atomic_read(&rpc->crpc_refcount) == 0);
287 LASSERT (rpc->crpc_bulk.bk_pages == NULL);
291 "Outgoing framework RPC done: "
292 "service %d, peer %s, status %s:%d:%d\n",
293 rpc->crpc_service, libcfs_id2str(rpc->crpc_dest),
294 swi_state2str(rpc->crpc_wi.wi_state),
295 rpc->crpc_aborted, rpc->crpc_status);
297 spin_lock(&sfw_data.fw_lock);
299 /* my callers must finish all RPCs before shutting me down */
300 LASSERT (!sfw_data.fw_shuttingdown);
301 list_add(&rpc->crpc_list, &sfw_data.fw_zombie_rpcs);
303 spin_unlock(&sfw_data.fw_lock);
308 sfw_find_batch (lst_bid_t bid)
310 sfw_session_t *sn = sfw_data.fw_session;
313 LASSERT (sn != NULL);
315 list_for_each_entry (bat, &sn->sn_batches, bat_list) {
316 if (bat->bat_id.bat_id == bid.bat_id)
324 sfw_bid2batch (lst_bid_t bid)
326 sfw_session_t *sn = sfw_data.fw_session;
329 LASSERT (sn != NULL);
331 bat = sfw_find_batch(bid);
335 LIBCFS_ALLOC(bat, sizeof(sfw_batch_t));
340 bat->bat_session = sn;
342 atomic_set(&bat->bat_nactive, 0);
343 CFS_INIT_LIST_HEAD(&bat->bat_tests);
345 list_add_tail(&bat->bat_list, &sn->sn_batches);
350 sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
352 sfw_session_t *sn = sfw_data.fw_session;
353 sfw_counters_t *cnt = &reply->str_fw;
356 reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
358 if (request->str_sid.ses_nid == LNET_NID_ANY) {
359 reply->str_status = EINVAL;
363 if (sn == NULL || !sfw_sid_equal(request->str_sid, sn->sn_id)) {
364 reply->str_status = ESRCH;
369 reply->str_lnet = the_lnet.ln_counters;
372 srpc_get_counters(&reply->str_rpc);
374 cnt->brw_errors = atomic_read(&sn->sn_brw_errors);
375 cnt->ping_errors = atomic_read(&sn->sn_ping_errors);
376 cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies);
378 cnt->active_tests = cnt->active_batches = 0;
379 list_for_each_entry (bat, &sn->sn_batches, bat_list) {
380 int n = atomic_read(&bat->bat_nactive);
383 cnt->active_batches++;
384 cnt->active_tests += n;
388 reply->str_status = 0;
393 sfw_make_session (srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply)
395 sfw_session_t *sn = sfw_data.fw_session;
397 if (request->mksn_sid.ses_nid == LNET_NID_ANY) {
398 reply->mksn_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
399 reply->mksn_status = EINVAL;
403 if (sn != NULL && !request->mksn_force) {
404 reply->mksn_sid = sn->sn_id;
405 reply->mksn_status = EBUSY;
406 strncpy(&reply->mksn_name[0], &sn->sn_name[0], LST_NAME_SIZE);
410 LIBCFS_ALLOC(sn, sizeof(sfw_session_t));
412 CERROR ("Dropping RPC (mksn) under memory pressure.\n");
416 sfw_init_session(sn, request->mksn_sid, &request->mksn_name[0]);
418 spin_lock(&sfw_data.fw_lock);
420 sfw_deactivate_session();
421 LASSERT (sfw_data.fw_session == NULL);
422 sfw_data.fw_session = sn;
424 spin_unlock(&sfw_data.fw_lock);
426 reply->mksn_status = 0;
427 reply->mksn_sid = sn->sn_id;
428 reply->mksn_timeout = sn->sn_timeout;
433 sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply)
435 sfw_session_t *sn = sfw_data.fw_session;
437 reply->rmsn_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
439 if (request->rmsn_sid.ses_nid == LNET_NID_ANY) {
440 reply->rmsn_status = EINVAL;
444 if (sn == NULL || !sfw_sid_equal(request->rmsn_sid, sn->sn_id)) {
445 reply->rmsn_status = (sn == NULL) ? ESRCH : EBUSY;
449 spin_lock(&sfw_data.fw_lock);
450 sfw_deactivate_session();
451 spin_unlock(&sfw_data.fw_lock);
453 reply->rmsn_status = 0;
454 reply->rmsn_sid = LST_INVALID_SID;
455 LASSERT (sfw_data.fw_session == NULL);
460 sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
462 sfw_session_t *sn = sfw_data.fw_session;
465 reply->dbg_status = ESRCH;
466 reply->dbg_sid = LST_INVALID_SID;
470 reply->dbg_status = 0;
471 reply->dbg_sid = sn->sn_id;
472 reply->dbg_timeout = sn->sn_timeout;
473 strncpy(reply->dbg_name, &sn->sn_name[0], LST_NAME_SIZE);
479 sfw_test_rpc_fini (srpc_client_rpc_t *rpc)
481 sfw_test_unit_t *tsu = rpc->crpc_priv;
482 sfw_test_instance_t *tsi = tsu->tsu_instance;
484 /* Called with hold of tsi->tsi_lock */
485 LASSERT (list_empty(&rpc->crpc_list));
486 list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs);
490 sfw_load_test (sfw_test_instance_t *tsi)
492 sfw_test_case_t *tsc = sfw_find_test_case(tsi->tsi_service);
493 int nrequired = sfw_test_buffers(tsi);
496 LASSERT (tsc != NULL);
498 if (tsi->tsi_is_client) {
499 tsi->tsi_ops = tsc->tsc_cli_ops;
503 nposted = srpc_service_add_buffers(tsc->tsc_srv_service, nrequired);
504 if (nposted != nrequired) {
505 CWARN ("Failed to reserve enough buffers: "
506 "service %s, %d needed, %d reserved\n",
507 tsc->tsc_srv_service->sv_name, nrequired, nposted);
508 srpc_service_remove_buffers(tsc->tsc_srv_service, nposted);
512 CDEBUG (D_NET, "Reserved %d buffers for test %s\n",
513 nposted, tsc->tsc_srv_service->sv_name);
518 sfw_unload_test (sfw_test_instance_t *tsi)
520 sfw_test_case_t *tsc = sfw_find_test_case(tsi->tsi_service);
522 LASSERT (tsc != NULL);
524 if (!tsi->tsi_is_client)
525 srpc_service_remove_buffers(tsc->tsc_srv_service,
526 sfw_test_buffers(tsi));
531 sfw_destroy_test_instance (sfw_test_instance_t *tsi)
533 srpc_client_rpc_t *rpc;
534 sfw_test_unit_t *tsu;
536 if (!tsi->tsi_is_client) goto clean;
538 tsi->tsi_ops->tso_fini(tsi);
540 LASSERT (!tsi->tsi_stopping);
541 LASSERT (list_empty(&tsi->tsi_active_rpcs));
542 LASSERT (!sfw_test_active(tsi));
544 while (!list_empty(&tsi->tsi_units)) {
545 tsu = list_entry(tsi->tsi_units.next,
546 sfw_test_unit_t, tsu_list);
547 list_del(&tsu->tsu_list);
548 LIBCFS_FREE(tsu, sizeof(*tsu));
551 while (!list_empty(&tsi->tsi_free_rpcs)) {
552 rpc = list_entry(tsi->tsi_free_rpcs.next,
553 srpc_client_rpc_t, crpc_list);
554 list_del(&rpc->crpc_list);
555 LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
559 sfw_unload_test(tsi);
560 LIBCFS_FREE(tsi, sizeof(*tsi));
565 sfw_destroy_batch (sfw_batch_t *tsb)
567 sfw_test_instance_t *tsi;
569 LASSERT (!sfw_batch_active(tsb));
570 LASSERT (list_empty(&tsb->bat_list));
572 while (!list_empty(&tsb->bat_tests)) {
573 tsi = list_entry(tsb->bat_tests.next,
574 sfw_test_instance_t, tsi_list);
575 list_del_init(&tsi->tsi_list);
576 sfw_destroy_test_instance(tsi);
579 LIBCFS_FREE(tsb, sizeof(sfw_batch_t));
584 sfw_destroy_session (sfw_session_t *sn)
588 LASSERT (list_empty(&sn->sn_list));
589 LASSERT (sn != sfw_data.fw_session);
591 while (!list_empty(&sn->sn_batches)) {
592 batch = list_entry(sn->sn_batches.next,
593 sfw_batch_t, bat_list);
594 list_del_init(&batch->bat_list);
595 sfw_destroy_batch(batch);
598 LIBCFS_FREE(sn, sizeof(*sn));
599 atomic_dec(&sfw_data.fw_nzombies);
604 sfw_unpack_test_req (srpc_msg_t *msg)
606 srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
608 LASSERT (msg->msg_type == SRPC_MSG_TEST_REQST);
609 LASSERT (req->tsr_is_client);
611 if (msg->msg_magic == SRPC_MSG_MAGIC)
612 return; /* no flipping needed */
614 LASSERT (msg->msg_magic == __swab32(SRPC_MSG_MAGIC));
616 if (req->tsr_service == SRPC_SERVICE_BRW) {
617 test_bulk_req_t *bulk = &req->tsr_u.bulk;
619 __swab32s(&bulk->blk_opc);
620 __swab32s(&bulk->blk_npg);
621 __swab32s(&bulk->blk_flags);
625 if (req->tsr_service == SRPC_SERVICE_PING) {
626 test_ping_req_t *ping = &req->tsr_u.ping;
628 __swab32s(&ping->png_size);
629 __swab32s(&ping->png_flags);
638 sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
640 srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg;
641 srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
642 srpc_bulk_t *bk = rpc->srpc_bulk;
643 int ndest = req->tsr_ndest;
644 sfw_test_unit_t *tsu;
645 sfw_test_instance_t *tsi;
649 LIBCFS_ALLOC(tsi, sizeof(*tsi));
651 CERROR ("Can't allocate test instance for batch: "LPU64"\n",
656 memset(tsi, 0, sizeof(*tsi));
657 spin_lock_init(&tsi->tsi_lock);
658 atomic_set(&tsi->tsi_nactive, 0);
659 CFS_INIT_LIST_HEAD(&tsi->tsi_units);
660 CFS_INIT_LIST_HEAD(&tsi->tsi_free_rpcs);
661 CFS_INIT_LIST_HEAD(&tsi->tsi_active_rpcs);
663 tsi->tsi_stopping = 0;
664 tsi->tsi_batch = tsb;
665 tsi->tsi_loop = req->tsr_loop;
666 tsi->tsi_concur = req->tsr_concur;
667 tsi->tsi_service = req->tsr_service;
668 tsi->tsi_is_client = !!(req->tsr_is_client);
669 tsi->tsi_stoptsu_onerr = !!(req->tsr_stop_onerr);
671 rc = sfw_load_test(tsi);
673 LIBCFS_FREE(tsi, sizeof(*tsi));
677 LASSERT (!sfw_batch_active(tsb));
679 if (!tsi->tsi_is_client) {
680 /* it's test server, just add it to tsb */
681 list_add_tail(&tsi->tsi_list, &tsb->bat_tests);
685 LASSERT (bk != NULL);
687 LASSERT (bk->bk_pages != NULL);
689 LASSERT (bk->bk_niov * SFW_ID_PER_PAGE >= ndest);
690 LASSERT (bk->bk_len >= sizeof(lnet_process_id_t) * ndest);
692 sfw_unpack_test_req(msg);
693 memcpy(&tsi->tsi_u, &req->tsr_u, sizeof(tsi->tsi_u));
695 for (i = 0; i < ndest; i++) {
696 lnet_process_id_t *dests;
697 lnet_process_id_t id;
701 dests = cfs_page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page);
702 LASSERT (dests != NULL); /* my pages are within KVM always */
704 dests = cfs_page_address(bk->bk_pages[i / SFW_ID_PER_PAGE]);
706 id = dests[i % SFW_ID_PER_PAGE];
707 if (msg->msg_magic != SRPC_MSG_MAGIC)
710 for (j = 0; j < tsi->tsi_concur; j++) {
711 LIBCFS_ALLOC(tsu, sizeof(sfw_test_unit_t));
714 CERROR ("Can't allocate tsu for %d\n",
720 tsu->tsu_instance = tsi;
721 tsu->tsu_private = NULL;
722 list_add_tail(&tsu->tsu_list, &tsi->tsi_units);
726 rc = tsi->tsi_ops->tso_init(tsi);
728 list_add_tail(&tsi->tsi_list, &tsb->bat_tests);
734 sfw_destroy_test_instance(tsi);
739 sfw_test_unit_done (sfw_test_unit_t *tsu)
741 sfw_test_instance_t *tsi = tsu->tsu_instance;
742 sfw_batch_t *tsb = tsi->tsi_batch;
743 sfw_session_t *sn = tsb->bat_session;
745 LASSERT (sfw_test_active(tsi));
747 if (!atomic_dec_and_test(&tsi->tsi_nactive))
750 /* the test instance is done */
751 spin_lock(&tsi->tsi_lock);
753 tsi->tsi_stopping = 0;
755 spin_unlock(&tsi->tsi_lock);
757 spin_lock(&sfw_data.fw_lock);
759 if (!atomic_dec_and_test(&tsb->bat_nactive) || /* tsb still active */
760 sn == sfw_data.fw_session) { /* sn also active */
761 spin_unlock(&sfw_data.fw_lock);
765 LASSERT (!list_empty(&sn->sn_list)); /* I'm a zombie! */
767 list_for_each_entry (tsb, &sn->sn_batches, bat_list) {
768 if (sfw_batch_active(tsb)) {
769 spin_unlock(&sfw_data.fw_lock);
774 list_del_init(&sn->sn_list);
775 spin_unlock(&sfw_data.fw_lock);
777 sfw_destroy_session(sn);
782 sfw_test_rpc_done (srpc_client_rpc_t *rpc)
784 sfw_test_unit_t *tsu = rpc->crpc_priv;
785 sfw_test_instance_t *tsi = tsu->tsu_instance;
788 tsi->tsi_ops->tso_done_rpc(tsu, rpc);
790 spin_lock(&tsi->tsi_lock);
792 LASSERT (sfw_test_active(tsi));
793 LASSERT (!list_empty(&rpc->crpc_list));
795 list_del_init(&rpc->crpc_list);
797 /* batch is stopping or loop is done or get error */
798 if (tsi->tsi_stopping ||
799 tsu->tsu_loop == 0 ||
800 (rpc->crpc_status != 0 && tsi->tsi_stoptsu_onerr))
803 /* dec ref for poster */
804 srpc_client_rpc_decref(rpc);
806 spin_unlock(&tsi->tsi_lock);
809 swi_schedule_workitem(&tsu->tsu_worker);
813 sfw_test_unit_done(tsu);
818 sfw_create_test_rpc (sfw_test_unit_t *tsu, lnet_process_id_t peer,
819 int nblk, int blklen, srpc_client_rpc_t **rpcpp)
821 srpc_client_rpc_t *rpc = NULL;
822 sfw_test_instance_t *tsi = tsu->tsu_instance;
824 spin_lock(&tsi->tsi_lock);
826 LASSERT (sfw_test_active(tsi));
828 if (!list_empty(&tsi->tsi_free_rpcs)) {
829 /* pick request from buffer */
830 rpc = list_entry(tsi->tsi_free_rpcs.next,
831 srpc_client_rpc_t, crpc_list);
832 LASSERT (nblk == rpc->crpc_bulk.bk_niov);
833 list_del_init(&rpc->crpc_list);
835 srpc_init_client_rpc(rpc, peer, tsi->tsi_service, nblk,
836 blklen, sfw_test_rpc_done,
837 sfw_test_rpc_fini, tsu);
840 spin_unlock(&tsi->tsi_lock);
843 rpc = srpc_create_client_rpc(peer, tsi->tsi_service, nblk,
844 blklen, sfw_test_rpc_done,
845 sfw_test_rpc_fini, tsu);
847 CERROR ("Can't create rpc for test %d\n", tsi->tsi_service);
856 sfw_run_test (swi_workitem_t *wi)
858 sfw_test_unit_t *tsu = wi->wi_data;
859 sfw_test_instance_t *tsi = tsu->tsu_instance;
860 srpc_client_rpc_t *rpc = NULL;
862 LASSERT (wi == &tsu->tsu_worker);
864 if (tsi->tsi_ops->tso_prep_rpc(tsu, tsu->tsu_dest, &rpc) != 0) {
865 LASSERT (rpc == NULL);
869 LASSERT (rpc != NULL);
871 spin_lock(&tsi->tsi_lock);
873 if (tsi->tsi_stopping) {
874 list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs);
875 spin_unlock(&tsi->tsi_lock);
879 if (tsu->tsu_loop > 0)
882 list_add_tail(&rpc->crpc_list, &tsi->tsi_active_rpcs);
883 spin_unlock(&tsi->tsi_lock);
885 rpc->crpc_timeout = SFW_TEST_RPC_TIMEOUT;
887 spin_lock(&rpc->crpc_lock);
889 spin_unlock(&rpc->crpc_lock);
894 * No one can schedule me now since:
895 * - previous RPC, if any, has done and
896 * - no new RPC is initiated.
897 * - my batch is still active; no one can run it again now.
898 * Cancel pending schedules and prevent future schedule attempts:
900 swi_kill_workitem(wi);
901 sfw_test_unit_done(tsu);
906 sfw_run_batch (sfw_batch_t *tsb)
909 sfw_test_unit_t *tsu;
910 sfw_test_instance_t *tsi;
912 if (sfw_batch_active(tsb)) {
913 CDEBUG (D_NET, "Can't start active batch: "LPU64" (%d)\n",
914 tsb->bat_id.bat_id, atomic_read(&tsb->bat_nactive));
918 list_for_each_entry (tsi, &tsb->bat_tests, tsi_list) {
919 if (!tsi->tsi_is_client) /* skip server instances */
922 LASSERT (!tsi->tsi_stopping);
923 LASSERT (!sfw_test_active(tsi));
925 atomic_inc(&tsb->bat_nactive);
927 list_for_each_entry (tsu, &tsi->tsi_units, tsu_list) {
928 atomic_inc(&tsi->tsi_nactive);
929 tsu->tsu_loop = tsi->tsi_loop;
930 wi = &tsu->tsu_worker;
931 swi_init_workitem(wi, tsu, sfw_run_test);
932 swi_schedule_workitem(wi);
940 sfw_stop_batch (sfw_batch_t *tsb, int force)
942 sfw_test_instance_t *tsi;
943 srpc_client_rpc_t *rpc;
945 if (!sfw_batch_active(tsb))
948 list_for_each_entry (tsi, &tsb->bat_tests, tsi_list) {
949 spin_lock(&tsi->tsi_lock);
951 if (!tsi->tsi_is_client ||
952 !sfw_test_active(tsi) || tsi->tsi_stopping) {
953 spin_unlock(&tsi->tsi_lock);
957 tsi->tsi_stopping = 1;
960 spin_unlock(&tsi->tsi_lock);
964 /* abort launched rpcs in the test */
965 list_for_each_entry (rpc, &tsi->tsi_active_rpcs, crpc_list) {
966 spin_lock(&rpc->crpc_lock);
968 srpc_abort_rpc(rpc, -EINTR);
970 spin_unlock(&rpc->crpc_lock);
973 spin_unlock(&tsi->tsi_lock);
980 sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply)
982 sfw_test_instance_t *tsi;
988 reply->bar_active = atomic_read(&tsb->bat_nactive);
992 list_for_each_entry (tsi, &tsb->bat_tests, tsi_list) {
996 reply->bar_active = atomic_read(&tsi->tsi_nactive);
1004 sfw_free_pages (srpc_server_rpc_t *rpc)
1006 srpc_free_bulk(rpc->srpc_bulk);
1007 rpc->srpc_bulk = NULL;
1011 sfw_alloc_pages (srpc_server_rpc_t *rpc, int npages, int sink)
1013 LASSERT (rpc->srpc_bulk == NULL);
1014 LASSERT (npages > 0 && npages <= LNET_MAX_IOV);
1016 rpc->srpc_bulk = srpc_alloc_bulk(npages, sink);
1017 if (rpc->srpc_bulk == NULL) return -ENOMEM;
1023 sfw_add_test (srpc_server_rpc_t *rpc)
1025 sfw_session_t *sn = sfw_data.fw_session;
1026 srpc_test_reply_t *reply = &rpc->srpc_replymsg.msg_body.tes_reply;
1027 srpc_test_reqst_t *request;
1031 request = &rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst;
1032 reply->tsr_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
1034 if (request->tsr_loop == 0 ||
1035 request->tsr_concur == 0 ||
1036 request->tsr_sid.ses_nid == LNET_NID_ANY ||
1037 request->tsr_ndest > SFW_MAX_NDESTS ||
1038 (request->tsr_is_client && request->tsr_ndest == 0) ||
1039 request->tsr_concur > SFW_MAX_CONCUR ||
1040 request->tsr_service > SRPC_SERVICE_MAX_ID ||
1041 request->tsr_service <= SRPC_FRAMEWORK_SERVICE_MAX_ID) {
1042 reply->tsr_status = EINVAL;
1046 if (sn == NULL || !sfw_sid_equal(request->tsr_sid, sn->sn_id) ||
1047 sfw_find_test_case(request->tsr_service) == NULL) {
1048 reply->tsr_status = ENOENT;
1052 bat = sfw_bid2batch(request->tsr_bid);
1054 CERROR ("Dropping RPC (%s) from %s under memory pressure.\n",
1055 rpc->srpc_service->sv_name,
1056 libcfs_id2str(rpc->srpc_peer));
1060 if (sfw_batch_active(bat)) {
1061 reply->tsr_status = EBUSY;
1065 if (request->tsr_is_client && rpc->srpc_bulk == NULL) {
1066 /* rpc will be resumed later in sfw_bulk_ready */
1067 return sfw_alloc_pages(rpc,
1068 sfw_id_pages(request->tsr_ndest), 1);
1071 rc = sfw_add_test_instance(bat, rpc);
1072 CDEBUG (rc == 0 ? D_NET : D_WARNING,
1073 "%s test: sv %d %s, loop %d, concur %d, ndest %d\n",
1074 rc == 0 ? "Added" : "Failed to add", request->tsr_service,
1075 request->tsr_is_client ? "client" : "server",
1076 request->tsr_loop, request->tsr_concur, request->tsr_ndest);
1078 reply->tsr_status = (rc < 0) ? -rc : rc;
1083 sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
1085 sfw_session_t *sn = sfw_data.fw_session;
1089 reply->bar_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
1091 if (sn == NULL || !sfw_sid_equal(request->bar_sid, sn->sn_id)) {
1092 reply->bar_status = ESRCH;
1096 bat = sfw_find_batch(request->bar_bid);
1098 reply->bar_status = ENOENT;
1102 switch (request->bar_opc) {
1103 case SRPC_BATCH_OPC_RUN:
1104 rc = sfw_run_batch(bat);
1107 case SRPC_BATCH_OPC_STOP:
1108 rc = sfw_stop_batch(bat, request->bar_arg);
1111 case SRPC_BATCH_OPC_QUERY:
1112 rc = sfw_query_batch(bat, request->bar_testidx, reply);
1116 return -EINVAL; /* drop it */
1119 reply->bar_status = (rc < 0) ? -rc : rc;
1124 sfw_handle_server_rpc (srpc_server_rpc_t *rpc)
1126 srpc_service_t *sv = rpc->srpc_service;
1127 srpc_msg_t *reply = &rpc->srpc_replymsg;
1128 srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg;
1131 LASSERT (sfw_data.fw_active_srpc == NULL);
1132 LASSERT (sv->sv_id <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
1134 spin_lock(&sfw_data.fw_lock);
1136 if (sfw_data.fw_shuttingdown) {
1137 spin_unlock(&sfw_data.fw_lock);
1141 /* Remove timer to avoid racing with it or expiring active session */
1142 if (sfw_del_session_timer() != 0) {
1143 CERROR ("Dropping RPC (%s) from %s: racing with expiry timer.",
1144 sv->sv_name, libcfs_id2str(rpc->srpc_peer));
1145 spin_unlock(&sfw_data.fw_lock);
1149 sfw_data.fw_active_srpc = rpc;
1150 spin_unlock(&sfw_data.fw_lock);
1152 sfw_unpack_message(request);
1153 LASSERT (request->msg_type == srpc_service2request(sv->sv_id));
1158 case SRPC_SERVICE_TEST:
1159 rc = sfw_add_test(rpc);
1162 case SRPC_SERVICE_BATCH:
1163 rc = sfw_control_batch(&request->msg_body.bat_reqst,
1164 &reply->msg_body.bat_reply);
1167 case SRPC_SERVICE_QUERY_STAT:
1168 rc = sfw_get_stats(&request->msg_body.stat_reqst,
1169 &reply->msg_body.stat_reply);
1172 case SRPC_SERVICE_DEBUG:
1173 rc = sfw_debug_session(&request->msg_body.dbg_reqst,
1174 &reply->msg_body.dbg_reply);
1177 case SRPC_SERVICE_MAKE_SESSION:
1178 rc = sfw_make_session(&request->msg_body.mksn_reqst,
1179 &reply->msg_body.mksn_reply);
1182 case SRPC_SERVICE_REMOVE_SESSION:
1183 rc = sfw_remove_session(&request->msg_body.rmsn_reqst,
1184 &reply->msg_body.rmsn_reply);
1188 rpc->srpc_done = sfw_server_rpc_done;
1189 spin_lock(&sfw_data.fw_lock);
1192 if (!sfw_data.fw_shuttingdown)
1193 sfw_add_session_timer();
1195 LASSERT (!sfw_data.fw_shuttingdown);
1196 sfw_add_session_timer();
1199 sfw_data.fw_active_srpc = NULL;
1200 spin_unlock(&sfw_data.fw_lock);
1205 sfw_bulk_ready (srpc_server_rpc_t *rpc, int status)
1207 srpc_service_t *sv = rpc->srpc_service;
1210 LASSERT (rpc->srpc_bulk != NULL);
1211 LASSERT (sv->sv_id == SRPC_SERVICE_TEST);
1212 LASSERT (sfw_data.fw_active_srpc == NULL);
1213 LASSERT (rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst.tsr_is_client);
1215 spin_lock(&sfw_data.fw_lock);
1218 CERROR ("Bulk transfer failed for RPC: "
1219 "service %s, peer %s, status %d\n",
1220 sv->sv_name, libcfs_id2str(rpc->srpc_peer), status);
1221 spin_unlock(&sfw_data.fw_lock);
1225 if (sfw_data.fw_shuttingdown) {
1226 spin_unlock(&sfw_data.fw_lock);
1230 if (sfw_del_session_timer() != 0) {
1231 CERROR ("Dropping RPC (%s) from %s: racing with expiry timer",
1232 sv->sv_name, libcfs_id2str(rpc->srpc_peer));
1233 spin_unlock(&sfw_data.fw_lock);
1237 sfw_data.fw_active_srpc = rpc;
1238 spin_unlock(&sfw_data.fw_lock);
1240 rc = sfw_add_test(rpc);
1242 spin_lock(&sfw_data.fw_lock);
1245 if (!sfw_data.fw_shuttingdown)
1246 sfw_add_session_timer();
1248 LASSERT (!sfw_data.fw_shuttingdown);
1249 sfw_add_session_timer();
1252 sfw_data.fw_active_srpc = NULL;
1253 spin_unlock(&sfw_data.fw_lock);
1258 sfw_create_rpc (lnet_process_id_t peer, int service,
1259 int nbulkiov, int bulklen,
1260 void (*done) (srpc_client_rpc_t *), void *priv)
1262 srpc_client_rpc_t *rpc;
1264 spin_lock(&sfw_data.fw_lock);
1266 LASSERT (!sfw_data.fw_shuttingdown);
1267 LASSERT (service <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
1269 if (nbulkiov == 0 && !list_empty(&sfw_data.fw_zombie_rpcs)) {
1270 rpc = list_entry(sfw_data.fw_zombie_rpcs.next,
1271 srpc_client_rpc_t, crpc_list);
1272 list_del(&rpc->crpc_list);
1273 spin_unlock(&sfw_data.fw_lock);
1275 srpc_init_client_rpc(rpc, peer, service, 0, 0,
1276 done, sfw_client_rpc_fini, priv);
1280 spin_unlock(&sfw_data.fw_lock);
1282 rpc = srpc_create_client_rpc(peer, service, nbulkiov, bulklen, done,
1283 nbulkiov != 0 ? NULL : sfw_client_rpc_fini,
1289 sfw_unpack_message (srpc_msg_t *msg)
1291 if (msg->msg_magic == SRPC_MSG_MAGIC)
1292 return; /* no flipping needed */
1294 LASSERT (msg->msg_magic == __swab32(SRPC_MSG_MAGIC));
1296 __swab32s(&msg->msg_type);
1298 if (msg->msg_type == SRPC_MSG_STAT_REQST) {
1299 srpc_stat_reqst_t *req = &msg->msg_body.stat_reqst;
1301 __swab32s(&req->str_type);
1302 __swab64s(&req->str_rpyid);
1303 sfw_unpack_sid(req->str_sid);
1307 if (msg->msg_type == SRPC_MSG_STAT_REPLY) {
1308 srpc_stat_reply_t *rep = &msg->msg_body.stat_reply;
1310 __swab32s(&rep->str_status);
1311 sfw_unpack_sid(rep->str_sid);
1312 sfw_unpack_fw_counters(rep->str_fw);
1313 sfw_unpack_rpc_counters(rep->str_rpc);
1314 sfw_unpack_lnet_counters(rep->str_lnet);
1318 if (msg->msg_type == SRPC_MSG_MKSN_REQST) {
1319 srpc_mksn_reqst_t *req = &msg->msg_body.mksn_reqst;
1321 __swab64s(&req->mksn_rpyid);
1322 __swab32s(&req->mksn_force);
1323 sfw_unpack_sid(req->mksn_sid);
1327 if (msg->msg_type == SRPC_MSG_MKSN_REPLY) {
1328 srpc_mksn_reply_t *rep = &msg->msg_body.mksn_reply;
1330 __swab32s(&rep->mksn_status);
1331 __swab32s(&rep->mksn_timeout);
1332 sfw_unpack_sid(rep->mksn_sid);
1336 if (msg->msg_type == SRPC_MSG_RMSN_REQST) {
1337 srpc_rmsn_reqst_t *req = &msg->msg_body.rmsn_reqst;
1339 __swab64s(&req->rmsn_rpyid);
1340 sfw_unpack_sid(req->rmsn_sid);
1344 if (msg->msg_type == SRPC_MSG_RMSN_REPLY) {
1345 srpc_rmsn_reply_t *rep = &msg->msg_body.rmsn_reply;
1347 __swab32s(&rep->rmsn_status);
1348 sfw_unpack_sid(rep->rmsn_sid);
1352 if (msg->msg_type == SRPC_MSG_DEBUG_REQST) {
1353 srpc_debug_reqst_t *req = &msg->msg_body.dbg_reqst;
1355 __swab64s(&req->dbg_rpyid);
1356 __swab32s(&req->dbg_flags);
1357 sfw_unpack_sid(req->dbg_sid);
1361 if (msg->msg_type == SRPC_MSG_DEBUG_REPLY) {
1362 srpc_debug_reply_t *rep = &msg->msg_body.dbg_reply;
1364 __swab32s(&rep->dbg_nbatch);
1365 __swab32s(&rep->dbg_timeout);
1366 sfw_unpack_sid(rep->dbg_sid);
1370 if (msg->msg_type == SRPC_MSG_BATCH_REQST) {
1371 srpc_batch_reqst_t *req = &msg->msg_body.bat_reqst;
1373 __swab32s(&req->bar_opc);
1374 __swab64s(&req->bar_rpyid);
1375 __swab32s(&req->bar_testidx);
1376 __swab32s(&req->bar_arg);
1377 sfw_unpack_sid(req->bar_sid);
1378 __swab64s(&req->bar_bid.bat_id);
1382 if (msg->msg_type == SRPC_MSG_BATCH_REPLY) {
1383 srpc_batch_reply_t *rep = &msg->msg_body.bat_reply;
1385 __swab32s(&rep->bar_status);
1386 sfw_unpack_sid(rep->bar_sid);
1390 if (msg->msg_type == SRPC_MSG_TEST_REQST) {
1391 srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
1393 __swab64s(&req->tsr_rpyid);
1394 __swab64s(&req->tsr_bulkid);
1395 __swab32s(&req->tsr_loop);
1396 __swab32s(&req->tsr_ndest);
1397 __swab32s(&req->tsr_concur);
1398 __swab32s(&req->tsr_service);
1399 sfw_unpack_sid(req->tsr_sid);
1400 __swab64s(&req->tsr_bid.bat_id);
1404 if (msg->msg_type == SRPC_MSG_TEST_REPLY) {
1405 srpc_test_reply_t *rep = &msg->msg_body.tes_reply;
1407 __swab32s(&rep->tsr_status);
1408 sfw_unpack_sid(rep->tsr_sid);
1412 if (msg->msg_type == SRPC_MSG_JOIN_REQST) {
1413 srpc_join_reqst_t *req = &msg->msg_body.join_reqst;
1415 __swab64s(&req->join_rpyid);
1416 sfw_unpack_sid(req->join_sid);
1420 if (msg->msg_type == SRPC_MSG_JOIN_REPLY) {
1421 srpc_join_reply_t *rep = &msg->msg_body.join_reply;
1423 __swab32s(&rep->join_status);
1424 __swab32s(&rep->join_timeout);
1425 sfw_unpack_sid(rep->join_sid);
1434 sfw_abort_rpc (srpc_client_rpc_t *rpc)
1436 LASSERT (atomic_read(&rpc->crpc_refcount) > 0);
1437 LASSERT (rpc->crpc_service <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
1439 spin_lock(&rpc->crpc_lock);
1440 srpc_abort_rpc(rpc, -EINTR);
1441 spin_unlock(&rpc->crpc_lock);
1446 sfw_post_rpc (srpc_client_rpc_t *rpc)
1448 spin_lock(&rpc->crpc_lock);
1450 LASSERT (!rpc->crpc_closed);
1451 LASSERT (!rpc->crpc_aborted);
1452 LASSERT (list_empty(&rpc->crpc_list));
1453 LASSERT (!sfw_data.fw_shuttingdown);
1455 rpc->crpc_timeout = SFW_CLIENT_RPC_TIMEOUT;
1458 spin_unlock(&rpc->crpc_lock);
1462 static srpc_service_t sfw_services[] =
1466 .sv_id = SRPC_SERVICE_DEBUG,
1469 .sv_name = "query stats",
1470 .sv_id = SRPC_SERVICE_QUERY_STAT,
1473 .sv_name = "make sessin",
1474 .sv_id = SRPC_SERVICE_MAKE_SESSION,
1477 .sv_name = "remove session",
1478 .sv_id = SRPC_SERVICE_REMOVE_SESSION,
1481 .sv_name = "batch service",
1482 .sv_id = SRPC_SERVICE_BATCH,
1485 .sv_name = "test service",
1486 .sv_id = SRPC_SERVICE_TEST,
1488 { .sv_name = NULL, }
1491 extern sfw_test_client_ops_t ping_test_client;
1492 extern srpc_service_t ping_test_service;
1494 extern sfw_test_client_ops_t brw_test_client;
1495 extern srpc_service_t brw_test_service;
1504 sfw_test_case_t *tsc;
1509 s = getenv("SESSION_TIMEOUT");
1510 session_timeout = s != NULL ? atoi(s) : session_timeout;
1512 s = getenv("BRW_INJECT_ERRORS");
1513 brw_inject_errors = s != NULL ? atoi(s) : brw_inject_errors;
1516 if (session_timeout < 0) {
1517 CERROR ("Session timeout must be non-negative: %d\n",
1522 if (session_timeout == 0)
1523 CWARN ("Zero session_timeout specified "
1524 "- test sessions never expire.\n");
1526 memset(&sfw_data, 0, sizeof(struct smoketest_framework));
1528 sfw_data.fw_session = NULL;
1529 sfw_data.fw_active_srpc = NULL;
1530 spin_lock_init(&sfw_data.fw_lock);
1531 atomic_set(&sfw_data.fw_nzombies, 0);
1532 CFS_INIT_LIST_HEAD(&sfw_data.fw_tests);
1533 CFS_INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
1534 CFS_INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
1536 rc = sfw_register_test(&brw_test_service, &brw_test_client);
1538 rc = sfw_register_test(&ping_test_service, &ping_test_client);
1542 list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
1543 sv = tsc->tsc_srv_service;
1544 sv->sv_concur = SFW_TEST_CONCURRENCY;
1546 rc = srpc_add_service(sv);
1547 LASSERT (rc != -EBUSY);
1549 CWARN ("Failed to add %s service: %d\n",
1555 for (i = 0; ; i++) {
1556 sv = &sfw_services[i];
1557 if (sv->sv_name == NULL) break;
1559 sv->sv_bulk_ready = NULL;
1560 sv->sv_handler = sfw_handle_server_rpc;
1561 sv->sv_concur = SFW_SERVICE_CONCURRENCY;
1562 if (sv->sv_id == SRPC_SERVICE_TEST)
1563 sv->sv_bulk_ready = sfw_bulk_ready;
1565 rc = srpc_add_service(sv);
1566 LASSERT (rc != -EBUSY);
1568 CWARN ("Failed to add %s service: %d\n",
1573 /* about to sfw_shutdown, no need to add buffer */
1574 if (error) continue;
1576 rc = srpc_service_add_buffers(sv, SFW_POST_BUFFERS);
1577 if (rc != SFW_POST_BUFFERS) {
1578 CWARN ("Failed to reserve enough buffers: "
1579 "service %s, %d needed, %d reserved\n",
1580 sv->sv_name, SFW_POST_BUFFERS, rc);
1594 sfw_test_case_t *tsc;
1597 spin_lock(&sfw_data.fw_lock);
1599 sfw_data.fw_shuttingdown = 1;
1601 lst_wait_until(sfw_data.fw_active_srpc == NULL, sfw_data.fw_lock,
1602 "waiting for active RPC to finish.\n");
1604 LASSERT (sfw_data.fw_active_srpc == NULL);
1607 if (sfw_del_session_timer() != 0)
1608 lst_wait_until(sfw_data.fw_session == NULL, sfw_data.fw_lock,
1609 "waiting for session timer to explode.\n");
1611 sfw_deactivate_session();
1612 lst_wait_until(atomic_read(&sfw_data.fw_nzombies) == 0,
1614 "waiting for %d zombie sessions to die.\n",
1615 atomic_read(&sfw_data.fw_nzombies));
1617 spin_unlock(&sfw_data.fw_lock);
1619 for (i = 0; ; i++) {
1620 sv = &sfw_services[i];
1621 if (sv->sv_name == NULL)
1624 srpc_shutdown_service(sv);
1625 srpc_remove_service(sv);
1628 list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
1629 sv = tsc->tsc_srv_service;
1630 srpc_shutdown_service(sv);
1631 srpc_remove_service(sv);
1634 while (!list_empty(&sfw_data.fw_zombie_rpcs)) {
1635 srpc_client_rpc_t *rpc;
1637 rpc = list_entry(sfw_data.fw_zombie_rpcs.next,
1638 srpc_client_rpc_t, crpc_list);
1639 list_del(&rpc->crpc_list);
1641 LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
1644 for (i = 0; ; i++) {
1645 sv = &sfw_services[i];
1646 if (sv->sv_name == NULL)
1649 srpc_wait_service_shutdown(sv);
1652 while (!list_empty(&sfw_data.fw_tests)) {
1653 tsc = list_entry(sfw_data.fw_tests.next,
1654 sfw_test_case_t, tsc_list);
1656 srpc_wait_service_shutdown(tsc->tsc_srv_service);
1658 list_del(&tsc->tsc_list);
1659 LIBCFS_FREE(tsc, sizeof(*tsc));