Commit 33be4600 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman

staging: lustre: more conversions to GFP_KERNEL allocations.

These are not called from filesystem context, so use
GFP_KERNEL, not LIBCFS_ALLOC().
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 464dbfca
...@@ -88,7 +88,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp, ...@@ -88,7 +88,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp,
if (!create) if (!create)
return -ENOENT; return -ENOENT;
LIBCFS_ALLOC(*ndpp, sizeof(**ndpp) + sizeof(*ndl)); *ndpp = kzalloc(sizeof(**ndpp) + sizeof(*ndl), GFP_KERNEL);
if (!*ndpp) if (!*ndpp)
return -ENOMEM; return -ENOMEM;
...@@ -133,7 +133,7 @@ lstcon_node_put(struct lstcon_node *nd) ...@@ -133,7 +133,7 @@ lstcon_node_put(struct lstcon_node *nd)
list_del(&ndl->ndl_link); list_del(&ndl->ndl_link);
list_del(&ndl->ndl_hlink); list_del(&ndl->ndl_hlink);
LIBCFS_FREE(nd, sizeof(*nd) + sizeof(*ndl)); kfree(nd);
} }
static int static int
...@@ -199,16 +199,16 @@ lstcon_group_alloc(char *name, struct lstcon_group **grpp) ...@@ -199,16 +199,16 @@ lstcon_group_alloc(char *name, struct lstcon_group **grpp)
struct lstcon_group *grp; struct lstcon_group *grp;
int i; int i;
LIBCFS_ALLOC(grp, offsetof(struct lstcon_group, grp = kmalloc(offsetof(struct lstcon_group,
grp_ndl_hash[LST_NODE_HASHSIZE])); grp_ndl_hash[LST_NODE_HASHSIZE]),
GFP_KERNEL);
if (!grp) if (!grp)
return -ENOMEM; return -ENOMEM;
grp->grp_ref = 1; grp->grp_ref = 1;
if (name) { if (name) {
if (strlen(name) > sizeof(grp->grp_name) - 1) { if (strlen(name) > sizeof(grp->grp_name) - 1) {
LIBCFS_FREE(grp, offsetof(struct lstcon_group, kfree(grp);
grp_ndl_hash[LST_NODE_HASHSIZE]));
return -E2BIG; return -E2BIG;
} }
strncpy(grp->grp_name, name, sizeof(grp->grp_name)); strncpy(grp->grp_name, name, sizeof(grp->grp_name));
...@@ -263,8 +263,7 @@ lstcon_group_decref(struct lstcon_group *grp) ...@@ -263,8 +263,7 @@ lstcon_group_decref(struct lstcon_group *grp)
for (i = 0; i < LST_NODE_HASHSIZE; i++) for (i = 0; i < LST_NODE_HASHSIZE; i++)
LASSERT(list_empty(&grp->grp_ndl_hash[i])); LASSERT(list_empty(&grp->grp_ndl_hash[i]));
LIBCFS_FREE(grp, offsetof(struct lstcon_group, kfree(grp);
grp_ndl_hash[LST_NODE_HASHSIZE]));
} }
static int static int
...@@ -862,8 +861,8 @@ lstcon_batch_add(char *name) ...@@ -862,8 +861,8 @@ lstcon_batch_add(char *name)
return -ENOMEM; return -ENOMEM;
} }
LIBCFS_ALLOC(bat->bat_cli_hash, bat->bat_cli_hash = kmalloc(sizeof(struct list_head) * LST_NODE_HASHSIZE,
sizeof(struct list_head) * LST_NODE_HASHSIZE); GFP_KERNEL);
if (!bat->bat_cli_hash) { if (!bat->bat_cli_hash) {
CERROR("Can't allocate hash for batch %s\n", name); CERROR("Can't allocate hash for batch %s\n", name);
kfree(bat); kfree(bat);
...@@ -871,19 +870,19 @@ lstcon_batch_add(char *name) ...@@ -871,19 +870,19 @@ lstcon_batch_add(char *name)
return -ENOMEM; return -ENOMEM;
} }
LIBCFS_ALLOC(bat->bat_srv_hash, bat->bat_srv_hash = kmalloc(sizeof(struct list_head) * LST_NODE_HASHSIZE,
sizeof(struct list_head) * LST_NODE_HASHSIZE); GFP_KERNEL);
if (!bat->bat_srv_hash) { if (!bat->bat_srv_hash) {
CERROR("Can't allocate hash for batch %s\n", name); CERROR("Can't allocate hash for batch %s\n", name);
LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE); kfree(bat->bat_cli_hash);
kfree(bat); kfree(bat);
return -ENOMEM; return -ENOMEM;
} }
if (strlen(name) > sizeof(bat->bat_name) - 1) { if (strlen(name) > sizeof(bat->bat_name) - 1) {
LIBCFS_FREE(bat->bat_srv_hash, LST_NODE_HASHSIZE); kfree(bat->bat_srv_hash);
LIBCFS_FREE(bat->bat_cli_hash, LST_NODE_HASHSIZE); kfree(bat->bat_cli_hash);
kfree(bat); kfree(bat);
return -E2BIG; return -E2BIG;
} }
...@@ -1107,8 +1106,7 @@ lstcon_batch_destroy(struct lstcon_batch *bat) ...@@ -1107,8 +1106,7 @@ lstcon_batch_destroy(struct lstcon_batch *bat)
lstcon_group_decref(test->tes_src_grp); lstcon_group_decref(test->tes_src_grp);
lstcon_group_decref(test->tes_dst_grp); lstcon_group_decref(test->tes_dst_grp);
LIBCFS_FREE(test, offsetof(struct lstcon_test, kfree(test);
tes_param[test->tes_paramlen]));
} }
LASSERT(list_empty(&bat->bat_trans_list)); LASSERT(list_empty(&bat->bat_trans_list));
...@@ -1134,10 +1132,8 @@ lstcon_batch_destroy(struct lstcon_batch *bat) ...@@ -1134,10 +1132,8 @@ lstcon_batch_destroy(struct lstcon_batch *bat)
LASSERT(list_empty(&bat->bat_srv_hash[i])); LASSERT(list_empty(&bat->bat_srv_hash[i]));
} }
LIBCFS_FREE(bat->bat_cli_hash, kfree(bat->bat_cli_hash);
sizeof(struct list_head) * LST_NODE_HASHSIZE); kfree(bat->bat_srv_hash);
LIBCFS_FREE(bat->bat_srv_hash,
sizeof(struct list_head) * LST_NODE_HASHSIZE);
kfree(bat); kfree(bat);
} }
...@@ -1311,7 +1307,8 @@ lstcon_test_add(char *batch_name, int type, int loop, ...@@ -1311,7 +1307,8 @@ lstcon_test_add(char *batch_name, int type, int loop,
if (dst_grp->grp_userland) if (dst_grp->grp_userland)
*retp = 1; *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) { if (!test) {
CERROR("Can't allocate test descriptor\n"); CERROR("Can't allocate test descriptor\n");
rc = -ENOMEM; rc = -ENOMEM;
...@@ -1357,8 +1354,7 @@ lstcon_test_add(char *batch_name, int type, int loop, ...@@ -1357,8 +1354,7 @@ lstcon_test_add(char *batch_name, int type, int loop,
/* hold groups so nobody can change them */ /* hold groups so nobody can change them */
return rc; return rc;
out: out:
if (test) kfree(test);
LIBCFS_FREE(test, offsetof(struct lstcon_test, tes_param[paramlen]));
if (dst_grp) if (dst_grp)
lstcon_group_decref(dst_grp); lstcon_group_decref(dst_grp);
...@@ -2027,8 +2023,8 @@ lstcon_console_init(void) ...@@ -2027,8 +2023,8 @@ lstcon_console_init(void)
INIT_LIST_HEAD(&console_session.ses_bat_list); INIT_LIST_HEAD(&console_session.ses_bat_list);
INIT_LIST_HEAD(&console_session.ses_trans_list); INIT_LIST_HEAD(&console_session.ses_trans_list);
LIBCFS_ALLOC(console_session.ses_ndl_hash, console_session.ses_ndl_hash =
sizeof(struct list_head) * LST_GLOBAL_HASHSIZE); kmalloc(sizeof(struct list_head) * LST_GLOBAL_HASHSIZE, GFP_KERNEL);
if (!console_session.ses_ndl_hash) if (!console_session.ses_ndl_hash)
return -ENOMEM; return -ENOMEM;
...@@ -2041,8 +2037,7 @@ lstcon_console_init(void) ...@@ -2041,8 +2037,7 @@ lstcon_console_init(void)
rc = srpc_add_service(&lstcon_acceptor_service); rc = srpc_add_service(&lstcon_acceptor_service);
LASSERT(rc != -EBUSY); LASSERT(rc != -EBUSY);
if (rc) { if (rc) {
LIBCFS_FREE(console_session.ses_ndl_hash, kfree(console_session.ses_ndl_hash);
sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
return rc; return rc;
} }
...@@ -2064,8 +2059,7 @@ lstcon_console_init(void) ...@@ -2064,8 +2059,7 @@ lstcon_console_init(void)
srpc_shutdown_service(&lstcon_acceptor_service); srpc_shutdown_service(&lstcon_acceptor_service);
srpc_remove_service(&lstcon_acceptor_service); srpc_remove_service(&lstcon_acceptor_service);
LIBCFS_FREE(console_session.ses_ndl_hash, kfree(console_session.ses_ndl_hash);
sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
srpc_wait_service_shutdown(&lstcon_acceptor_service); srpc_wait_service_shutdown(&lstcon_acceptor_service);
...@@ -2099,8 +2093,7 @@ lstcon_console_fini(void) ...@@ -2099,8 +2093,7 @@ lstcon_console_fini(void)
for (i = 0; i < LST_NODE_HASHSIZE; i++) for (i = 0; i < LST_NODE_HASHSIZE; i++)
LASSERT(list_empty(&console_session.ses_ndl_hash[i])); LASSERT(list_empty(&console_session.ses_ndl_hash[i]));
LIBCFS_FREE(console_session.ses_ndl_hash, kfree(console_session.ses_ndl_hash);
sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
srpc_wait_service_shutdown(&lstcon_acceptor_service); srpc_wait_service_shutdown(&lstcon_acceptor_service);
......
...@@ -639,7 +639,7 @@ sfw_destroy_test_instance(struct sfw_test_instance *tsi) ...@@ -639,7 +639,7 @@ sfw_destroy_test_instance(struct sfw_test_instance *tsi)
rpc = list_entry(tsi->tsi_free_rpcs.next, rpc = list_entry(tsi->tsi_free_rpcs.next,
struct srpc_client_rpc, crpc_list); struct srpc_client_rpc, crpc_list);
list_del(&rpc->crpc_list); list_del(&rpc->crpc_list);
LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); kfree(rpc);
} }
clean: clean:
...@@ -1767,7 +1767,7 @@ sfw_shutdown(void) ...@@ -1767,7 +1767,7 @@ sfw_shutdown(void)
struct srpc_client_rpc, crpc_list); struct srpc_client_rpc, crpc_list);
list_del(&rpc->crpc_list); list_del(&rpc->crpc_list);
LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); kfree(rpc);
} }
for (i = 0; ; i++) { for (i = 0; ; i++) {
......
...@@ -72,9 +72,7 @@ lnet_selftest_exit(void) ...@@ -72,9 +72,7 @@ lnet_selftest_exit(void)
continue; continue;
cfs_wi_sched_destroy(lst_sched_test[i]); cfs_wi_sched_destroy(lst_sched_test[i]);
} }
LIBCFS_FREE(lst_sched_test, kvfree(lst_sched_test);
sizeof(lst_sched_test[0]) *
cfs_cpt_number(lnet_cpt_table()));
lst_sched_test = NULL; lst_sched_test = NULL;
/* fall through */ /* fall through */
case LST_INIT_WI_SERIAL: case LST_INIT_WI_SERIAL:
...@@ -103,7 +101,8 @@ lnet_selftest_init(void) ...@@ -103,7 +101,8 @@ lnet_selftest_init(void)
lst_init_step = LST_INIT_WI_SERIAL; lst_init_step = LST_INIT_WI_SERIAL;
nscheds = cfs_cpt_number(lnet_cpt_table()); nscheds = cfs_cpt_number(lnet_cpt_table());
LIBCFS_ALLOC(lst_sched_test, sizeof(lst_sched_test[0]) * nscheds); lst_sched_test = kvmalloc_array(nscheds, sizeof(lst_sched_test[0]),
GFP_KERNEL | __GFP_ZERO);
if (!lst_sched_test) if (!lst_sched_test)
goto error; goto error;
......
...@@ -1322,8 +1322,8 @@ srpc_create_client_rpc(struct lnet_process_id peer, int service, ...@@ -1322,8 +1322,8 @@ srpc_create_client_rpc(struct lnet_process_id peer, int service,
{ {
struct srpc_client_rpc *rpc; struct srpc_client_rpc *rpc;
LIBCFS_ALLOC(rpc, offsetof(struct srpc_client_rpc, rpc = kzalloc(offsetof(struct srpc_client_rpc,
crpc_bulk.bk_iovs[nbulkiov])); crpc_bulk.bk_iovs[nbulkiov]), GFP_KERNEL);
if (!rpc) if (!rpc)
return NULL; return NULL;
......
...@@ -516,7 +516,7 @@ srpc_destroy_client_rpc(struct srpc_client_rpc *rpc) ...@@ -516,7 +516,7 @@ srpc_destroy_client_rpc(struct srpc_client_rpc *rpc)
LASSERT(!atomic_read(&rpc->crpc_refcount)); LASSERT(!atomic_read(&rpc->crpc_refcount));
if (!rpc->crpc_fini) if (!rpc->crpc_fini)
LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc)); kfree(rpc);
else else
(*rpc->crpc_fini)(rpc); (*rpc->crpc_fini)(rpc);
} }
......
...@@ -1137,7 +1137,8 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, ...@@ -1137,7 +1137,8 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num,
num_entry = num_possible_cpus(); num_entry = num_possible_cpus();
/* alloc percpu pointers for all possible cpu slots */ /* alloc percpu pointers for all possible cpu slots */
LIBCFS_ALLOC(stats, offsetof(typeof(*stats), ls_percpu[num_entry])); stats = kvzalloc(offsetof(typeof(*stats), ls_percpu[num_entry]),
GFP_KERNEL);
if (!stats) if (!stats)
return NULL; return NULL;
...@@ -1146,8 +1147,9 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num, ...@@ -1146,8 +1147,9 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num,
spin_lock_init(&stats->ls_lock); spin_lock_init(&stats->ls_lock);
/* alloc num of counter headers */ /* alloc num of counter headers */
LIBCFS_ALLOC(stats->ls_cnt_header, stats->ls_cnt_header = kvmalloc_array(stats->ls_num,
stats->ls_num * sizeof(struct lprocfs_counter_header)); sizeof(struct lprocfs_counter_header),
GFP_KERNEL | __GFP_ZERO);
if (!stats->ls_cnt_header) if (!stats->ls_cnt_header)
goto fail; goto fail;
...@@ -1193,10 +1195,8 @@ void lprocfs_free_stats(struct lprocfs_stats **statsh) ...@@ -1193,10 +1195,8 @@ void lprocfs_free_stats(struct lprocfs_stats **statsh)
for (i = 0; i < num_entry; i++) for (i = 0; i < num_entry; i++)
if (stats->ls_percpu[i]) if (stats->ls_percpu[i])
LIBCFS_FREE(stats->ls_percpu[i], percpusize); LIBCFS_FREE(stats->ls_percpu[i], percpusize);
if (stats->ls_cnt_header) kvfree(stats->ls_cnt_header);
LIBCFS_FREE(stats->ls_cnt_header, stats->ls_num * kvfree(stats);
sizeof(struct lprocfs_counter_header));
LIBCFS_FREE(stats, offsetof(typeof(*stats), ls_percpu[num_entry]));
} }
EXPORT_SYMBOL(lprocfs_free_stats); EXPORT_SYMBOL(lprocfs_free_stats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment