/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Author: Liang Zhen <liangzhen@clusterfs.com>
*
- * This file is part of Lustre, http://www.lustre.org
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * 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.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/selftest/conctl.c
*
* Infrastructure of LST console
+ *
+ * Author: Liang Zhen <liangzhen@clusterfs.com>
*/
+
#ifdef __KERNEL__
#include <libcfs/libcfs.h>
LASSERT (id.nid != LNET_NID_ANY);
- list_for_each_entry(ndl, &console_session.ses_ndl_hash[idx], ndl_hlink) {
+ cfs_list_for_each_entry_typed(ndl, &console_session.ses_ndl_hash[idx],
+ lstcon_ndlink_t, ndl_hlink) {
if (ndl->ndl_node->nd_id.nid != id.nid ||
ndl->ndl_node->nd_id.pid != id.pid)
continue;
return -EINVAL;
/* search in hash */
- list_for_each_entry(ndl, &hash[idx], ndl_hlink) {
+ cfs_list_for_each_entry_typed(ndl, &hash[idx],
+ lstcon_ndlink_t, ndl_hlink) {
if (ndl->ndl_node->nd_id.nid != id.nid ||
ndl->ndl_node->nd_id.pid != id.pid)
continue;
lstcon_ndlink_t *ndl;
lstcon_ndlink_t *tmp;
- list_for_each_entry_safe(ndl, tmp, &grp->grp_ndl_list, ndl_link) {
+ cfs_list_for_each_entry_safe_typed(ndl, tmp, &grp->grp_ndl_list,
+ lstcon_ndlink_t, ndl_link) {
if ((ndl->ndl_node->nd_state & keep) == 0)
lstcon_group_ndlink_release(grp, ndl);
}
{
lstcon_group_t *grp;
- list_for_each_entry(grp, &console_session.ses_grp_list, grp_link) {
+ cfs_list_for_each_entry_typed(grp, &console_session.ses_grp_list,
+ lstcon_group_t, grp_link) {
if (strncmp(grp->grp_name, name, LST_NAME_SIZE) != 0)
continue;
LASSERT (index >= 0);
LASSERT (name_up != NULL);
- list_for_each_entry(grp, &console_session.ses_grp_list, grp_link) {
+ cfs_list_for_each_entry_typed(grp, &console_session.ses_grp_list,
+ lstcon_group_t, grp_link) {
if (index-- == 0) {
return copy_to_user(name_up, grp->grp_name, len) ?
-EFAULT : 0;
LASSERT (*index_p >= 0);
LASSERT (*count_p > 0);
- list_for_each_entry(ndl, head, ndl_link) {
+ cfs_list_for_each_entry_typed(ndl, head, lstcon_ndlink_t, ndl_link) {
if (index++ < *index_p)
continue;
memset(gentp, 0, sizeof(lstcon_ndlist_ent_t));
- list_for_each_entry(ndl, &grp->grp_ndl_list, ndl_link)
+ cfs_list_for_each_entry_typed(ndl, &grp->grp_ndl_list,
+ lstcon_ndlink_t, ndl_link)
LST_NODE_STATE_COUNTER(ndl->ndl_node, gentp);
rc = copy_to_user(gents_p, gentp,
{
lstcon_batch_t *bat;
- list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) {
+ cfs_list_for_each_entry_typed(bat, &console_session.ses_bat_list,
+ lstcon_batch_t, bat_link) {
if (strncmp(bat->bat_name, name, LST_NAME_SIZE) == 0) {
*batpp = bat;
return 0;
LASSERT (name_up != NULL);
LASSERT (index >= 0);
- list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) {
+ cfs_list_for_each_entry_typed(bat, &console_session.ses_bat_list,
+ lstcon_batch_t, bat_link) {
if (index-- == 0) {
return copy_to_user(name_up,bat->bat_name, len) ?
-EFAULT: 0;
if (testidx > 0) {
/* query test, test index start from 1 */
- list_for_each_entry(test, &bat->bat_test_list, tes_link) {
+ cfs_list_for_each_entry_typed(test, &bat->bat_test_list,
+ lstcon_test_t, tes_link) {
if (testidx-- == 1)
break;
}
entp->u.tbe_test.tse_concur = test->tes_concur;
}
- list_for_each_entry(ndl, clilst, ndl_link)
+ cfs_list_for_each_entry_typed(ndl, clilst, lstcon_ndlink_t, ndl_link)
LST_NODE_STATE_COUNTER(ndl->ndl_node, &entp->tbe_cli_nle);
- list_for_each_entry(ndl, srvlst, ndl_link)
+ cfs_list_for_each_entry_typed(ndl, srvlst, lstcon_ndlink_t, ndl_link)
LST_NODE_STATE_COUNTER(ndl->ndl_node, &entp->tbe_srv_nle);
rc = copy_to_user(ent_up, entp,
{
lstcon_test_t *test;
- list_for_each_entry(test, &batch->bat_test_list, tes_link) {
+ cfs_list_for_each_entry_typed(test, &batch->bat_test_list,
+ lstcon_test_t, tes_link) {
if (idx == test->tes_hdr.tsb_index) {
*testpp = test;
return 0;
return rc;
}
- timeout = (timeout > LST_TRANS_MIN_TIMEOUT) ? timeout :
- LST_TRANS_MIN_TIMEOUT;
- lstcon_rpc_trans_postwait(trans, timeout);
+ lstcon_rpc_trans_postwait(trans, LST_VALIDATE_TIMEOUT(timeout));
rc = lstcon_rpc_trans_interpreter(trans, result_up,
lstcon_statrpc_readent);
return rc;
}
- timeout = (timeout > LST_TRANS_MIN_TIMEOUT) ? timeout :
- LST_TRANS_MIN_TIMEOUT;
-
- lstcon_rpc_trans_postwait(trans, timeout);
+ lstcon_rpc_trans_postwait(trans, LST_VALIDATE_TIMEOUT(timeout));
rc = lstcon_rpc_trans_interpreter(trans, result_up,
lstcon_sesrpc_readent);
rc = lstcon_rpc_pinger_start();
if (rc != 0) {
- lstcon_batch_t *bat;
+ lstcon_batch_t *bat = NULL;
lstcon_batch_find(LST_DEFAULT_BATCH, &bat);
lstcon_batch_destroy(bat);
memset(entp, 0, sizeof(*entp));
- list_for_each_entry(ndl, &console_session.ses_ndl_list, ndl_link)
+ cfs_list_for_each_entry_typed(ndl, &console_session.ses_ndl_list,
+ lstcon_ndlink_t, ndl_link)
LST_NODE_STATE_COUNTER(ndl->ndl_node, entp);
if (copy_to_user(sid_up, &console_session.ses_id, sizeof(lst_sid_t)) ||
return rc;
}
-srpc_service_t lstcon_acceptor_service =
+srpc_service_t lstcon_acceptor_service;
+void lstcon_init_acceptor_service(void)
{
- .sv_name = "join session",
- .sv_handler = lstcon_acceptor_handle,
- .sv_bulk_ready = NULL,
- .sv_id = SRPC_SERVICE_JOIN,
- .sv_concur = SFW_SERVICE_CONCURRENCY,
-};
+ /* initialize selftest console acceptor service table */
+ lstcon_acceptor_service.sv_name = "join session";
+ lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle;
+ lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN;
+ lstcon_acceptor_service.sv_concur = SFW_SERVICE_CONCURRENCY;
+}
extern int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data);
for (i = 0; i < LST_GLOBAL_HASHSIZE; i++)
CFS_INIT_LIST_HEAD(&console_session.ses_ndl_hash[i]);
+
+ /* initialize acceptor service table */
+ lstcon_init_acceptor_service();
+
rc = srpc_add_service(&lstcon_acceptor_service);
LASSERT (rc != -EBUSY);
if (rc != 0) {
{
int i;
- mutex_down(&console_session.ses_mutex);
-
libcfs_deregister_ioctl(&lstcon_ioctl_handler);
+ mutex_down(&console_session.ses_mutex);
+
srpc_shutdown_service(&lstcon_acceptor_service);
srpc_remove_service(&lstcon_acceptor_service);