diff options
Diffstat (limited to 'drivers/staging/lustre/lnet/selftest/console.c')
-rw-r--r-- | drivers/staging/lustre/lnet/selftest/console.c | 83 |
1 files changed, 38 insertions, 45 deletions
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index a2662638d599..1acd5cb324b1 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -88,7 +88,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp, if (!create) return -ENOENT; - LIBCFS_ALLOC(*ndpp, sizeof(**ndpp) + sizeof(*ndl)); + *ndpp = kzalloc(sizeof(**ndpp) + sizeof(*ndl), GFP_KERNEL); if (!*ndpp) return -ENOMEM; @@ -133,7 +133,7 @@ lstcon_node_put(struct lstcon_node *nd) list_del(&ndl->ndl_link); list_del(&ndl->ndl_hlink); - LIBCFS_FREE(nd, sizeof(*nd) + sizeof(*ndl)); + kfree(nd); } static int @@ -166,7 +166,7 @@ lstcon_ndlink_find(struct list_head *hash, struct lnet_process_id id, if (rc) return rc; - LIBCFS_ALLOC(ndl, sizeof(struct lstcon_ndlink)); + ndl = kzalloc(sizeof(struct lstcon_ndlink), GFP_NOFS); if (!ndl) { lstcon_node_put(nd); return -ENOMEM; @@ -190,7 +190,7 @@ lstcon_ndlink_release(struct lstcon_ndlink *ndl) list_del(&ndl->ndl_hlink); /* delete from hash */ lstcon_node_put(ndl->ndl_node); - LIBCFS_FREE(ndl, sizeof(*ndl)); + kfree(ndl); } static int @@ -199,16 +199,16 @@ lstcon_group_alloc(char *name, struct lstcon_group **grpp) struct lstcon_group *grp; int i; - LIBCFS_ALLOC(grp, offsetof(struct lstcon_group, - grp_ndl_hash[LST_NODE_HASHSIZE])); + grp = kmalloc(offsetof(struct lstcon_group, + grp_ndl_hash[LST_NODE_HASHSIZE]), + GFP_KERNEL); if (!grp) return -ENOMEM; grp->grp_ref = 1; if (name) { if (strlen(name) > sizeof(grp->grp_name) - 1) { - LIBCFS_FREE(grp, offsetof(struct lstcon_group, - grp_ndl_hash[LST_NODE_HASHSIZE])); + kfree(grp); return -E2BIG; } strncpy(grp->grp_name, name, sizeof(grp->grp_name)); @@ -263,8 +263,7 @@ lstcon_group_decref(struct lstcon_group *grp) for (i = 0; i < LST_NODE_HASHSIZE; i++) LASSERT(list_empty(&grp->grp_ndl_hash[i])); - LIBCFS_FREE(grp, offsetof(struct lstcon_group, - grp_ndl_hash[LST_NODE_HASHSIZE])); + kfree(grp); } static int @@ -807,7 +806,7 @@ lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gents_p, } /* non-verbose query */ - LIBCFS_ALLOC(gentp, sizeof(struct lstcon_ndlist_ent)); + gentp = kzalloc(sizeof(struct lstcon_ndlist_ent), GFP_NOFS); if (!gentp) { CERROR("Can't allocate ndlist_ent\n"); lstcon_group_decref(grp); @@ -821,7 +820,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)); + kfree(gentp); lstcon_group_decref(grp); @@ -856,35 +855,35 @@ lstcon_batch_add(char *name) return rc; } - LIBCFS_ALLOC(bat, sizeof(struct lstcon_batch)); + bat = kzalloc(sizeof(struct lstcon_batch), GFP_NOFS); if (!bat) { CERROR("Can't allocate descriptor for batch %s\n", name); return -ENOMEM; } - LIBCFS_ALLOC(bat->bat_cli_hash, - sizeof(struct list_head) * LST_NODE_HASHSIZE); + bat->bat_cli_hash = kmalloc(sizeof(struct list_head) * LST_NODE_HASHSIZE, + GFP_KERNEL); if (!bat->bat_cli_hash) { CERROR("Can't allocate hash for batch %s\n", name); - LIBCFS_FREE(bat, sizeof(struct lstcon_batch)); + kfree(bat); return -ENOMEM; } - LIBCFS_ALLOC(bat->bat_srv_hash, - sizeof(struct list_head) * LST_NODE_HASHSIZE); + bat->bat_srv_hash = kmalloc(sizeof(struct list_head) * LST_NODE_HASHSIZE, + GFP_KERNEL); if (!bat->bat_srv_hash) { CERROR("Can't allocate hash for batch %s\n", name); - LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE); - LIBCFS_FREE(bat, sizeof(struct lstcon_batch)); + kfree(bat->bat_cli_hash); + kfree(bat); return -ENOMEM; } if (strlen(name) > sizeof(bat->bat_name) - 1) { - LIBCFS_FREE(bat->bat_srv_hash, LST_NODE_HASHSIZE); - LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE); - LIBCFS_FREE(bat, sizeof(struct lstcon_batch)); + kfree(bat->bat_srv_hash); + kfree(bat->bat_cli_hash); + kfree(bat); return -E2BIG; } strncpy(bat->bat_name, name, sizeof(bat->bat_name)); @@ -971,7 +970,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)); + entp = kzalloc(sizeof(struct lstcon_test_batch_ent), GFP_NOFS); if (!entp) return -ENOMEM; @@ -993,7 +992,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)); + kfree(entp); return rc; } @@ -1107,8 +1106,7 @@ lstcon_batch_destroy(struct lstcon_batch *bat) lstcon_group_decref(test->tes_src_grp); lstcon_group_decref(test->tes_dst_grp); - LIBCFS_FREE(test, offsetof(struct lstcon_test, - tes_param[test->tes_paramlen])); + kfree(test); } LASSERT(list_empty(&bat->bat_trans_list)); @@ -1134,11 +1132,9 @@ lstcon_batch_destroy(struct lstcon_batch *bat) LASSERT(list_empty(&bat->bat_srv_hash[i])); } - LIBCFS_FREE(bat->bat_cli_hash, - sizeof(struct list_head) * LST_NODE_HASHSIZE); - LIBCFS_FREE(bat->bat_srv_hash, - sizeof(struct list_head) * LST_NODE_HASHSIZE); - LIBCFS_FREE(bat, sizeof(struct lstcon_batch)); + kfree(bat->bat_cli_hash); + kfree(bat->bat_srv_hash); + kfree(bat); } static int @@ -1311,7 +1307,8 @@ lstcon_test_add(char *batch_name, int type, int loop, if (dst_grp->grp_userland) *retp = 1; - LIBCFS_ALLOC(test, offsetof(struct lstcon_test, tes_param[paramlen])); + test = kzalloc(offsetof(struct lstcon_test, tes_param[paramlen]), + GFP_KERNEL); if (!test) { CERROR("Can't allocate test descriptor\n"); rc = -ENOMEM; @@ -1357,8 +1354,7 @@ lstcon_test_add(char *batch_name, int type, int loop, /* hold groups so nobody can change them */ return rc; out: - if (test) - LIBCFS_FREE(test, offsetof(struct lstcon_test, tes_param[paramlen])); + kfree(test); if (dst_grp) lstcon_group_decref(dst_grp); @@ -1790,7 +1786,7 @@ lstcon_session_info(struct lst_sid __user *sid_up, int __user *key_up, if (console_session.ses_state != LST_SESSION_ACTIVE) return -ESRCH; - LIBCFS_ALLOC(entp, sizeof(*entp)); + entp = kzalloc(sizeof(*entp), GFP_NOFS); if (!entp) return -ENOMEM; @@ -1807,7 +1803,7 @@ lstcon_session_info(struct lst_sid __user *sid_up, int __user *key_up, copy_to_user(name_up, console_session.ses_name, len)) rc = -EFAULT; - LIBCFS_FREE(entp, sizeof(*entp)); + kfree(entp); return rc; } @@ -2027,8 +2023,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); + console_session.ses_ndl_hash = + kmalloc(sizeof(struct list_head) * LST_GLOBAL_HASHSIZE, GFP_KERNEL); if (!console_session.ses_ndl_hash) return -ENOMEM; @@ -2041,8 +2037,7 @@ lstcon_console_init(void) rc = srpc_add_service(&lstcon_acceptor_service); LASSERT(rc != -EBUSY); if (rc) { - LIBCFS_FREE(console_session.ses_ndl_hash, - sizeof(struct list_head) * LST_GLOBAL_HASHSIZE); + kfree(console_session.ses_ndl_hash); return rc; } @@ -2064,8 +2059,7 @@ 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); + kfree(console_session.ses_ndl_hash); srpc_wait_service_shutdown(&lstcon_acceptor_service); @@ -2099,8 +2093,7 @@ 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); + kfree(console_session.ses_ndl_hash); srpc_wait_service_shutdown(&lstcon_acceptor_service); |