X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lnet%2Fselftest%2Fframework.c;h=032d95ef3492bc9aa03d498025ad2281b449d579;hp=111ca0ece75258ecaa305e93ddc6e14bfc091bf9;hb=b49f7b3ac64c06be014be44d5b468dce5a75a240;hpb=a1c6026257d0ce303a40c39ea986170fb56ecd2d diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 111ca0e..032d95e 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -17,17 +15,15 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012, 2016, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -43,24 +39,15 @@ #include "selftest.h" -lst_sid_t LST_INVALID_SID = {LNET_NID_ANY, -1}; - -int brw_inject_errors = 0; -CFS_MODULE_PARM(brw_inject_errors, "i", int, 0644, - "# data errors to inject randomly, zero by default"); +struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1}; static int session_timeout = 100; -CFS_MODULE_PARM(session_timeout, "i", int, 0444, - "test session timeout in seconds (100 by default, 0 == never)"); +module_param(session_timeout, int, 0444); +MODULE_PARM_DESC(session_timeout, "test session timeout in seconds (100 by default, 0 == never)"); static int rpc_timeout = 64; -CFS_MODULE_PARM(rpc_timeout, "i", int, 0644, - "rpc timeout in seconds (64 by default, 0 == never)"); - -#define SFW_TEST_CONCURRENCY 1792 -#define SFW_EXTRA_TEST_BUFFERS 8 /* tolerate buggy peers with extra buffers */ - -#define sfw_test_buffers(tsi) ((tsi)->tsi_loop + SFW_EXTRA_TEST_BUFFERS) +module_param(rpc_timeout, int, 0644); +MODULE_PARM_DESC(rpc_timeout, "rpc timeout in seconds (64 by default, 0 == never)"); #define sfw_unpack_id(id) \ do { \ @@ -76,11 +63,11 @@ do { \ #define sfw_unpack_fw_counters(fc) \ do { \ - __swab32s(&(fc).brw_errors); \ - __swab32s(&(fc).ping_errors); \ - __swab32s(&(fc).active_tests); \ + __swab32s(&(fc).running_ms); \ __swab32s(&(fc).active_batches); \ __swab32s(&(fc).zombie_sessions); \ + __swab32s(&(fc).brw_errors); \ + __swab32s(&(fc).ping_errors); \ } while (0) #define sfw_unpack_rpc_counters(rc) \ @@ -109,18 +96,26 @@ do { \ __swab64s(&(lc).route_length); \ } while (0) -#define sfw_test_active(t) (cfs_atomic_read(&(t)->tsi_nactive) != 0) -#define sfw_batch_active(b) (cfs_atomic_read(&(b)->bat_nactive) != 0) - -struct smoketest_framework { - cfs_list_t fw_zombie_rpcs; /* RPCs to be recycled */ - cfs_list_t fw_zombie_sessions; /* stopping sessions */ - cfs_list_t fw_tests; /* registered test cases */ - cfs_atomic_t fw_nzombies; /* # zombie sessions */ - cfs_spinlock_t fw_lock; /* serialise */ - sfw_session_t *fw_session; /* _the_ session */ - int fw_shuttingdown; /* shutdown in progress */ - srpc_server_rpc_t *fw_active_srpc; /* running RPC */ +#define sfw_test_active(t) (atomic_read(&(t)->tsi_nactive) != 0) +#define sfw_batch_active(b) (atomic_read(&(b)->bat_nactive) != 0) + +static struct smoketest_framework { + /* RPCs to be recycled */ + struct list_head fw_zombie_rpcs; + /* stopping sessions */ + struct list_head fw_zombie_sessions; + /* registered test cases */ + struct list_head fw_tests; + /* # zombie sessions */ + atomic_t fw_nzombies; + /* serialise */ + spinlock_t fw_lock; + /* _the_ session */ + sfw_session_t *fw_session; + /* shutdown in progress */ + int fw_shuttingdown; + /* running RPC */ + srpc_server_rpc_t *fw_active_srpc; } sfw_data; /* forward ref's */ @@ -130,18 +125,17 @@ void sfw_destroy_session (sfw_session_t *sn); static inline sfw_test_case_t * sfw_find_test_case(int id) { - sfw_test_case_t *tsc; + sfw_test_case_t *tsc; - LASSERT (id <= SRPC_SERVICE_MAX_ID); - LASSERT (id > SRPC_FRAMEWORK_SERVICE_MAX_ID); + LASSERT(id <= SRPC_SERVICE_MAX_ID); + LASSERT(id > SRPC_FRAMEWORK_SERVICE_MAX_ID); - cfs_list_for_each_entry_typed (tsc, &sfw_data.fw_tests, - sfw_test_case_t, tsc_list) { - if (tsc->tsc_srv_service->sv_id == id) - return tsc; - } + list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) { + if (tsc->tsc_srv_service->sv_id == id) + return tsc; + } - return NULL; + return NULL; } static int @@ -159,15 +153,14 @@ sfw_register_test (srpc_service_t *service, sfw_test_client_ops_t *cliops) if (tsc == NULL) return -ENOMEM; - memset(tsc, 0, sizeof(sfw_test_case_t)); tsc->tsc_cli_ops = cliops; tsc->tsc_srv_service = service; - cfs_list_add_tail(&tsc->tsc_list, &sfw_data.fw_tests); - return 0; + list_add_tail(&tsc->tsc_list, &sfw_data.fw_tests); + return 0; } -void +static void sfw_add_session_timer (void) { sfw_session_t *sn = sfw_data.fw_session; @@ -181,13 +174,12 @@ sfw_add_session_timer (void) LASSERT (!sn->sn_timer_active); sn->sn_timer_active = 1; - timer->stt_expires = cfs_time_add(sn->sn_timeout, - cfs_time_current_sec()); + timer->stt_expires = ktime_get_real_seconds()+ sn->sn_timeout; stt_add_timer(timer); return; } -int +static int sfw_del_session_timer (void) { sfw_session_t *sn = sfw_data.fw_session; @@ -202,16 +194,13 @@ sfw_del_session_timer (void) return 0; } -#ifndef __KERNEL__ - /* Racing is impossible in single-threaded userland selftest */ - LBUG(); -#endif return EBUSY; /* racing with sfw_session_expired() */ } /* called with sfw_data.fw_lock held */ static void sfw_deactivate_session (void) +__must_hold(&sfw_data.fw_lock) { sfw_session_t *sn = sfw_data.fw_session; int nactive = 0; @@ -220,106 +209,96 @@ sfw_deactivate_session (void) if (sn == NULL) return; - LASSERT (!sn->sn_timer_active); + LASSERT(!sn->sn_timer_active); - sfw_data.fw_session = NULL; - cfs_atomic_inc(&sfw_data.fw_nzombies); - cfs_list_add(&sn->sn_list, &sfw_data.fw_zombie_sessions); + sfw_data.fw_session = NULL; + atomic_inc(&sfw_data.fw_nzombies); + list_add(&sn->sn_list, &sfw_data.fw_zombie_sessions); - cfs_spin_unlock(&sfw_data.fw_lock); + spin_unlock(&sfw_data.fw_lock); - cfs_list_for_each_entry_typed (tsc, &sfw_data.fw_tests, - sfw_test_case_t, tsc_list) { - srpc_abort_service(tsc->tsc_srv_service); - } + list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) { + srpc_abort_service(tsc->tsc_srv_service); + } - cfs_spin_lock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); - cfs_list_for_each_entry_typed (tsb, &sn->sn_batches, - sfw_batch_t, bat_list) { - if (sfw_batch_active(tsb)) { - nactive++; - sfw_stop_batch(tsb, 1); - } - } - - if (nactive != 0) - return; /* wait for active batches to stop */ - - cfs_list_del_init(&sn->sn_list); - cfs_spin_unlock(&sfw_data.fw_lock); + list_for_each_entry(tsb, &sn->sn_batches, bat_list) { + if (sfw_batch_active(tsb)) { + nactive++; + sfw_stop_batch(tsb, 1); + } + } - sfw_destroy_session(sn); + if (nactive != 0) + return; /* wait for active batches to stop */ - cfs_spin_lock(&sfw_data.fw_lock); - return; -} + list_del_init(&sn->sn_list); + spin_unlock(&sfw_data.fw_lock); -#ifndef __KERNEL__ + sfw_destroy_session(sn); -int -sfw_session_removed (void) -{ - return (sfw_data.fw_session == NULL) ? 1 : 0; + spin_lock(&sfw_data.fw_lock); } -#endif -void +static void sfw_session_expired (void *data) { - sfw_session_t *sn = data; + sfw_session_t *sn = data; - cfs_spin_lock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); LASSERT (sn->sn_timer_active); LASSERT (sn == sfw_data.fw_session); - CWARN ("Session expired! sid: %s-"LPU64", name: %s\n", + CWARN ("Session expired! sid: %s-%llu, name: %s\n", libcfs_nid2str(sn->sn_id.ses_nid), sn->sn_id.ses_stamp, &sn->sn_name[0]); sn->sn_timer_active = 0; sfw_deactivate_session(); - cfs_spin_unlock(&sfw_data.fw_lock); - return; + spin_unlock(&sfw_data.fw_lock); } static inline void -sfw_init_session (sfw_session_t *sn, lst_sid_t sid, const char *name) +sfw_init_session(sfw_session_t *sn, struct lst_sid sid, + unsigned features, const char *name) { stt_timer_t *timer = &sn->sn_timer; memset(sn, 0, sizeof(sfw_session_t)); - CFS_INIT_LIST_HEAD(&sn->sn_list); - CFS_INIT_LIST_HEAD(&sn->sn_batches); - cfs_atomic_set(&sn->sn_refcount, 1); /* +1 for caller */ - cfs_atomic_set(&sn->sn_brw_errors, 0); - cfs_atomic_set(&sn->sn_ping_errors, 0); - strncpy(&sn->sn_name[0], name, LST_NAME_SIZE); + INIT_LIST_HEAD(&sn->sn_list); + INIT_LIST_HEAD(&sn->sn_batches); + atomic_set(&sn->sn_refcount, 1); /* +1 for caller */ + atomic_set(&sn->sn_brw_errors, 0); + atomic_set(&sn->sn_ping_errors, 0); + strlcpy(&sn->sn_name[0], name, sizeof(sn->sn_name)); sn->sn_timer_active = 0; sn->sn_id = sid; + sn->sn_features = features; sn->sn_timeout = session_timeout; + sn->sn_started = cfs_time_current(); timer->stt_data = sn; timer->stt_func = sfw_session_expired; - CFS_INIT_LIST_HEAD(&timer->stt_list); + INIT_LIST_HEAD(&timer->stt_list); } /* completion handler for incoming framework RPCs */ -void -sfw_server_rpc_done (srpc_server_rpc_t *rpc) +static void +sfw_server_rpc_done(struct srpc_server_rpc *rpc) { - srpc_service_t *sv = rpc->srpc_service; - int status = rpc->srpc_status; + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + int status = rpc->srpc_status; CDEBUG (D_NET, "Incoming framework RPC done: " "service %s, peer %s, status %s:%d\n", sv->sv_name, libcfs_id2str(rpc->srpc_peer), - swi_state2str(rpc->srpc_wi.wi_state), + swi_state2str(rpc->srpc_wi.swi_state), status); if (rpc->srpc_bulk != NULL) @@ -327,52 +306,46 @@ sfw_server_rpc_done (srpc_server_rpc_t *rpc) return; } -void +static void sfw_client_rpc_fini (srpc_client_rpc_t *rpc) { - LASSERT (rpc->crpc_bulk.bk_niov == 0); - LASSERT (cfs_list_empty(&rpc->crpc_list)); - LASSERT (cfs_atomic_read(&rpc->crpc_refcount) == 0); -#ifndef __KERNEL__ - LASSERT (rpc->crpc_bulk.bk_pages == NULL); -#endif + LASSERT(rpc->crpc_bulk.bk_niov == 0); + LASSERT(list_empty(&rpc->crpc_list)); + LASSERT(atomic_read(&rpc->crpc_refcount) == 0); - CDEBUG (D_NET, - "Outgoing framework RPC done: " - "service %d, peer %s, status %s:%d:%d\n", - rpc->crpc_service, libcfs_id2str(rpc->crpc_dest), - swi_state2str(rpc->crpc_wi.wi_state), - rpc->crpc_aborted, rpc->crpc_status); + CDEBUG(D_NET, "Outgoing framework RPC done: " + "service %d, peer %s, status %s:%d:%d\n", + rpc->crpc_service, libcfs_id2str(rpc->crpc_dest), + swi_state2str(rpc->crpc_wi.swi_state), + rpc->crpc_aborted, rpc->crpc_status); - cfs_spin_lock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); - /* my callers must finish all RPCs before shutting me down */ - LASSERT (!sfw_data.fw_shuttingdown); - cfs_list_add(&rpc->crpc_list, &sfw_data.fw_zombie_rpcs); + /* my callers must finish all RPCs before shutting me down */ + LASSERT(!sfw_data.fw_shuttingdown); + list_add(&rpc->crpc_list, &sfw_data.fw_zombie_rpcs); - cfs_spin_unlock(&sfw_data.fw_lock); - return; + spin_unlock(&sfw_data.fw_lock); } -sfw_batch_t * -sfw_find_batch (lst_bid_t bid) +static sfw_batch_t * +sfw_find_batch(struct lst_bid bid) { - sfw_session_t *sn = sfw_data.fw_session; - sfw_batch_t *bat; + sfw_session_t *sn = sfw_data.fw_session; + sfw_batch_t *bat; - LASSERT (sn != NULL); + LASSERT(sn != NULL); - cfs_list_for_each_entry_typed (bat, &sn->sn_batches, - sfw_batch_t, bat_list) { - if (bat->bat_id.bat_id == bid.bat_id) - return bat; - } + list_for_each_entry(bat, &sn->sn_batches, bat_list) { + if (bat->bat_id.bat_id == bid.bat_id) + return bat; + } - return NULL; + return NULL; } -sfw_batch_t * -sfw_bid2batch (lst_bid_t bid) +static sfw_batch_t * +sfw_bid2batch(struct lst_bid bid) { sfw_session_t *sn = sfw_data.fw_session; sfw_batch_t *bat; @@ -384,24 +357,24 @@ sfw_bid2batch (lst_bid_t bid) return bat; LIBCFS_ALLOC(bat, sizeof(sfw_batch_t)); - if (bat == NULL) + if (bat == NULL) return NULL; - bat->bat_error = 0; - bat->bat_session = sn; - bat->bat_id = bid; - cfs_atomic_set(&bat->bat_nactive, 0); - CFS_INIT_LIST_HEAD(&bat->bat_tests); + bat->bat_error = 0; + bat->bat_session = sn; + bat->bat_id = bid; + atomic_set(&bat->bat_nactive, 0); + INIT_LIST_HEAD(&bat->bat_tests); - cfs_list_add_tail(&bat->bat_list, &sn->sn_batches); - return bat; + list_add_tail(&bat->bat_list, &sn->sn_batches); + return bat; } -int +static int sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; - sfw_counters_t *cnt = &reply->str_fw; + struct sfw_counters *cnt = &reply->str_fw; sfw_batch_t *bat; reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -416,35 +389,33 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) return 0; } - LNET_LOCK(); - reply->str_lnet = the_lnet.ln_counters; - LNET_UNLOCK(); - - srpc_get_counters(&reply->str_rpc); + lnet_counters_get(&reply->str_lnet); + srpc_get_counters(&reply->str_rpc); - cnt->brw_errors = cfs_atomic_read(&sn->sn_brw_errors); - cnt->ping_errors = cfs_atomic_read(&sn->sn_ping_errors); - cnt->zombie_sessions = cfs_atomic_read(&sfw_data.fw_nzombies); + /* send over the msecs since the session was started + - with 32 bits to send, this is ~49 days */ + cnt->running_ms = jiffies_to_msecs(jiffies - sn->sn_started); + cnt->brw_errors = atomic_read(&sn->sn_brw_errors); + cnt->ping_errors = atomic_read(&sn->sn_ping_errors); + cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies); - cnt->active_tests = cnt->active_batches = 0; - cfs_list_for_each_entry_typed (bat, &sn->sn_batches, - sfw_batch_t, bat_list) { - int n = cfs_atomic_read(&bat->bat_nactive); - - if (n > 0) { - cnt->active_batches++; - cnt->active_tests += n; - } - } + cnt->active_batches = 0; + list_for_each_entry(bat, &sn->sn_batches, bat_list) { + if (atomic_read(&bat->bat_nactive) > 0) + cnt->active_batches++; + } - reply->str_status = 0; - return 0; + reply->str_status = 0; + return 0; } int -sfw_make_session (srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply) +sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply) { - sfw_session_t *sn = sfw_data.fw_session; + sfw_session_t *sn = sfw_data.fw_session; + srpc_msg_t *msg = container_of(request, srpc_msg_t, + msg_body.mksn_reqst); + int cplen = 0; if (request->mksn_sid.ses_nid == LNET_NID_ANY) { reply->mksn_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -458,41 +429,56 @@ sfw_make_session (srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply) reply->mksn_timeout = sn->sn_timeout; if (sfw_sid_equal(request->mksn_sid, sn->sn_id)) { - cfs_atomic_inc(&sn->sn_refcount); + atomic_inc(&sn->sn_refcount); return 0; } if (!request->mksn_force) { reply->mksn_status = EBUSY; - strncpy(&reply->mksn_name[0], &sn->sn_name[0], LST_NAME_SIZE); + cplen = strlcpy(&reply->mksn_name[0], &sn->sn_name[0], + sizeof(reply->mksn_name)); + if (cplen >= sizeof(reply->mksn_name)) + return -E2BIG; return 0; } } - /* brand new or create by force */ - LIBCFS_ALLOC(sn, sizeof(sfw_session_t)); - if (sn == NULL) { - CERROR ("Dropping RPC (mksn) under memory pressure.\n"); - return -ENOMEM; - } + /* reject the request if it requires unknown features + * NB: old version will always accept all features because it's not + * aware of srpc_msg_t::msg_ses_feats, it's a defect but it's also + * harmless because it will return zero feature to console, and it's + * console's responsibility to make sure all nodes in a session have + * same feature mask. */ + if ((msg->msg_ses_feats & ~LST_FEATS_MASK) != 0) { + reply->mksn_status = EPROTO; + return 0; + } - sfw_init_session(sn, request->mksn_sid, &request->mksn_name[0]); + /* brand new or create by force */ + LIBCFS_ALLOC(sn, sizeof(sfw_session_t)); + if (sn == NULL) { + CERROR("dropping RPC mksn under memory pressure\n"); + return -ENOMEM; + } - cfs_spin_lock(&sfw_data.fw_lock); + sfw_init_session(sn, request->mksn_sid, + msg->msg_ses_feats, &request->mksn_name[0]); - sfw_deactivate_session(); - LASSERT (sfw_data.fw_session == NULL); - sfw_data.fw_session = sn; + spin_lock(&sfw_data.fw_lock); - cfs_spin_unlock(&sfw_data.fw_lock); + sfw_deactivate_session(); + LASSERT(sfw_data.fw_session == NULL); + sfw_data.fw_session = sn; - reply->mksn_status = 0; - reply->mksn_sid = sn->sn_id; - reply->mksn_timeout = sn->sn_timeout; - return 0; + spin_unlock(&sfw_data.fw_lock); + + reply->mksn_status = 0; + reply->mksn_sid = sn->sn_id; + reply->mksn_timeout = sn->sn_timeout; + return 0; } -int +static int sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -509,22 +495,22 @@ sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply) return 0; } - if (!cfs_atomic_dec_and_test(&sn->sn_refcount)) { + if (!atomic_dec_and_test(&sn->sn_refcount)) { reply->rmsn_status = 0; return 0; } - cfs_spin_lock(&sfw_data.fw_lock); - sfw_deactivate_session(); - cfs_spin_unlock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); + sfw_deactivate_session(); + spin_unlock(&sfw_data.fw_lock); - reply->rmsn_status = 0; - reply->rmsn_sid = LST_INVALID_SID; - LASSERT (sfw_data.fw_session == NULL); - return 0; + reply->rmsn_status = 0; + reply->rmsn_sid = LST_INVALID_SID; + LASSERT(sfw_data.fw_session == NULL); + return 0; } -int +static int sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -533,69 +519,104 @@ sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply) reply->dbg_status = ESRCH; reply->dbg_sid = LST_INVALID_SID; return 0; - } + } - reply->dbg_status = 0; - reply->dbg_sid = sn->sn_id; - reply->dbg_timeout = sn->sn_timeout; - strncpy(reply->dbg_name, &sn->sn_name[0], LST_NAME_SIZE); + reply->dbg_status = 0; + reply->dbg_sid = sn->sn_id; + reply->dbg_timeout = sn->sn_timeout; + if (strlcpy(reply->dbg_name, &sn->sn_name[0], sizeof(reply->dbg_name)) + >= sizeof(reply->dbg_name)) + return -E2BIG; return 0; } -void +static void sfw_test_rpc_fini (srpc_client_rpc_t *rpc) { - sfw_test_unit_t *tsu = rpc->crpc_priv; - sfw_test_instance_t *tsi = tsu->tsu_instance; + sfw_test_unit_t *tsu = rpc->crpc_priv; + sfw_test_instance_t *tsi = tsu->tsu_instance; - /* Called with hold of tsi->tsi_lock */ - LASSERT (cfs_list_empty(&rpc->crpc_list)); - cfs_list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs); + /* Called with hold of tsi->tsi_lock */ + LASSERT(list_empty(&rpc->crpc_list)); + list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs); } -int -sfw_load_test (sfw_test_instance_t *tsi) +static inline int +sfw_test_buffers(sfw_test_instance_t *tsi) { - sfw_test_case_t *tsc = sfw_find_test_case(tsi->tsi_service); - int nrequired = sfw_test_buffers(tsi); - int nposted; - - LASSERT (tsc != NULL); - - if (tsi->tsi_is_client) { - tsi->tsi_ops = tsc->tsc_cli_ops; - return 0; - } - - nposted = srpc_service_add_buffers(tsc->tsc_srv_service, nrequired); - if (nposted != nrequired) { - CWARN ("Failed to reserve enough buffers: " - "service %s, %d needed, %d reserved\n", - tsc->tsc_srv_service->sv_name, nrequired, nposted); - srpc_service_remove_buffers(tsc->tsc_srv_service, nposted); - return -ENOMEM; - } + struct sfw_test_case *tsc; + struct srpc_service *svc; + int nbuf; + + LASSERT(tsi != NULL); + tsc = sfw_find_test_case(tsi->tsi_service); + LASSERT(tsc != NULL); + svc = tsc->tsc_srv_service; + LASSERT(svc != NULL); + + nbuf = min(svc->sv_wi_total, tsi->tsi_loop) / svc->sv_ncpts; + return max(SFW_TEST_WI_MIN, nbuf + SFW_TEST_WI_EXTRA); +} - CDEBUG (D_NET, "Reserved %d buffers for test %s\n", - nposted, tsc->tsc_srv_service->sv_name); - return 0; +static int +sfw_load_test(struct sfw_test_instance *tsi) +{ + struct sfw_test_case *tsc; + struct srpc_service *svc; + int nbuf; + int rc; + + LASSERT(tsi != NULL); + tsc = sfw_find_test_case(tsi->tsi_service); + nbuf = sfw_test_buffers(tsi); + LASSERT(tsc != NULL); + svc = tsc->tsc_srv_service; + + if (tsi->tsi_is_client) { + tsi->tsi_ops = tsc->tsc_cli_ops; + return 0; + } + + rc = srpc_service_add_buffers(svc, nbuf); + if (rc != 0) { + CWARN("Failed to reserve enough buffers: " + "service %s, %d needed: %d\n", svc->sv_name, nbuf, rc); + /* NB: this error handler is not strictly correct, because + * it may release more buffers than already allocated, + * but it doesn't matter because request portal should + * be lazy portal and will grow buffers if necessary. */ + srpc_service_remove_buffers(svc, nbuf); + return -ENOMEM; + } + + CDEBUG(D_NET, "Reserved %d buffers for test %s\n", + nbuf * (srpc_serv_is_framework(svc) ? + 1 : cfs_cpt_number(cfs_cpt_table)), svc->sv_name); + return 0; } -void -sfw_unload_test (sfw_test_instance_t *tsi) +static void +sfw_unload_test(struct sfw_test_instance *tsi) { - sfw_test_case_t *tsc = sfw_find_test_case(tsi->tsi_service); + struct sfw_test_case *tsc; - LASSERT (tsc != NULL); + LASSERT(tsi != NULL); + tsc = sfw_find_test_case(tsi->tsi_service); + LASSERT(tsc != NULL); - if (!tsi->tsi_is_client) - srpc_service_remove_buffers(tsc->tsc_srv_service, - sfw_test_buffers(tsi)); - return; + if (tsi->tsi_is_client) + return; + + /* shrink buffers, because request portal is lazy portal + * which can grow buffers at runtime so we may leave + * some buffers behind, but never mind... */ + srpc_service_remove_buffers(tsc->tsc_srv_service, + sfw_test_buffers(tsi)); + return; } -void +static void sfw_destroy_test_instance (sfw_test_instance_t *tsi) { srpc_client_rpc_t *rpc; @@ -605,71 +626,71 @@ sfw_destroy_test_instance (sfw_test_instance_t *tsi) tsi->tsi_ops->tso_fini(tsi); - LASSERT (!tsi->tsi_stopping); - LASSERT (cfs_list_empty(&tsi->tsi_active_rpcs)); - LASSERT (!sfw_test_active(tsi)); + LASSERT(!tsi->tsi_stopping); + LASSERT(list_empty(&tsi->tsi_active_rpcs)); + LASSERT(!sfw_test_active(tsi)); - while (!cfs_list_empty(&tsi->tsi_units)) { - tsu = cfs_list_entry(tsi->tsi_units.next, - sfw_test_unit_t, tsu_list); - cfs_list_del(&tsu->tsu_list); - LIBCFS_FREE(tsu, sizeof(*tsu)); - } + while (!list_empty(&tsi->tsi_units)) { + tsu = list_entry(tsi->tsi_units.next, + sfw_test_unit_t, tsu_list); + list_del(&tsu->tsu_list); + LIBCFS_FREE(tsu, sizeof(*tsu)); + } - while (!cfs_list_empty(&tsi->tsi_free_rpcs)) { - rpc = cfs_list_entry(tsi->tsi_free_rpcs.next, - srpc_client_rpc_t, crpc_list); - cfs_list_del(&rpc->crpc_list); - LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); - } + while (!list_empty(&tsi->tsi_free_rpcs)) { + rpc = list_entry(tsi->tsi_free_rpcs.next, + srpc_client_rpc_t, crpc_list); + list_del(&rpc->crpc_list); + LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); + } clean: - sfw_unload_test(tsi); - LIBCFS_FREE(tsi, sizeof(*tsi)); - return; + sfw_unload_test(tsi); + LIBCFS_FREE(tsi, sizeof(*tsi)); + return; } -void +static void sfw_destroy_batch (sfw_batch_t *tsb) { - sfw_test_instance_t *tsi; + sfw_test_instance_t *tsi; - LASSERT (!sfw_batch_active(tsb)); - LASSERT (cfs_list_empty(&tsb->bat_list)); + LASSERT(!sfw_batch_active(tsb)); + LASSERT(list_empty(&tsb->bat_list)); - while (!cfs_list_empty(&tsb->bat_tests)) { - tsi = cfs_list_entry(tsb->bat_tests.next, - sfw_test_instance_t, tsi_list); - cfs_list_del_init(&tsi->tsi_list); - sfw_destroy_test_instance(tsi); - } + while (!list_empty(&tsb->bat_tests)) { + tsi = list_entry(tsb->bat_tests.next, + sfw_test_instance_t, tsi_list); + list_del_init(&tsi->tsi_list); + sfw_destroy_test_instance(tsi); + } - LIBCFS_FREE(tsb, sizeof(sfw_batch_t)); - return; + LIBCFS_FREE(tsb, sizeof(sfw_batch_t)); + return; } void sfw_destroy_session (sfw_session_t *sn) { - sfw_batch_t *batch; + sfw_batch_t *batch; - LASSERT (cfs_list_empty(&sn->sn_list)); - LASSERT (sn != sfw_data.fw_session); + LASSERT(list_empty(&sn->sn_list)); + LASSERT(sn != sfw_data.fw_session); - while (!cfs_list_empty(&sn->sn_batches)) { - batch = cfs_list_entry(sn->sn_batches.next, - sfw_batch_t, bat_list); - cfs_list_del_init(&batch->bat_list); - sfw_destroy_batch(batch); - } + while (!list_empty(&sn->sn_batches)) { + batch = list_entry(sn->sn_batches.next, + sfw_batch_t, bat_list); + list_del_init(&batch->bat_list); + sfw_destroy_batch(batch); + } - LIBCFS_FREE(sn, sizeof(*sn)); - cfs_atomic_dec(&sfw_data.fw_nzombies); - return; + LIBCFS_FREE(sn, sizeof(*sn)); + atomic_dec(&sfw_data.fw_nzombies); + return; } -void -sfw_unpack_test_req (srpc_msg_t *msg) +static void +sfw_unpack_addtest_req(srpc_msg_t *msg) { srpc_test_reqst_t *req = &msg->msg_body.tes_reqst; @@ -681,14 +702,25 @@ sfw_unpack_test_req (srpc_msg_t *msg) LASSERT (msg->msg_magic == __swab32(SRPC_MSG_MAGIC)); - if (req->tsr_service == SRPC_SERVICE_BRW) { - test_bulk_req_t *bulk = &req->tsr_u.bulk; + if (req->tsr_service == SRPC_SERVICE_BRW) { + if ((msg->msg_ses_feats & LST_FEAT_BULK_LEN) == 0) { + test_bulk_req_t *bulk = &req->tsr_u.bulk_v0; - __swab32s(&bulk->blk_opc); - __swab32s(&bulk->blk_npg); - __swab32s(&bulk->blk_flags); - return; - } + __swab32s(&bulk->blk_opc); + __swab32s(&bulk->blk_npg); + __swab32s(&bulk->blk_flags); + + } else { + test_bulk_req_v1_t *bulk = &req->tsr_u.bulk_v1; + + __swab16s(&bulk->blk_opc); + __swab16s(&bulk->blk_flags); + __swab32s(&bulk->blk_offset); + __swab32s(&bulk->blk_len); + } + + return; + } if (req->tsr_service == SRPC_SERVICE_PING) { test_ping_req_t *ping = &req->tsr_u.ping; @@ -698,11 +730,11 @@ sfw_unpack_test_req (srpc_msg_t *msg) return; } - LBUG (); - return; + LBUG(); + return; } -int +static int sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) { srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg; @@ -716,17 +748,16 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) LIBCFS_ALLOC(tsi, sizeof(*tsi)); if (tsi == NULL) { - CERROR ("Can't allocate test instance for batch: "LPU64"\n", + CERROR ("Can't allocate test instance for batch: %llu\n", tsb->bat_id.bat_id); return -ENOMEM; } - memset(tsi, 0, sizeof(*tsi)); - cfs_spin_lock_init(&tsi->tsi_lock); - cfs_atomic_set(&tsi->tsi_nactive, 0); - CFS_INIT_LIST_HEAD(&tsi->tsi_units); - CFS_INIT_LIST_HEAD(&tsi->tsi_free_rpcs); - CFS_INIT_LIST_HEAD(&tsi->tsi_active_rpcs); + spin_lock_init(&tsi->tsi_lock); + atomic_set(&tsi->tsi_nactive, 0); + INIT_LIST_HEAD(&tsi->tsi_units); + INIT_LIST_HEAD(&tsi->tsi_free_rpcs); + INIT_LIST_HEAD(&tsi->tsi_active_rpcs); tsi->tsi_stopping = 0; tsi->tsi_batch = tsb; @@ -744,33 +775,27 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) LASSERT (!sfw_batch_active(tsb)); - if (!tsi->tsi_is_client) { - /* it's test server, just add it to tsb */ - cfs_list_add_tail(&tsi->tsi_list, &tsb->bat_tests); - return 0; - } + if (!tsi->tsi_is_client) { + /* it's test server, just add it to tsb */ + list_add_tail(&tsi->tsi_list, &tsb->bat_tests); + return 0; + } LASSERT (bk != NULL); -#ifndef __KERNEL__ - LASSERT (bk->bk_pages != NULL); -#endif LASSERT (bk->bk_niov * SFW_ID_PER_PAGE >= (unsigned int)ndest); - LASSERT ((unsigned int)bk->bk_len >= sizeof(lnet_process_id_t) * ndest); + LASSERT((unsigned int)bk->bk_len >= + sizeof(struct lnet_process_id_packed) * ndest); - sfw_unpack_test_req(msg); + sfw_unpack_addtest_req(msg); memcpy(&tsi->tsi_u, &req->tsr_u, sizeof(tsi->tsi_u)); for (i = 0; i < ndest; i++) { - lnet_process_id_packed_t *dests; - lnet_process_id_packed_t id; + struct lnet_process_id_packed *dests; + struct lnet_process_id_packed id; int j; -#ifdef __KERNEL__ - dests = cfs_page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page); - LASSERT (dests != NULL); /* my pages are within KVM always */ -#else - dests = cfs_page_address(bk->bk_pages[i / SFW_ID_PER_PAGE]); -#endif + dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page); + LASSERT (dests != NULL); /* my pages are within KVM always */ id = dests[i % SFW_ID_PER_PAGE]; if (msg->msg_magic != SRPC_MSG_MAGIC) sfw_unpack_id(id); @@ -784,24 +809,24 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) goto error; } - tsu->tsu_dest.nid = id.nid; - tsu->tsu_dest.pid = id.pid; - tsu->tsu_instance = tsi; - tsu->tsu_private = NULL; - cfs_list_add_tail(&tsu->tsu_list, &tsi->tsi_units); - } - } + tsu->tsu_dest.nid = id.nid; + tsu->tsu_dest.pid = id.pid; + tsu->tsu_instance = tsi; + tsu->tsu_private = NULL; + list_add_tail(&tsu->tsu_list, &tsi->tsi_units); + } + } - rc = tsi->tsi_ops->tso_init(tsi); - if (rc == 0) { - cfs_list_add_tail(&tsi->tsi_list, &tsb->bat_tests); - return 0; - } + rc = tsi->tsi_ops->tso_init(tsi); + if (rc == 0) { + list_add_tail(&tsi->tsi_list, &tsb->bat_tests); + return 0; + } error: - LASSERT (rc != 0); - sfw_destroy_test_instance(tsi); - return rc; + LASSERT(rc != 0); + sfw_destroy_test_instance(tsi); + return rc; } static void @@ -813,42 +838,41 @@ sfw_test_unit_done (sfw_test_unit_t *tsu) LASSERT (sfw_test_active(tsi)); - if (!cfs_atomic_dec_and_test(&tsi->tsi_nactive)) + if (!atomic_dec_and_test(&tsi->tsi_nactive)) return; /* the test instance is done */ - cfs_spin_lock(&tsi->tsi_lock); + spin_lock(&tsi->tsi_lock); - tsi->tsi_stopping = 0; + tsi->tsi_stopping = 0; - cfs_spin_unlock(&tsi->tsi_lock); + spin_unlock(&tsi->tsi_lock); - cfs_spin_lock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); - if (!cfs_atomic_dec_and_test(&tsb->bat_nactive) ||/* tsb still active */ - sn == sfw_data.fw_session) { /* sn also active */ - cfs_spin_unlock(&sfw_data.fw_lock); + if (!atomic_dec_and_test(&tsb->bat_nactive) ||/* tsb still active */ + sn == sfw_data.fw_session) { /* sn also active */ + spin_unlock(&sfw_data.fw_lock); return; } - LASSERT (!cfs_list_empty(&sn->sn_list)); /* I'm a zombie! */ + LASSERT(!list_empty(&sn->sn_list)); /* I'm a zombie! */ - cfs_list_for_each_entry_typed (tsb, &sn->sn_batches, - sfw_batch_t, bat_list) { - if (sfw_batch_active(tsb)) { - cfs_spin_unlock(&sfw_data.fw_lock); - return; - } - } + list_for_each_entry(tsb, &sn->sn_batches, bat_list) { + if (sfw_batch_active(tsb)) { + spin_unlock(&sfw_data.fw_lock); + return; + } + } - cfs_list_del_init(&sn->sn_list); - cfs_spin_unlock(&sfw_data.fw_lock); + list_del_init(&sn->sn_list); + spin_unlock(&sfw_data.fw_lock); - sfw_destroy_session(sn); - return; + sfw_destroy_session(sn); + return; } -void +static void sfw_test_rpc_done (srpc_client_rpc_t *rpc) { sfw_test_unit_t *tsu = rpc->crpc_priv; @@ -856,13 +880,13 @@ sfw_test_rpc_done (srpc_client_rpc_t *rpc) int done = 0; tsi->tsi_ops->tso_done_rpc(tsu, rpc); - - cfs_spin_lock(&tsi->tsi_lock); - LASSERT (sfw_test_active(tsi)); - LASSERT (!cfs_list_empty(&rpc->crpc_list)); + spin_lock(&tsi->tsi_lock); + + LASSERT(sfw_test_active(tsi)); + LASSERT(!list_empty(&rpc->crpc_list)); - cfs_list_del_init(&rpc->crpc_list); + list_del_init(&rpc->crpc_list); /* batch is stopping or loop is done or get error */ if (tsi->tsi_stopping || @@ -873,7 +897,7 @@ sfw_test_rpc_done (srpc_client_rpc_t *rpc) /* dec ref for poster */ srpc_client_rpc_decref(rpc); - cfs_spin_unlock(&tsi->tsi_lock); + spin_unlock(&tsi->tsi_lock); if (!done) { swi_schedule_workitem(&tsu->tsu_worker); @@ -885,47 +909,52 @@ sfw_test_rpc_done (srpc_client_rpc_t *rpc) } int -sfw_create_test_rpc (sfw_test_unit_t *tsu, lnet_process_id_t peer, - int nblk, int blklen, srpc_client_rpc_t **rpcpp) +sfw_create_test_rpc(sfw_test_unit_t *tsu, struct lnet_process_id peer, + unsigned features, int nblk, int blklen, + srpc_client_rpc_t **rpcpp) { - srpc_client_rpc_t *rpc = NULL; - sfw_test_instance_t *tsi = tsu->tsu_instance; + srpc_client_rpc_t *rpc = NULL; + sfw_test_instance_t *tsi = tsu->tsu_instance; - cfs_spin_lock(&tsi->tsi_lock); + spin_lock(&tsi->tsi_lock); LASSERT (sfw_test_active(tsi)); - if (!cfs_list_empty(&tsi->tsi_free_rpcs)) { - /* pick request from buffer */ - rpc = cfs_list_entry(tsi->tsi_free_rpcs.next, - srpc_client_rpc_t, crpc_list); - LASSERT (nblk == rpc->crpc_bulk.bk_niov); - cfs_list_del_init(&rpc->crpc_list); - - srpc_init_client_rpc(rpc, peer, tsi->tsi_service, nblk, - blklen, sfw_test_rpc_done, - sfw_test_rpc_fini, tsu); - } - - cfs_spin_unlock(&tsi->tsi_lock); - - if (rpc == NULL) - rpc = srpc_create_client_rpc(peer, tsi->tsi_service, nblk, - blklen, sfw_test_rpc_done, - sfw_test_rpc_fini, tsu); - if (rpc == NULL) { - CERROR ("Can't create rpc for test %d\n", tsi->tsi_service); - return -ENOMEM; - } - - *rpcpp = rpc; - return 0; + if (!list_empty(&tsi->tsi_free_rpcs)) { + /* pick request from buffer */ + rpc = list_entry(tsi->tsi_free_rpcs.next, + srpc_client_rpc_t, crpc_list); + LASSERT(nblk == rpc->crpc_bulk.bk_niov); + list_del_init(&rpc->crpc_list); + } + + spin_unlock(&tsi->tsi_lock); + + if (rpc == NULL) { + rpc = srpc_create_client_rpc(peer, tsi->tsi_service, nblk, + blklen, sfw_test_rpc_done, + sfw_test_rpc_fini, tsu); + } else { + srpc_init_client_rpc(rpc, peer, tsi->tsi_service, nblk, + blklen, sfw_test_rpc_done, + sfw_test_rpc_fini, tsu); + } + + if (rpc == NULL) { + CERROR("Can't create rpc for test %d\n", tsi->tsi_service); + return -ENOMEM; + } + + rpc->crpc_reqstmsg.msg_ses_feats = features; + *rpcpp = rpc; + + return 0; } -int +static int sfw_run_test (swi_workitem_t *wi) { - sfw_test_unit_t *tsu = wi->wi_data; + sfw_test_unit_t *tsu = wi->swi_workitem.wi_data; sfw_test_instance_t *tsi = tsu->tsu_instance; srpc_client_rpc_t *rpc = NULL; @@ -938,26 +967,25 @@ sfw_run_test (swi_workitem_t *wi) LASSERT (rpc != NULL); - cfs_spin_lock(&tsi->tsi_lock); + spin_lock(&tsi->tsi_lock); - if (tsi->tsi_stopping) { - cfs_list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs); - cfs_spin_unlock(&tsi->tsi_lock); - goto test_done; - } + if (tsi->tsi_stopping) { + list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs); + spin_unlock(&tsi->tsi_lock); + goto test_done; + } - if (tsu->tsu_loop > 0) - tsu->tsu_loop--; + if (tsu->tsu_loop > 0) + tsu->tsu_loop--; - cfs_list_add_tail(&rpc->crpc_list, &tsi->tsi_active_rpcs); - cfs_spin_unlock(&tsi->tsi_lock); + list_add_tail(&rpc->crpc_list, &tsi->tsi_active_rpcs); + spin_unlock(&tsi->tsi_lock); - rpc->crpc_timeout = rpc_timeout; - - cfs_spin_lock(&rpc->crpc_lock); - srpc_post_rpc(rpc); - cfs_spin_unlock(&rpc->crpc_lock); - return 0; + spin_lock(&rpc->crpc_lock); + rpc->crpc_timeout = rpc_timeout; + srpc_post_rpc(rpc); + spin_unlock(&rpc->crpc_lock); + return 0; test_done: /* @@ -967,12 +995,12 @@ test_done: * - my batch is still active; no one can run it again now. * Cancel pending schedules and prevent future schedule attempts: */ - swi_kill_workitem(wi); - sfw_test_unit_done(tsu); - return 1; + swi_exit_workitem(wi); + sfw_test_unit_done(tsu); + return 1; } -int +static int sfw_run_batch (sfw_batch_t *tsb) { swi_workitem_t *wi; @@ -980,32 +1008,33 @@ sfw_run_batch (sfw_batch_t *tsb) sfw_test_instance_t *tsi; if (sfw_batch_active(tsb)) { - CDEBUG(D_NET, "Batch already active: "LPU64" (%d)\n", - tsb->bat_id.bat_id, cfs_atomic_read(&tsb->bat_nactive)); + CDEBUG(D_NET, "Batch already active: %llu (%d)\n", + tsb->bat_id.bat_id, atomic_read(&tsb->bat_nactive)); return 0; } - cfs_list_for_each_entry_typed (tsi, &tsb->bat_tests, - sfw_test_instance_t, tsi_list) { - if (!tsi->tsi_is_client) /* skip server instances */ - continue; + list_for_each_entry(tsi, &tsb->bat_tests, tsi_list) { + if (!tsi->tsi_is_client) /* skip server instances */ + continue; - LASSERT (!tsi->tsi_stopping); - LASSERT (!sfw_test_active(tsi)); + LASSERT(!tsi->tsi_stopping); + LASSERT(!sfw_test_active(tsi)); - cfs_atomic_inc(&tsb->bat_nactive); + atomic_inc(&tsb->bat_nactive); - cfs_list_for_each_entry_typed (tsu, &tsi->tsi_units, - sfw_test_unit_t, tsu_list) { - cfs_atomic_inc(&tsi->tsi_nactive); - tsu->tsu_loop = tsi->tsi_loop; - wi = &tsu->tsu_worker; - swi_init_workitem(wi, tsu, sfw_run_test); - swi_schedule_workitem(wi); - } - } + list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) { + atomic_inc(&tsi->tsi_nactive); + tsu->tsu_loop = tsi->tsi_loop; + wi = &tsu->tsu_worker; + swi_init_workitem(wi, tsu, sfw_run_test, + lst_sched_test[\ + lnet_cpt_of_nid(tsu->tsu_dest.nid, + NULL)]); + swi_schedule_workitem(wi); + } + } - return 0; + return 0; } int @@ -1015,44 +1044,42 @@ sfw_stop_batch (sfw_batch_t *tsb, int force) srpc_client_rpc_t *rpc; if (!sfw_batch_active(tsb)) { - CDEBUG(D_NET, "Batch "LPU64" inactive\n", tsb->bat_id.bat_id); + CDEBUG(D_NET, "Batch %llu inactive\n", tsb->bat_id.bat_id); return 0; } - cfs_list_for_each_entry_typed (tsi, &tsb->bat_tests, - sfw_test_instance_t, tsi_list) { - cfs_spin_lock(&tsi->tsi_lock); + list_for_each_entry(tsi, &tsb->bat_tests, tsi_list) { + spin_lock(&tsi->tsi_lock); - if (!tsi->tsi_is_client || - !sfw_test_active(tsi) || tsi->tsi_stopping) { - cfs_spin_unlock(&tsi->tsi_lock); - continue; - } + if (!tsi->tsi_is_client || + !sfw_test_active(tsi) || tsi->tsi_stopping) { + spin_unlock(&tsi->tsi_lock); + continue; + } - tsi->tsi_stopping = 1; + tsi->tsi_stopping = 1; - if (!force) { - cfs_spin_unlock(&tsi->tsi_lock); - continue; - } + if (!force) { + spin_unlock(&tsi->tsi_lock); + continue; + } - /* abort launched rpcs in the test */ - cfs_list_for_each_entry_typed (rpc, &tsi->tsi_active_rpcs, - srpc_client_rpc_t, crpc_list) { - cfs_spin_lock(&rpc->crpc_lock); + /* abort launched rpcs in the test */ + list_for_each_entry(rpc, &tsi->tsi_active_rpcs, crpc_list) { + spin_lock(&rpc->crpc_lock); - srpc_abort_rpc(rpc, -EINTR); + srpc_abort_rpc(rpc, -EINTR); - cfs_spin_unlock(&rpc->crpc_lock); - } + spin_unlock(&rpc->crpc_lock); + } - cfs_spin_unlock(&tsi->tsi_lock); - } + spin_unlock(&tsi->tsi_lock); + } - return 0; + return 0; } -int +static int sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply) { sfw_test_instance_t *tsi; @@ -1061,16 +1088,15 @@ sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply) return -EINVAL; if (testidx == 0) { - reply->bar_active = cfs_atomic_read(&tsb->bat_nactive); + reply->bar_active = atomic_read(&tsb->bat_nactive); return 0; } - cfs_list_for_each_entry_typed (tsi, &tsb->bat_tests, - sfw_test_instance_t, tsi_list) { + list_for_each_entry(tsi, &tsb->bat_tests, tsi_list) { if (testidx-- > 1) continue; - reply->bar_active = cfs_atomic_read(&tsi->tsi_nactive); + reply->bar_active = atomic_read(&tsi->tsi_nactive); return 0; } @@ -1085,18 +1111,20 @@ sfw_free_pages (srpc_server_rpc_t *rpc) } int -sfw_alloc_pages (srpc_server_rpc_t *rpc, int npages, int sink) +sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len, + int sink) { - LASSERT (rpc->srpc_bulk == NULL); - LASSERT (npages > 0 && npages <= LNET_MAX_IOV); + LASSERT(rpc->srpc_bulk == NULL); + LASSERT(npages > 0 && npages <= LNET_MAX_IOV); - rpc->srpc_bulk = srpc_alloc_bulk(npages, sink); - if (rpc->srpc_bulk == NULL) return -ENOMEM; + rpc->srpc_bulk = srpc_alloc_bulk(cpt, 0, npages, len, sink); + if (rpc->srpc_bulk == NULL) + return -ENOMEM; - return 0; + return 0; } -int +static int sfw_add_test (srpc_server_rpc_t *rpc) { sfw_session_t *sn = sfw_data.fw_session; @@ -1126,10 +1154,10 @@ sfw_add_test (srpc_server_rpc_t *rpc) return 0; } - bat = sfw_bid2batch(request->tsr_bid); - if (bat == NULL) { - CERROR ("Dropping RPC (%s) from %s under memory pressure.\n", - rpc->srpc_service->sv_name, + bat = sfw_bid2batch(request->tsr_bid); + if (bat == NULL) { + CERROR("dropping RPC %s from %s under memory pressure\n", + rpc->srpc_scd->scd_svc->sv_name, libcfs_id2str(rpc->srpc_peer)); return -ENOMEM; } @@ -1140,9 +1168,19 @@ sfw_add_test (srpc_server_rpc_t *rpc) } if (request->tsr_is_client && rpc->srpc_bulk == NULL) { - /* rpc will be resumed later in sfw_bulk_ready */ - return sfw_alloc_pages(rpc, - sfw_id_pages(request->tsr_ndest), 1); + /* rpc will be resumed later in sfw_bulk_ready */ + int npg = sfw_id_pages(request->tsr_ndest); + int len; + + if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) { + len = npg * PAGE_SIZE; + + } else { + len = sizeof(struct lnet_process_id_packed) * + request->tsr_ndest; + } + + return sfw_alloc_pages(rpc, CFS_CPT_ANY, npg, len, 1); } rc = sfw_add_test_instance(bat, rpc); @@ -1156,7 +1194,7 @@ sfw_add_test (srpc_server_rpc_t *rpc) return 0; } -int +static int sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply) { sfw_session_t *sn = sfw_data.fw_session; @@ -1197,37 +1235,63 @@ sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply) return 0; } -int -sfw_handle_server_rpc (srpc_server_rpc_t *rpc) +static int +sfw_handle_server_rpc(struct srpc_server_rpc *rpc) { - srpc_service_t *sv = rpc->srpc_service; - srpc_msg_t *reply = &rpc->srpc_replymsg; - srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg; - int rc = 0; - - LASSERT (sfw_data.fw_active_srpc == NULL); - LASSERT (sv->sv_id <= SRPC_FRAMEWORK_SERVICE_MAX_ID); - - cfs_spin_lock(&sfw_data.fw_lock); - - if (sfw_data.fw_shuttingdown) { - cfs_spin_unlock(&sfw_data.fw_lock); - return -ESHUTDOWN; - } - - /* Remove timer to avoid racing with it or expiring active session */ - if (sfw_del_session_timer() != 0) { - CERROR ("Dropping RPC (%s) from %s: racing with expiry timer.", - sv->sv_name, libcfs_id2str(rpc->srpc_peer)); - cfs_spin_unlock(&sfw_data.fw_lock); - return -EAGAIN; - } - - sfw_data.fw_active_srpc = rpc; - cfs_spin_unlock(&sfw_data.fw_lock); - - sfw_unpack_message(request); - LASSERT (request->msg_type == srpc_service2request(sv->sv_id)); + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + srpc_msg_t *reply = &rpc->srpc_replymsg; + srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg; + unsigned features = LST_FEATS_MASK; + int rc = 0; + + LASSERT(sfw_data.fw_active_srpc == NULL); + LASSERT(sv->sv_id <= SRPC_FRAMEWORK_SERVICE_MAX_ID); + + spin_lock(&sfw_data.fw_lock); + + if (sfw_data.fw_shuttingdown) { + spin_unlock(&sfw_data.fw_lock); + return -ESHUTDOWN; + } + + /* Remove timer to avoid racing with it or expiring active session */ + if (sfw_del_session_timer() != 0) { + CERROR("dropping RPC %s from %s: racing with expiry timer\n", + sv->sv_name, libcfs_id2str(rpc->srpc_peer)); + spin_unlock(&sfw_data.fw_lock); + return -EAGAIN; + } + + sfw_data.fw_active_srpc = rpc; + spin_unlock(&sfw_data.fw_lock); + + sfw_unpack_message(request); + LASSERT(request->msg_type == srpc_service2request(sv->sv_id)); + + /* rpc module should have checked this */ + LASSERT(request->msg_version == SRPC_MSG_VERSION); + + if (sv->sv_id != SRPC_SERVICE_MAKE_SESSION && + sv->sv_id != SRPC_SERVICE_DEBUG) { + sfw_session_t *sn = sfw_data.fw_session; + + if (sn != NULL && + sn->sn_features != request->msg_ses_feats) { + CNETERR("Features of framework RPC don't match " + "features of current session: %x/%x\n", + request->msg_ses_feats, sn->sn_features); + reply->msg_body.reply.status = EPROTO; + reply->msg_body.reply.sid = sn->sn_id; + goto out; + } + + } else if ((request->msg_ses_feats & ~LST_FEATS_MASK) != 0) { + /* NB: at this point, old version will ignore features and + * create new session anyway, so console should be able + * to handle this */ + reply->msg_body.reply.status = EPROTO; + goto out; + } switch(sv->sv_id) { default: @@ -1262,104 +1326,104 @@ sfw_handle_server_rpc (srpc_server_rpc_t *rpc) break; } - rpc->srpc_done = sfw_server_rpc_done; - cfs_spin_lock(&sfw_data.fw_lock); + if (sfw_data.fw_session != NULL) + features = sfw_data.fw_session->sn_features; + out: + reply->msg_ses_feats = features; + rpc->srpc_done = sfw_server_rpc_done; + spin_lock(&sfw_data.fw_lock); -#ifdef __KERNEL__ - if (!sfw_data.fw_shuttingdown) - sfw_add_session_timer(); -#else - LASSERT (!sfw_data.fw_shuttingdown); - sfw_add_session_timer(); -#endif + if (!sfw_data.fw_shuttingdown) + sfw_add_session_timer(); - sfw_data.fw_active_srpc = NULL; - cfs_spin_unlock(&sfw_data.fw_lock); - return rc; + sfw_data.fw_active_srpc = NULL; + spin_unlock(&sfw_data.fw_lock); + return rc; } -int -sfw_bulk_ready (srpc_server_rpc_t *rpc, int status) +static int +sfw_bulk_ready(struct srpc_server_rpc *rpc, int status) { - srpc_service_t *sv = rpc->srpc_service; - int rc; - - LASSERT (rpc->srpc_bulk != NULL); - LASSERT (sv->sv_id == SRPC_SERVICE_TEST); - LASSERT (sfw_data.fw_active_srpc == NULL); - LASSERT (rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst.tsr_is_client); - - cfs_spin_lock(&sfw_data.fw_lock); - - if (status != 0) { - CERROR ("Bulk transfer failed for RPC: " - "service %s, peer %s, status %d\n", - sv->sv_name, libcfs_id2str(rpc->srpc_peer), status); - cfs_spin_unlock(&sfw_data.fw_lock); - return -EIO; - } + struct srpc_service *sv = rpc->srpc_scd->scd_svc; + int rc; - if (sfw_data.fw_shuttingdown) { - cfs_spin_unlock(&sfw_data.fw_lock); - return -ESHUTDOWN; - } + LASSERT(rpc->srpc_bulk != NULL); + LASSERT(sv->sv_id == SRPC_SERVICE_TEST); + LASSERT(sfw_data.fw_active_srpc == NULL); + LASSERT(rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst.tsr_is_client); - if (sfw_del_session_timer() != 0) { - CERROR ("Dropping RPC (%s) from %s: racing with expiry timer", - sv->sv_name, libcfs_id2str(rpc->srpc_peer)); - cfs_spin_unlock(&sfw_data.fw_lock); - return -EAGAIN; - } + spin_lock(&sfw_data.fw_lock); - sfw_data.fw_active_srpc = rpc; - cfs_spin_unlock(&sfw_data.fw_lock); + if (status != 0) { + CERROR("Bulk transfer failed for RPC: " + "service %s, peer %s, status %d\n", + sv->sv_name, libcfs_id2str(rpc->srpc_peer), status); + spin_unlock(&sfw_data.fw_lock); + return -EIO; + } - rc = sfw_add_test(rpc); + if (sfw_data.fw_shuttingdown) { + spin_unlock(&sfw_data.fw_lock); + return -ESHUTDOWN; + } - cfs_spin_lock(&sfw_data.fw_lock); + if (sfw_del_session_timer() != 0) { + CERROR("dropping RPC %s from %s: racing with expiry timer\n", + sv->sv_name, libcfs_id2str(rpc->srpc_peer)); + spin_unlock(&sfw_data.fw_lock); + return -EAGAIN; + } -#ifdef __KERNEL__ - if (!sfw_data.fw_shuttingdown) - sfw_add_session_timer(); -#else - LASSERT (!sfw_data.fw_shuttingdown); - sfw_add_session_timer(); -#endif + sfw_data.fw_active_srpc = rpc; + spin_unlock(&sfw_data.fw_lock); - sfw_data.fw_active_srpc = NULL; - cfs_spin_unlock(&sfw_data.fw_lock); - return rc; + rc = sfw_add_test(rpc); + + spin_lock(&sfw_data.fw_lock); + + if (!sfw_data.fw_shuttingdown) + sfw_add_session_timer(); + + sfw_data.fw_active_srpc = NULL; + spin_unlock(&sfw_data.fw_lock); + return rc; } srpc_client_rpc_t * -sfw_create_rpc (lnet_process_id_t peer, int service, - int nbulkiov, int bulklen, - void (*done) (srpc_client_rpc_t *), void *priv) +sfw_create_rpc(struct lnet_process_id peer, int service, + unsigned features, int nbulkiov, int bulklen, + void (*done)(srpc_client_rpc_t *), void *priv) { - srpc_client_rpc_t *rpc; + srpc_client_rpc_t *rpc = NULL; - cfs_spin_lock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); LASSERT (!sfw_data.fw_shuttingdown); LASSERT (service <= SRPC_FRAMEWORK_SERVICE_MAX_ID); - if (nbulkiov == 0 && !cfs_list_empty(&sfw_data.fw_zombie_rpcs)) { - rpc = cfs_list_entry(sfw_data.fw_zombie_rpcs.next, + if (nbulkiov == 0 && !list_empty(&sfw_data.fw_zombie_rpcs)) { + rpc = list_entry(sfw_data.fw_zombie_rpcs.next, srpc_client_rpc_t, crpc_list); - cfs_list_del(&rpc->crpc_list); - cfs_spin_unlock(&sfw_data.fw_lock); + list_del(&rpc->crpc_list); srpc_init_client_rpc(rpc, peer, service, 0, 0, done, sfw_client_rpc_fini, priv); - return rpc; } - cfs_spin_unlock(&sfw_data.fw_lock); + spin_unlock(&sfw_data.fw_lock); - rpc = srpc_create_client_rpc(peer, service, nbulkiov, bulklen, done, - nbulkiov != 0 ? NULL : sfw_client_rpc_fini, - priv); - return rpc; + if (rpc == NULL) { + rpc = srpc_create_client_rpc(peer, service, + nbulkiov, bulklen, done, + nbulkiov != 0 ? NULL : + sfw_client_rpc_fini, + priv); + } + + if (rpc != NULL) /* "session" is concept in framework */ + rpc->crpc_reqstmsg.msg_ses_feats = features; + + return rpc; } void @@ -1368,10 +1432,9 @@ sfw_unpack_message (srpc_msg_t *msg) if (msg->msg_magic == SRPC_MSG_MAGIC) return; /* no flipping needed */ + /* srpc module should guarantee I wouldn't get crap */ LASSERT (msg->msg_magic == __swab32(SRPC_MSG_MAGIC)); - __swab32s(&msg->msg_type); - if (msg->msg_type == SRPC_MSG_STAT_REQST) { srpc_stat_reqst_t *req = &msg->msg_body.stat_reqst; @@ -1510,33 +1573,33 @@ sfw_unpack_message (srpc_msg_t *msg) void sfw_abort_rpc (srpc_client_rpc_t *rpc) { - LASSERT (cfs_atomic_read(&rpc->crpc_refcount) > 0); - LASSERT (rpc->crpc_service <= SRPC_FRAMEWORK_SERVICE_MAX_ID); + LASSERT(atomic_read(&rpc->crpc_refcount) > 0); + LASSERT(rpc->crpc_service <= SRPC_FRAMEWORK_SERVICE_MAX_ID); - cfs_spin_lock(&rpc->crpc_lock); - srpc_abort_rpc(rpc, -EINTR); - cfs_spin_unlock(&rpc->crpc_lock); - return; + spin_lock(&rpc->crpc_lock); + srpc_abort_rpc(rpc, -EINTR); + spin_unlock(&rpc->crpc_lock); + return; } void sfw_post_rpc (srpc_client_rpc_t *rpc) { - cfs_spin_lock(&rpc->crpc_lock); + spin_lock(&rpc->crpc_lock); - LASSERT (!rpc->crpc_closed); - LASSERT (!rpc->crpc_aborted); - LASSERT (cfs_list_empty(&rpc->crpc_list)); - LASSERT (!sfw_data.fw_shuttingdown); + LASSERT(!rpc->crpc_closed); + LASSERT(!rpc->crpc_aborted); + LASSERT(list_empty(&rpc->crpc_list)); + LASSERT(!sfw_data.fw_shuttingdown); - rpc->crpc_timeout = rpc_timeout; - srpc_post_rpc(rpc); + rpc->crpc_timeout = rpc_timeout; + srpc_post_rpc(rpc); - cfs_spin_unlock(&rpc->crpc_lock); - return; + spin_unlock(&rpc->crpc_lock); + return; } -static srpc_service_t sfw_services[] = +static srpc_service_t sfw_services[] = { { /* sv_id */ SRPC_SERVICE_DEBUG, @@ -1575,17 +1638,6 @@ static srpc_service_t sfw_services[] = } }; -extern sfw_test_client_ops_t ping_test_client; -extern srpc_service_t ping_test_service; -extern void ping_init_test_client(void); -extern void ping_init_test_service(void); - -extern sfw_test_client_ops_t brw_test_client; -extern srpc_service_t brw_test_service; -extern void brw_init_test_client(void); -extern void brw_init_test_service(void); - - int sfw_startup (void) { @@ -1595,18 +1647,6 @@ sfw_startup (void) srpc_service_t *sv; sfw_test_case_t *tsc; -#ifndef __KERNEL__ - char *s; - - s = getenv("SESSION_TIMEOUT"); - session_timeout = s != NULL ? atoi(s) : session_timeout; - - s = getenv("BRW_INJECT_ERRORS"); - brw_inject_errors = s != NULL ? atoi(s) : brw_inject_errors; - - s = getenv("RPC_TIMEOUT"); - rpc_timeout = s != NULL ? atoi(s) : rpc_timeout; -#endif if (session_timeout < 0) { CERROR ("Session timeout must be non-negative: %d\n", @@ -1632,11 +1672,11 @@ sfw_startup (void) sfw_data.fw_session = NULL; sfw_data.fw_active_srpc = NULL; - cfs_spin_lock_init(&sfw_data.fw_lock); - cfs_atomic_set(&sfw_data.fw_nzombies, 0); - CFS_INIT_LIST_HEAD(&sfw_data.fw_tests); - CFS_INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs); - CFS_INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions); + spin_lock_init(&sfw_data.fw_lock); + atomic_set(&sfw_data.fw_nzombies, 0); + INIT_LIST_HEAD(&sfw_data.fw_tests); + INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs); + INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions); brw_init_test_client(); brw_init_test_service(); @@ -1648,20 +1688,18 @@ sfw_startup (void) rc = sfw_register_test(&ping_test_service, &ping_test_client); LASSERT (rc == 0); - error = 0; - cfs_list_for_each_entry_typed (tsc, &sfw_data.fw_tests, - sfw_test_case_t, tsc_list) { - sv = tsc->tsc_srv_service; - sv->sv_concur = SFW_TEST_CONCURRENCY; + error = 0; + list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) { + sv = tsc->tsc_srv_service; - rc = srpc_add_service(sv); - LASSERT (rc != -EBUSY); - if (rc != 0) { - CWARN ("Failed to add %s service: %d\n", - sv->sv_name, rc); - error = rc; - } - } + rc = srpc_add_service(sv); + LASSERT(rc != -EBUSY); + if (rc != 0) { + CWARN("Failed to add %s service: %d\n", + sv->sv_name, rc); + error = rc; + } + } for (i = 0; ; i++) { sv = &sfw_services[i]; @@ -1669,7 +1707,7 @@ sfw_startup (void) sv->sv_bulk_ready = NULL; sv->sv_handler = sfw_handle_server_rpc; - sv->sv_concur = SFW_SERVICE_CONCURRENCY; + sv->sv_wi_total = SFW_FRWK_WI_MAX; if (sv->sv_id == SRPC_SERVICE_TEST) sv->sv_bulk_ready = sfw_bulk_ready; @@ -1684,13 +1722,13 @@ sfw_startup (void) /* about to sfw_shutdown, no need to add buffer */ if (error) continue; - rc = srpc_service_add_buffers(sv, SFW_POST_BUFFERS); - if (rc != SFW_POST_BUFFERS) { - CWARN ("Failed to reserve enough buffers: " - "service %s, %d needed, %d reserved\n", - sv->sv_name, SFW_POST_BUFFERS, rc); - error = -ENOMEM; - } + rc = srpc_service_add_buffers(sv, sv->sv_wi_total); + if (rc != 0) { + CWARN("Failed to reserve enough buffers: " + "service %s, %d needed: %d\n", + sv->sv_name, sv->sv_wi_total, rc); + error = -ENOMEM; + } } if (error != 0) @@ -1701,31 +1739,27 @@ sfw_startup (void) void sfw_shutdown (void) { - srpc_service_t *sv; - sfw_test_case_t *tsc; - int i; + srpc_service_t *sv; + sfw_test_case_t *tsc; + int i; - cfs_spin_lock(&sfw_data.fw_lock); + spin_lock(&sfw_data.fw_lock); sfw_data.fw_shuttingdown = 1; -#ifdef __KERNEL__ lst_wait_until(sfw_data.fw_active_srpc == NULL, sfw_data.fw_lock, "waiting for active RPC to finish.\n"); -#else - LASSERT (sfw_data.fw_active_srpc == NULL); -#endif if (sfw_del_session_timer() != 0) lst_wait_until(sfw_data.fw_session == NULL, sfw_data.fw_lock, "waiting for session timer to explode.\n"); sfw_deactivate_session(); - lst_wait_until(cfs_atomic_read(&sfw_data.fw_nzombies) == 0, + lst_wait_until(atomic_read(&sfw_data.fw_nzombies) == 0, sfw_data.fw_lock, "waiting for %d zombie sessions to die.\n", - cfs_atomic_read(&sfw_data.fw_nzombies)); + atomic_read(&sfw_data.fw_nzombies)); - cfs_spin_unlock(&sfw_data.fw_lock); + spin_unlock(&sfw_data.fw_lock); for (i = 0; ; i++) { sv = &sfw_services[i]; @@ -1736,22 +1770,21 @@ sfw_shutdown (void) srpc_remove_service(sv); } - cfs_list_for_each_entry_typed (tsc, &sfw_data.fw_tests, - sfw_test_case_t, tsc_list) { + list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) { sv = tsc->tsc_srv_service; srpc_shutdown_service(sv); srpc_remove_service(sv); } - while (!cfs_list_empty(&sfw_data.fw_zombie_rpcs)) { - srpc_client_rpc_t *rpc; + while (!list_empty(&sfw_data.fw_zombie_rpcs)) { + srpc_client_rpc_t *rpc; - rpc = cfs_list_entry(sfw_data.fw_zombie_rpcs.next, - srpc_client_rpc_t, crpc_list); - cfs_list_del(&rpc->crpc_list); + rpc = list_entry(sfw_data.fw_zombie_rpcs.next, + srpc_client_rpc_t, crpc_list); + list_del(&rpc->crpc_list); - LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); - } + LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); + } for (i = 0; ; i++) { sv = &sfw_services[i]; @@ -1761,15 +1794,15 @@ sfw_shutdown (void) srpc_wait_service_shutdown(sv); } - while (!cfs_list_empty(&sfw_data.fw_tests)) { - tsc = cfs_list_entry(sfw_data.fw_tests.next, - sfw_test_case_t, tsc_list); + while (!list_empty(&sfw_data.fw_tests)) { + tsc = list_entry(sfw_data.fw_tests.next, + sfw_test_case_t, tsc_list); - srpc_wait_service_shutdown(tsc->tsc_srv_service); + srpc_wait_service_shutdown(tsc->tsc_srv_service); - cfs_list_del(&tsc->tsc_list); - LIBCFS_FREE(tsc, sizeof(*tsc)); - } + list_del(&tsc->tsc_list); + LIBCFS_FREE(tsc, sizeof(*tsc)); + } - return; + return; }