X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Fselftest%2Fconsole.c;h=f2cf0a400f1a3456cc12de86a397a1236b63368b;hb=f8ac16100986b32cbae7b13baf69a30ac598ae7e;hp=e6df2ee8d558eac504b0b2cc817228042d7852df;hpb=33984c012883a7c714429d2c612cf6dcda191974;p=fs%2Flustre-release.git diff --git a/lnet/selftest/console.c b/lnet/selftest/console.c index e6df2ee..f2cf0a4 100644 --- a/lnet/selftest/console.c +++ b/lnet/selftest/console.c @@ -15,11 +15,7 @@ * * 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 */ @@ -40,7 +36,6 @@ * Author: Liang Zhen */ -#ifdef __KERNEL__ #include #include @@ -71,7 +66,7 @@ lstcon_node_get(lstcon_node_t *nd) } static int -lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create) +lstcon_node_find(struct lnet_process_id id, lstcon_node_t **ndpp, int create) { lstcon_ndlink_t *ndl; unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE; @@ -139,8 +134,8 @@ lstcon_node_put(lstcon_node_t *nd) } static int -lstcon_ndlink_find(struct list_head *hash, - lnet_process_id_t id, lstcon_ndlink_t **ndlpp, int create) +lstcon_ndlink_find(struct list_head *hash, struct lnet_process_id id, + lstcon_ndlink_t **ndlpp, int create) { unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE; lstcon_ndlink_t *ndl; @@ -206,9 +201,6 @@ lstcon_group_alloc(char *name, lstcon_group_t **grpp) if (grp == NULL) return -ENOMEM; - memset(grp, 0, offsetof(lstcon_group_t, - grp_ndl_hash[LST_NODE_HASHSIZE])); - grp->grp_ref = 1; if (name != NULL) { if (strlen(name) > sizeof(grp->grp_name)-1) { @@ -288,14 +280,8 @@ lstcon_group_find(const char *name, lstcon_group_t **grpp) return -ENOENT; } -static void -lstcon_group_put(lstcon_group_t *grp) -{ - lstcon_group_decref(grp); -} - static int -lstcon_group_ndlink_find(lstcon_group_t *grp, lnet_process_id_t id, +lstcon_group_ndlink_find(lstcon_group_t *grp, struct lnet_process_id id, lstcon_ndlink_t **ndlpp, int create) { int rc; @@ -382,7 +368,7 @@ lstcon_sesrpc_condition(int transop, lstcon_node_t *nd, void *arg) static int lstcon_sesrpc_readent(int transop, srpc_msg_t *msg, - lstcon_rpc_ent_t __user *ent_up) + struct lstcon_rpc_ent __user *ent_up) { srpc_debug_reply_t *rep; @@ -411,13 +397,13 @@ lstcon_sesrpc_readent(int transop, srpc_msg_t *msg, static int lstcon_group_nodes_add(lstcon_group_t *grp, - int count, lnet_process_id_t __user *ids_up, + int count, struct lnet_process_id __user *ids_up, unsigned *featp, struct list_head __user *result_up) { lstcon_rpc_trans_t *trans; lstcon_ndlink_t *ndl; lstcon_group_t *tmp; - lnet_process_id_t id; + struct lnet_process_id id; int i; int rc; @@ -447,7 +433,7 @@ lstcon_group_nodes_add(lstcon_group_t *grp, } if (rc != 0) { - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; } @@ -456,7 +442,7 @@ lstcon_group_nodes_add(lstcon_group_t *grp, tmp, lstcon_sesrpc_condition, &trans); if (rc != 0) { CERROR("Can't create transaction: %d\n", rc); - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; } @@ -471,20 +457,20 @@ lstcon_group_nodes_add(lstcon_group_t *grp, lstcon_rpc_trans_destroy(trans); lstcon_group_move(tmp, grp); - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; } static int lstcon_group_nodes_remove(lstcon_group_t *grp, - int count, lnet_process_id_t __user *ids_up, + int count, struct lnet_process_id __user *ids_up, struct list_head __user *result_up) { lstcon_rpc_trans_t *trans; lstcon_ndlink_t *ndl; lstcon_group_t *tmp; - lnet_process_id_t id; + struct lnet_process_id id; int rc; int i; @@ -521,12 +507,12 @@ lstcon_group_nodes_remove(lstcon_group_t *grp, lstcon_rpc_trans_destroy(trans); /* release nodes anyway, because we can't rollback status */ - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; error: lstcon_group_move(tmp, grp); - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; } @@ -540,7 +526,7 @@ lstcon_group_add(char *name) rc = (lstcon_group_find(name, &grp) == 0)? -EEXIST: 0; if (rc != 0) { /* find a group with same name */ - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -556,7 +542,7 @@ lstcon_group_add(char *name) } int -lstcon_nodes_add(char *name, int count, lnet_process_id_t __user *ids_up, +lstcon_nodes_add(char *name, int count, struct lnet_process_id __user *ids_up, unsigned *featp, struct list_head __user *result_up) { lstcon_group_t *grp; @@ -574,14 +560,14 @@ lstcon_nodes_add(char *name, int count, lnet_process_id_t __user *ids_up, if (grp->grp_ref > 2) { /* referred by other threads or test */ CDEBUG(D_NET, "Group %s is busy\n", name); - lstcon_group_put(grp); + lstcon_group_decref(grp); return -EBUSY; } rc = lstcon_group_nodes_add(grp, count, ids_up, featp, result_up); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -602,7 +588,7 @@ lstcon_group_del(char *name) if (grp->grp_ref > 2) { /* referred by others threads or test */ CDEBUG(D_NET, "Group %s is busy\n", name); - lstcon_group_put(grp); + lstcon_group_decref(grp); return -EBUSY; } @@ -611,7 +597,7 @@ lstcon_group_del(char *name) grp, lstcon_sesrpc_condition, &trans); if (rc != 0) { CERROR("Can't create transaction: %d\n", rc); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -619,10 +605,10 @@ lstcon_group_del(char *name) lstcon_rpc_trans_destroy(trans); - lstcon_group_put(grp); + lstcon_group_decref(grp); /* -ref for session, it's destroyed, * status can't be rolled back, destroy group anway */ - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -642,7 +628,7 @@ lstcon_group_clean(char *name, int args) if (grp->grp_ref > 2) { /* referred by test */ CDEBUG(D_NET, "Group %s is busy\n", name); - lstcon_group_put(grp); + lstcon_group_decref(grp); return -EBUSY; } @@ -651,17 +637,17 @@ lstcon_group_clean(char *name, int args) lstcon_group_drain(grp, args); - lstcon_group_put(grp); + lstcon_group_decref(grp); /* release empty group */ if (list_empty(&grp->grp_ndl_list)) - lstcon_group_put(grp); + lstcon_group_decref(grp); return 0; } int lstcon_nodes_remove(char *name, int count, - lnet_process_id_t __user *ids_up, + struct lnet_process_id __user *ids_up, struct list_head __user *result_up) { lstcon_group_t *grp = NULL; @@ -676,16 +662,16 @@ lstcon_nodes_remove(char *name, int count, if (grp->grp_ref > 2) { /* referred by test */ CDEBUG(D_NET, "Group %s is busy\n", name); - lstcon_group_put(grp); + lstcon_group_decref(grp); return -EBUSY; } rc = lstcon_group_nodes_remove(grp, count, ids_up, result_up); - lstcon_group_put(grp); + lstcon_group_decref(grp); /* release empty group */ if (list_empty(&grp->grp_ndl_list)) - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -706,7 +692,7 @@ lstcon_group_refresh(char *name, struct list_head __user *result_up) if (grp->grp_ref > 2) { /* referred by test */ CDEBUG(D_NET, "Group %s is busy\n", name); - lstcon_group_put(grp); + lstcon_group_decref(grp); return -EBUSY; } @@ -717,7 +703,7 @@ lstcon_group_refresh(char *name, struct list_head __user *result_up) if (rc != 0) { /* local error, return */ CDEBUG(D_NET, "Can't create transaction: %d\n", rc); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -727,7 +713,7 @@ lstcon_group_refresh(char *name, struct list_head __user *result_up) lstcon_rpc_trans_destroy(trans); /* -ref for me */ - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } @@ -752,7 +738,7 @@ lstcon_group_list(int index, int len, char __user *name_up) static int lstcon_nodes_getent(struct list_head *head, int *index_p, - int *count_p, lstcon_node_ent_t __user *dents_up) + int *count_p, struct lstcon_node_ent __user *dents_up) { lstcon_ndlink_t *ndl; lstcon_node_t *nd; @@ -791,11 +777,11 @@ lstcon_nodes_getent(struct list_head *head, int *index_p, } int -lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gents_p, +lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gents_p, int *index_p, int *count_p, - lstcon_node_ent_t __user *dents_up) + struct lstcon_node_ent __user *dents_up) { - lstcon_ndlist_ent_t *gentp; + struct lstcon_ndlist_ent *gentp; lstcon_group_t *grp; lstcon_ndlink_t *ndl; int rc; @@ -806,35 +792,33 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gents_p, return rc; } - if (dents_up != 0) { + if (dents_up != NULL) { /* verbose query */ rc = lstcon_nodes_getent(&grp->grp_ndl_list, index_p, count_p, dents_up); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } /* non-verbose query */ - LIBCFS_ALLOC(gentp, sizeof(lstcon_ndlist_ent_t)); + LIBCFS_ALLOC(gentp, sizeof(struct lstcon_ndlist_ent)); if (gentp == NULL) { CERROR("Can't allocate ndlist_ent\n"); - lstcon_group_put(grp); + lstcon_group_decref(grp); return -ENOMEM; } - memset(gentp, 0, sizeof(lstcon_ndlist_ent_t)); - list_for_each_entry(ndl, &grp->grp_ndl_list, ndl_link) LST_NODE_STATE_COUNTER(ndl->ndl_node, gentp); rc = copy_to_user(gents_p, gentp, - sizeof(lstcon_ndlist_ent_t)) ? -EFAULT : 0; + sizeof(struct lstcon_ndlist_ent)) ? -EFAULT : 0; - LIBCFS_FREE(gentp, sizeof(lstcon_ndlist_ent_t)); + LIBCFS_FREE(gentp, sizeof(struct lstcon_ndlist_ent)); - lstcon_group_put(grp); + lstcon_group_decref(grp); return 0; } @@ -939,11 +923,11 @@ lstcon_batch_list(int index, int len, char __user *name_up) } int -lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, +lstcon_batch_info(char *name, struct lstcon_test_batch_ent __user *ent_up, int server, int testidx, int *index_p, int *ndent_p, - lstcon_node_ent_t __user *dents_up) + struct lstcon_node_ent __user *dents_up) { - lstcon_test_batch_ent_t *entp; + struct lstcon_test_batch_ent *entp; struct list_head *clilst; struct list_head *srvlst; lstcon_test_t *test = NULL; @@ -982,12 +966,10 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, } /* non-verbose query */ - LIBCFS_ALLOC(entp, sizeof(lstcon_test_batch_ent_t)); + LIBCFS_ALLOC(entp, sizeof(struct lstcon_test_batch_ent)); if (entp == NULL) return -ENOMEM; - memset(entp, 0, sizeof(lstcon_test_batch_ent_t)); - if (test == NULL) { entp->u.tbe_batch.bae_ntest = bat->bat_ntest; entp->u.tbe_batch.bae_state = bat->bat_state; @@ -1006,9 +988,9 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, LST_NODE_STATE_COUNTER(ndl->ndl_node, &entp->tbe_srv_nle); rc = copy_to_user(ent_up, entp, - sizeof(lstcon_test_batch_ent_t)) ? -EFAULT : 0; + sizeof(struct lstcon_test_batch_ent)) ? -EFAULT : 0; - LIBCFS_FREE(entp, sizeof(lstcon_test_batch_ent_t)); + LIBCFS_FREE(entp, sizeof(struct lstcon_test_batch_ent)); return rc; } @@ -1119,8 +1101,8 @@ lstcon_batch_destroy(lstcon_batch_t *bat) list_del(&test->tes_link); - lstcon_group_put(test->tes_src_grp); - lstcon_group_put(test->tes_dst_grp); + lstcon_group_decref(test->tes_src_grp); + lstcon_group_decref(test->tes_dst_grp); LIBCFS_FREE(test, offsetof(lstcon_test_t, tes_param[test->tes_paramlen])); @@ -1335,7 +1317,6 @@ lstcon_test_add(char *batch_name, int type, int loop, goto out; } - memset(test, 0, offsetof(lstcon_test_t, tes_param[paramlen])); test->tes_hdr.tsb_id = batch->bat_hdr.tsb_id; test->tes_batch = batch; test->tes_type = type; @@ -1378,10 +1359,10 @@ out: LIBCFS_FREE(test, offsetof(lstcon_test_t, tes_param[paramlen])); if (dst_grp != NULL) - lstcon_group_put(dst_grp); + lstcon_group_decref(dst_grp); if (src_grp != NULL) - lstcon_group_put(src_grp); + lstcon_group_decref(src_grp); return rc; } @@ -1403,7 +1384,7 @@ lstcon_test_find(lstcon_batch_t *batch, int idx, lstcon_test_t **testpp) static int lstcon_tsbrpc_readent(int transop, srpc_msg_t *msg, - lstcon_rpc_ent_t __user *ent_up) + struct lstcon_rpc_ent __user *ent_up) { srpc_batch_reply_t *rep = &msg->msg_body.bat_reply; @@ -1482,20 +1463,20 @@ lstcon_test_batch_query(char *name, int testidx, int client, static int lstcon_statrpc_readent(int transop, srpc_msg_t *msg, - lstcon_rpc_ent_t __user *ent_up) + struct lstcon_rpc_ent __user *ent_up) { srpc_stat_reply_t *rep = &msg->msg_body.stat_reply; - sfw_counters_t __user *sfwk_stat; - srpc_counters_t __user *srpc_stat; - lnet_counters_t __user *lnet_stat; + struct sfw_counters __user *sfwk_stat; + struct srpc_counters __user *srpc_stat; + struct lnet_counters __user *lnet_stat; if (rep->str_status != 0) return 0; - sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0]; - srpc_stat = (srpc_counters_t __user *) + sfwk_stat = (struct sfw_counters __user *)&ent_up->rpe_payload[0]; + srpc_stat = (struct srpc_counters __user *) ((char __user *)sfwk_stat + sizeof(*sfwk_stat)); - lnet_stat = (lnet_counters_t __user *) + lnet_stat = (struct lnet_counters __user *) ((char __user *)srpc_stat + sizeof(*srpc_stat)); if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) || @@ -1547,18 +1528,18 @@ lstcon_group_stat(char *grp_name, int timeout, rc = lstcon_ndlist_stat(&grp->grp_ndl_list, timeout, result_up); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } int -lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up, +lstcon_nodes_stat(int count, struct lnet_process_id __user *ids_up, int timeout, struct list_head __user *result_up) { lstcon_ndlink_t *ndl; lstcon_group_t *tmp; - lnet_process_id_t id; + struct lnet_process_id id; int i; int rc; @@ -1585,13 +1566,13 @@ lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up, } if (rc != 0) { - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; } rc = lstcon_ndlist_stat(&tmp->grp_ndl_list, timeout, result_up); - lstcon_group_put(tmp); + lstcon_group_decref(tmp); return rc; } @@ -1658,17 +1639,17 @@ lstcon_group_debug(int timeout, char *name, rc = lstcon_debug_ndlist(&grp->grp_ndl_list, NULL, timeout, result_up); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } int lstcon_nodes_debug(int timeout, - int count, lnet_process_id_t __user *ids_up, + int count, struct lnet_process_id __user *ids_up, struct list_head __user *result_up) { - lnet_process_id_t id; + struct lnet_process_id id; lstcon_ndlink_t *ndl; lstcon_group_t *grp; int i; @@ -1695,29 +1676,29 @@ lstcon_nodes_debug(int timeout, } if (rc != 0) { - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } rc = lstcon_debug_ndlist(&grp->grp_ndl_list, NULL, timeout, result_up); - lstcon_group_put(grp); + lstcon_group_decref(grp); return rc; } int -lstcon_session_match(lst_sid_t sid) +lstcon_session_match(struct lst_sid sid) { return (console_session.ses_id.ses_nid == sid.ses_nid && console_session.ses_id.ses_stamp == sid.ses_stamp) ? 1: 0; } static void -lstcon_new_session_id(lst_sid_t *sid) +lstcon_new_session_id(struct lst_sid *sid) { - lnet_process_id_t id; + struct lnet_process_id id; LASSERT (console_session.ses_state == LST_SESSION_NONE); @@ -1728,7 +1709,7 @@ lstcon_new_session_id(lst_sid_t *sid) int lstcon_session_new(char *name, int key, unsigned feats, - int timeout, int force, lst_sid_t __user *sid_up) + int timeout, int force, struct lst_sid __user *sid_up) { int rc = 0; int i; @@ -1787,7 +1768,7 @@ lstcon_session_new(char *name, int key, unsigned feats, } if (copy_to_user(sid_up, &console_session.ses_id, - sizeof(lst_sid_t)) == 0) + sizeof(struct lst_sid)) == 0) return rc; lstcon_session_end(); @@ -1796,12 +1777,12 @@ lstcon_session_new(char *name, int key, unsigned feats, } int -lstcon_session_info(lst_sid_t __user *sid_up, int __user *key_up, +lstcon_session_info(struct lst_sid __user *sid_up, int __user *key_up, unsigned __user *featp, - lstcon_ndlist_ent_t __user *ndinfo_up, + struct lstcon_ndlist_ent __user *ndinfo_up, char __user *name_up, int len) { - lstcon_ndlist_ent_t *entp; + struct lstcon_ndlist_ent *entp; lstcon_ndlink_t *ndl; int rc = 0; @@ -1812,13 +1793,11 @@ lstcon_session_info(lst_sid_t __user *sid_up, int __user *key_up, if (entp == NULL) return -ENOMEM; - memset(entp, 0, sizeof(*entp)); - list_for_each_entry(ndl, &console_session.ses_ndl_list, ndl_link) LST_NODE_STATE_COUNTER(ndl->ndl_node, entp); if (copy_to_user(sid_up, &console_session.ses_id, - sizeof(lst_sid_t)) || + sizeof(struct lst_sid)) || copy_to_user(key_up, &console_session.ses_key, sizeof(*key_up)) || copy_to_user(featp, &console_session.ses_features, @@ -1882,7 +1861,7 @@ lstcon_session_end() lstcon_group_t, grp_link); LASSERT(grp->grp_ref == 1); - lstcon_group_put(grp); + lstcon_group_decref(grp); } /* all nodes should be released */ @@ -2003,7 +1982,7 @@ lstcon_acceptor_handle (srpc_server_rpc_t *rpc) out: rep->msg_ses_feats = console_session.ses_features; if (grp != NULL) - lstcon_group_put(grp); + lstcon_group_decref(grp); mutex_unlock(&console_session.ses_mutex); @@ -2040,7 +2019,7 @@ lstcon_console_init(void) console_session.ses_expired = 0; console_session.ses_feats_updated = 0; console_session.ses_features = LST_FEATS_MASK; - console_session.ses_laststamp = cfs_time_current_sec(); + console_session.ses_laststamp = ktime_get_real_seconds(); mutex_init(&console_session.ses_mutex); @@ -2130,4 +2109,3 @@ lstcon_console_fini(void) return 0; } -#endif