X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Fselftest%2Fconsole.c;h=d2863b0a8ad2e46014ab7c75ffc5642e007e8c83;hb=d106dfc1458702865118e73bfcdfc2ec2676a7d6;hp=ee41bf3faefe38355924585cc046f5e58b19e007;hpb=0300a6efd226f138b3f6968f82b0a4313074a1a6;p=fs%2Flustre-release.git diff --git a/lnet/selftest/console.c b/lnet/selftest/console.c index ee41bf3..d2863b0 100644 --- a/lnet/selftest/console.c +++ b/lnet/selftest/console.c @@ -27,7 +27,6 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. * * lnet/selftest/conctl.c * @@ -315,15 +314,11 @@ lstcon_group_ndlink_move(struct lstcon_group *old, unsigned int idx = LNET_NIDADDR(ndl->ndl_node->nd_id.nid) % LST_NODE_HASHSIZE; - list_del(&ndl->ndl_hlink); - list_del(&ndl->ndl_link); old->grp_nnode--; - list_add_tail(&ndl->ndl_hlink, &new->grp_ndl_hash[idx]); - list_add_tail(&ndl->ndl_link, &new->grp_ndl_list); + list_move_tail(&ndl->ndl_hlink, &new->grp_ndl_hash[idx]); + list_move_tail(&ndl->ndl_link, &new->grp_ndl_list); new->grp_nnode++; - - return; } static void @@ -804,7 +799,7 @@ lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gents_p, } /* non-verbose query */ - LIBCFS_ALLOC(gentp, sizeof(struct lstcon_ndlist_ent)); + CFS_ALLOC_PTR(gentp); if (gentp == NULL) { CERROR("Can't allocate ndlist_ent\n"); lstcon_group_decref(grp); @@ -818,7 +813,7 @@ lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gents_p, rc = copy_to_user(gents_p, gentp, sizeof(struct lstcon_ndlist_ent)) ? -EFAULT : 0; - LIBCFS_FREE(gentp, sizeof(struct lstcon_ndlist_ent)); + CFS_FREE_PTR(gentp); lstcon_group_decref(grp); @@ -859,24 +854,22 @@ lstcon_batch_add(char *name) return -ENOMEM; } - LIBCFS_ALLOC(bat->bat_cli_hash, - sizeof(struct list_head) * LST_NODE_HASHSIZE); + CFS_ALLOC_PTR_ARRAY(bat->bat_cli_hash, LST_NODE_HASHSIZE); if (bat->bat_cli_hash == NULL) { CERROR("Can't allocate hash for batch %s\n", name); LIBCFS_FREE(bat, sizeof(*bat)); - return -ENOMEM; - } + return -ENOMEM; + } - LIBCFS_ALLOC(bat->bat_srv_hash, - sizeof(struct list_head) * LST_NODE_HASHSIZE); - if (bat->bat_srv_hash == NULL) { - CERROR("Can't allocate hash for batch %s\n", name); - LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE); + CFS_ALLOC_PTR_ARRAY(bat->bat_srv_hash, LST_NODE_HASHSIZE); + if (bat->bat_srv_hash == NULL) { + CERROR("Can't allocate hash for batch %s\n", name); + LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE); LIBCFS_FREE(bat, sizeof(*bat)); - return -ENOMEM; - } + return -ENOMEM; + } if (strlen(name) > sizeof(bat->bat_name)-1) { LIBCFS_FREE(bat->bat_srv_hash, LST_NODE_HASHSIZE); @@ -968,7 +961,7 @@ lstcon_batch_info(char *name, struct lstcon_test_batch_ent __user *ent_up, } /* non-verbose query */ - LIBCFS_ALLOC(entp, sizeof(struct lstcon_test_batch_ent)); + CFS_ALLOC_PTR(entp); if (entp == NULL) return -ENOMEM; @@ -992,7 +985,7 @@ lstcon_batch_info(char *name, struct lstcon_test_batch_ent __user *ent_up, rc = copy_to_user(ent_up, entp, sizeof(struct lstcon_test_batch_ent)) ? -EFAULT : 0; - LIBCFS_FREE(entp, sizeof(struct lstcon_test_batch_ent)); + CFS_FREE_PTR(entp) return rc; } @@ -1472,7 +1465,7 @@ lstcon_statrpc_readent(int transop, struct srpc_msg *msg, struct srpc_stat_reply *rep = &msg->msg_body.stat_reply; struct sfw_counters __user *sfwk_stat; struct srpc_counters __user *srpc_stat; - struct lnet_counters __user *lnet_stat; + struct lnet_counters_common __user *lnet_stat; if (rep->str_status != 0) return 0; @@ -1480,7 +1473,7 @@ lstcon_statrpc_readent(int transop, struct srpc_msg *msg, 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 = (struct lnet_counters __user *) + lnet_stat = (struct lnet_counters_common __user *) ((char __user *)srpc_stat + sizeof(*srpc_stat)); if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) || @@ -1495,11 +1488,9 @@ static int lstcon_ndlist_stat(struct list_head *ndlist, int timeout, struct list_head __user *result_up) { - struct list_head head; + LIST_HEAD(head); struct lstcon_rpc_trans *trans; - int rc; - - INIT_LIST_HEAD(&head); + int rc; rc = lstcon_rpc_trans_ndlist(ndlist, &head, LST_TRANS_STATQRY, NULL, NULL, &trans); @@ -1816,7 +1807,7 @@ lstcon_session_info(struct lst_sid __user *sid_up, int __user *key_up, } int -lstcon_session_end() +lstcon_session_end(void) { struct lstcon_rpc_trans *trans; struct lstcon_group *grp; @@ -2004,9 +1995,9 @@ static void lstcon_init_acceptor_service(void) lstcon_acceptor_service.sv_wi_total = SFW_FRWK_WI_MAX; } -int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr); - -DECLARE_IOCTL_HANDLER(lstcon_ioctl_handler, lstcon_ioctl_entry); +static struct notifier_block lstcon_ioctl_handler = { + .notifier_call = lstcon_ioctl_entry, +}; /* initialize console */ int @@ -2031,8 +2022,8 @@ lstcon_console_init(void) INIT_LIST_HEAD(&console_session.ses_bat_list); INIT_LIST_HEAD(&console_session.ses_trans_list); - LIBCFS_ALLOC(console_session.ses_ndl_hash, - sizeof(struct list_head) * LST_GLOBAL_HASHSIZE); + CFS_ALLOC_PTR_ARRAY(console_session.ses_ndl_hash, + LST_GLOBAL_HASHSIZE); if (console_session.ses_ndl_hash == NULL) return -ENOMEM; @@ -2046,8 +2037,8 @@ lstcon_console_init(void) rc = srpc_add_service(&lstcon_acceptor_service); LASSERT(rc != -EBUSY); if (rc != 0) { - LIBCFS_FREE(console_session.ses_ndl_hash, - sizeof(struct list_head) * LST_GLOBAL_HASHSIZE); + CFS_FREE_PTR_ARRAY(console_session.ses_ndl_hash, + LST_GLOBAL_HASHSIZE); return rc; } @@ -2058,19 +2049,18 @@ lstcon_console_init(void) goto out; } - rc = libcfs_register_ioctl(&lstcon_ioctl_handler); - - if (rc == 0) { - lstcon_rpc_module_init(); - return 0; - } + rc = blocking_notifier_chain_register(&libcfs_ioctl_list, + &lstcon_ioctl_handler); + if (rc == 0) { + lstcon_rpc_module_init(); + return 0; + } out: srpc_shutdown_service(&lstcon_acceptor_service); srpc_remove_service(&lstcon_acceptor_service); - LIBCFS_FREE(console_session.ses_ndl_hash, - sizeof(struct list_head) * LST_GLOBAL_HASHSIZE); + CFS_FREE_PTR_ARRAY(console_session.ses_ndl_hash, LST_GLOBAL_HASHSIZE); srpc_wait_service_shutdown(&lstcon_acceptor_service); @@ -2080,9 +2070,10 @@ out: int lstcon_console_fini(void) { - int i; + int i; - libcfs_deregister_ioctl(&lstcon_ioctl_handler); + blocking_notifier_chain_unregister(&libcfs_ioctl_list, + &lstcon_ioctl_handler); mutex_lock(&console_session.ses_mutex); @@ -2104,8 +2095,8 @@ lstcon_console_fini(void) for (i = 0; i < LST_NODE_HASHSIZE; i++) LASSERT(list_empty(&console_session.ses_ndl_hash[i])); - LIBCFS_FREE(console_session.ses_ndl_hash, - sizeof(struct list_head) * LST_GLOBAL_HASHSIZE); + CFS_FREE_PTR_ARRAY(console_session.ses_ndl_hash, + LST_GLOBAL_HASHSIZE); srpc_wait_service_shutdown(&lstcon_acceptor_service);