Commit 9ae10597 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: ptlrpc: Use kzalloc and kfree

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// </smpl>
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7795178d
...@@ -103,7 +103,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw, ...@@ -103,7 +103,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
struct ptlrpc_bulk_desc *desc; struct ptlrpc_bulk_desc *desc;
int i; int i;
OBD_ALLOC(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[npages])); desc = kzalloc(offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]),
GFP_NOFS);
if (!desc) if (!desc)
return NULL; return NULL;
...@@ -205,8 +206,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) ...@@ -205,8 +206,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin)
page_cache_release(desc->bd_iov[i].kiov_page); page_cache_release(desc->bd_iov[i].kiov_page);
} }
OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc, kfree(desc);
bd_iov[desc->bd_max_iov]));
} }
EXPORT_SYMBOL(__ptlrpc_free_bulk); EXPORT_SYMBOL(__ptlrpc_free_bulk);
...@@ -439,7 +439,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) ...@@ -439,7 +439,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
ptlrpc_request_cache_free(req); ptlrpc_request_cache_free(req);
} }
spin_unlock(&pool->prp_lock); spin_unlock(&pool->prp_lock);
OBD_FREE(pool, sizeof(*pool)); kfree(pool);
} }
EXPORT_SYMBOL(ptlrpc_free_rq_pool); EXPORT_SYMBOL(ptlrpc_free_rq_pool);
...@@ -498,7 +498,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, ...@@ -498,7 +498,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize,
{ {
struct ptlrpc_request_pool *pool; struct ptlrpc_request_pool *pool;
OBD_ALLOC(pool, sizeof(struct ptlrpc_request_pool)); pool = kzalloc(sizeof(struct ptlrpc_request_pool), GFP_NOFS);
if (!pool) if (!pool)
return NULL; return NULL;
...@@ -514,7 +514,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, ...@@ -514,7 +514,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize,
if (list_empty(&pool->prp_req_list)) { if (list_empty(&pool->prp_req_list)) {
/* have not allocated a single request for the pool */ /* have not allocated a single request for the pool */
OBD_FREE(pool, sizeof(struct ptlrpc_request_pool)); kfree(pool);
pool = NULL; pool = NULL;
} }
return pool; return pool;
...@@ -856,7 +856,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) ...@@ -856,7 +856,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void)
{ {
struct ptlrpc_request_set *set; struct ptlrpc_request_set *set;
OBD_ALLOC(set, sizeof(*set)); set = kzalloc(sizeof(*set), GFP_NOFS);
if (!set) if (!set)
return NULL; return NULL;
atomic_set(&set->set_refcount, 1); atomic_set(&set->set_refcount, 1);
...@@ -970,7 +970,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set, ...@@ -970,7 +970,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
{ {
struct ptlrpc_set_cbdata *cbdata; struct ptlrpc_set_cbdata *cbdata;
OBD_ALLOC_PTR(cbdata); cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS);
if (cbdata == NULL) if (cbdata == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -2214,7 +2214,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) ...@@ -2214,7 +2214,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
err = cbdata->psc_interpret(set, cbdata->psc_data, rc); err = cbdata->psc_interpret(set, cbdata->psc_data, rc);
if (err && !rc) if (err && !rc)
rc = err; rc = err;
OBD_FREE_PTR(cbdata); kfree(cbdata);
} }
} }
......
...@@ -54,7 +54,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, ...@@ -54,7 +54,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
if (conn) if (conn)
goto out; goto out;
OBD_ALLOC_PTR(conn); conn = kzalloc(sizeof(*conn), GFP_NOFS);
if (!conn) if (!conn)
return NULL; return NULL;
...@@ -76,7 +76,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, ...@@ -76,7 +76,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
/* coverity[overrun-buffer-val] */ /* coverity[overrun-buffer-val] */
conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash); conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
if (conn != conn2) { if (conn != conn2) {
OBD_FREE_PTR(conn); kfree(conn);
conn = conn2; conn = conn2;
} }
out: out:
...@@ -227,7 +227,7 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode) ...@@ -227,7 +227,7 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode)
LASSERTF(atomic_read(&conn->c_refcount) == 0, LASSERTF(atomic_read(&conn->c_refcount) == 0,
"Busy connection with %d refs\n", "Busy connection with %d refs\n",
atomic_read(&conn->c_refcount)); atomic_read(&conn->c_refcount));
OBD_FREE_PTR(conn); kfree(conn);
} }
static cfs_hash_ops_t conn_hash_ops = { static cfs_hash_ops_t conn_hash_ops = {
......
...@@ -507,7 +507,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) ...@@ -507,7 +507,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n)
num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols; num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols;
spin_unlock(&nrs->nrs_lock); spin_unlock(&nrs->nrs_lock);
OBD_ALLOC(infos, num_pols * sizeof(*infos)); infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS);
if (infos == NULL) { if (infos == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -619,7 +619,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) ...@@ -619,7 +619,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n)
out: out:
if (infos) if (infos)
OBD_FREE(infos, num_pols * sizeof(*infos)); kfree(infos);
mutex_unlock(&nrs_core.nrs_mutex); mutex_unlock(&nrs_core.nrs_mutex);
...@@ -655,7 +655,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, ...@@ -655,7 +655,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
goto out; goto out;
} }
OBD_ALLOC(cmd, LPROCFS_NRS_WR_MAX_CMD); cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
if (cmd == NULL) { if (cmd == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -717,7 +717,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, ...@@ -717,7 +717,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
mutex_unlock(&nrs_core.nrs_mutex); mutex_unlock(&nrs_core.nrs_mutex);
out: out:
if (cmd_copy) if (cmd_copy)
OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD); kfree(cmd_copy);
return rc < 0 ? rc : count; return rc < 0 ? rc : count;
} }
...@@ -825,7 +825,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) ...@@ -825,7 +825,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
return NULL; return NULL;
} }
OBD_ALLOC(srhi, sizeof(*srhi)); srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
if (srhi == NULL) if (srhi == NULL)
return NULL; return NULL;
...@@ -851,7 +851,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) ...@@ -851,7 +851,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
} }
} }
OBD_FREE(srhi, sizeof(*srhi)); kfree(srhi);
return NULL; return NULL;
} }
...@@ -861,7 +861,7 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter) ...@@ -861,7 +861,7 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter)
struct ptlrpc_srh_iterator *srhi = iter; struct ptlrpc_srh_iterator *srhi = iter;
if (srhi != NULL) if (srhi != NULL)
OBD_FREE(srhi, sizeof(*srhi)); kfree(srhi);
} }
static void * static void *
...@@ -895,7 +895,7 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, ...@@ -895,7 +895,7 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
} }
} }
OBD_FREE(srhi, sizeof(*srhi)); kfree(srhi);
return NULL; return NULL;
} }
...@@ -1191,7 +1191,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, ...@@ -1191,7 +1191,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
char *kbuf; char *kbuf;
char *tmpbuf; char *tmpbuf;
OBD_ALLOC(kbuf, BUFLEN); kbuf = kzalloc(BUFLEN, GFP_NOFS);
if (kbuf == NULL) if (kbuf == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1225,7 +1225,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, ...@@ -1225,7 +1225,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
class_decref(obd, __func__, current); class_decref(obd, __func__, current);
out: out:
OBD_FREE(kbuf, BUFLEN); kfree(kbuf);
return count; return count;
} }
EXPORT_SYMBOL(lprocfs_wr_evict_client); EXPORT_SYMBOL(lprocfs_wr_evict_client);
...@@ -1275,7 +1275,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, ...@@ -1275,7 +1275,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len) if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len)
return -EINVAL; return -EINVAL;
OBD_ALLOC(kbuf, count + 1); kbuf = kzalloc(count + 1, GFP_NOFS);
if (kbuf == NULL) if (kbuf == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1319,7 +1319,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer, ...@@ -1319,7 +1319,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
ptlrpc_recover_import(imp, uuid, 1); ptlrpc_recover_import(imp, uuid, 1);
out: out:
OBD_FREE(kbuf, count + 1); kfree(kbuf);
return count; return count;
} }
EXPORT_SYMBOL(lprocfs_wr_import); EXPORT_SYMBOL(lprocfs_wr_import);
......
...@@ -715,7 +715,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) ...@@ -715,7 +715,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name)
nrs_policy_fini(policy); nrs_policy_fini(policy);
LASSERT(policy->pol_private == NULL); LASSERT(policy->pol_private == NULL);
OBD_FREE_PTR(policy); kfree(policy);
return 0; return 0;
} }
...@@ -761,7 +761,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, ...@@ -761,7 +761,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
rc = nrs_policy_init(policy); rc = nrs_policy_init(policy);
if (rc != 0) { if (rc != 0) {
OBD_FREE_PTR(policy); kfree(policy);
return rc; return rc;
} }
...@@ -776,7 +776,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, ...@@ -776,7 +776,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
spin_unlock(&nrs->nrs_lock); spin_unlock(&nrs->nrs_lock);
nrs_policy_fini(policy); nrs_policy_fini(policy);
OBD_FREE_PTR(policy); kfree(policy);
return -EEXIST; return -EEXIST;
} }
...@@ -1013,7 +1013,7 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) ...@@ -1013,7 +1013,7 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt)
} }
if (hp) if (hp)
OBD_FREE_PTR(nrs); kfree(nrs);
} }
/** /**
...@@ -1153,7 +1153,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) ...@@ -1153,7 +1153,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
goto fail; goto fail;
} }
OBD_ALLOC_PTR(desc); desc = kzalloc(sizeof(*desc), GFP_NOFS);
if (desc == NULL) { if (desc == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto fail; goto fail;
...@@ -1210,7 +1210,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) ...@@ -1210,7 +1210,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
*/ */
LASSERT(rc2 == 0); LASSERT(rc2 == 0);
mutex_unlock(&ptlrpc_all_services_mutex); mutex_unlock(&ptlrpc_all_services_mutex);
OBD_FREE_PTR(desc); kfree(desc);
goto fail; goto fail;
} }
...@@ -1233,7 +1233,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) ...@@ -1233,7 +1233,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
*/ */
LASSERT(rc2 == 0); LASSERT(rc2 == 0);
mutex_unlock(&ptlrpc_all_services_mutex); mutex_unlock(&ptlrpc_all_services_mutex);
OBD_FREE_PTR(desc); kfree(desc);
goto fail; goto fail;
} }
} }
...@@ -1301,7 +1301,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) ...@@ -1301,7 +1301,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf)
conf->nc_name); conf->nc_name);
list_del(&desc->pd_list); list_del(&desc->pd_list);
OBD_FREE_PTR(desc); kfree(desc);
fail: fail:
mutex_unlock(&ptlrpc_all_services_mutex); mutex_unlock(&ptlrpc_all_services_mutex);
...@@ -1747,7 +1747,7 @@ void ptlrpc_nrs_fini(void) ...@@ -1747,7 +1747,7 @@ void ptlrpc_nrs_fini(void)
list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies, list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies,
pd_list) { pd_list) {
list_del_init(&desc->pd_list); list_del_init(&desc->pd_list);
OBD_FREE_PTR(desc); kfree(desc);
} }
} }
......
...@@ -105,7 +105,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy) ...@@ -105,7 +105,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy)
LASSERT(head != NULL); LASSERT(head != NULL);
LASSERT(list_empty(&head->fh_list)); LASSERT(list_empty(&head->fh_list));
OBD_FREE_PTR(head); kfree(head);
} }
/** /**
......
...@@ -427,7 +427,7 @@ struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event, ...@@ -427,7 +427,7 @@ struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event,
{ {
struct timeout_item *ti; struct timeout_item *ti;
OBD_ALLOC_PTR(ti); ti = kzalloc(sizeof(*ti), GFP_NOFS);
if (!ti) if (!ti)
return NULL; return NULL;
...@@ -514,7 +514,7 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list, ...@@ -514,7 +514,7 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list,
LASSERTF(ti != NULL, "ti is NULL !\n"); LASSERTF(ti != NULL, "ti is NULL !\n");
if (list_empty(&ti->ti_obd_list)) { if (list_empty(&ti->ti_obd_list)) {
list_del(&ti->ti_chain); list_del(&ti->ti_chain);
OBD_FREE_PTR(ti); kfree(ti);
} }
mutex_unlock(&pinger_mutex); mutex_unlock(&pinger_mutex);
return 0; return 0;
...@@ -529,7 +529,7 @@ int ptlrpc_pinger_remove_timeouts(void) ...@@ -529,7 +529,7 @@ int ptlrpc_pinger_remove_timeouts(void)
list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) { list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) {
LASSERT(list_empty(&item->ti_obd_list)); LASSERT(list_empty(&item->ti_obd_list));
list_del(&item->ti_chain); list_del(&item->ti_chain);
OBD_FREE_PTR(item); kfree(item);
} }
mutex_unlock(&pinger_mutex); mutex_unlock(&pinger_mutex);
return 0; return 0;
......
...@@ -528,8 +528,9 @@ static int ptlrpcd_bind(int index, int max) ...@@ -528,8 +528,9 @@ static int ptlrpcd_bind(int index, int max)
} }
if (rc == 0 && pc->pc_npartners > 0) { if (rc == 0 && pc->pc_npartners > 0) {
OBD_ALLOC(pc->pc_partners, pc->pc_partners = kcalloc(pc->pc_npartners,
sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners); sizeof(struct ptlrpcd_ctl *),
GFP_NOFS);
if (pc->pc_partners == NULL) { if (pc->pc_partners == NULL) {
pc->pc_npartners = 0; pc->pc_npartners = 0;
rc = -ENOMEM; rc = -ENOMEM;
...@@ -699,8 +700,7 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc) ...@@ -699,8 +700,7 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc)
if (pc->pc_npartners > 0) { if (pc->pc_npartners > 0) {
LASSERT(pc->pc_partners != NULL); LASSERT(pc->pc_partners != NULL);
OBD_FREE(pc->pc_partners, kfree(pc->pc_partners);
sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners);
pc->pc_partners = NULL; pc->pc_partners = NULL;
} }
pc->pc_npartners = 0; pc->pc_npartners = 0;
...@@ -717,7 +717,7 @@ static void ptlrpcd_fini(void) ...@@ -717,7 +717,7 @@ static void ptlrpcd_fini(void)
ptlrpcd_free(&ptlrpcds->pd_threads[i]); ptlrpcd_free(&ptlrpcds->pd_threads[i]);
ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0); ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0);
ptlrpcd_free(&ptlrpcds->pd_thread_rcv); ptlrpcd_free(&ptlrpcds->pd_thread_rcv);
OBD_FREE(ptlrpcds, ptlrpcds->pd_size); kfree(ptlrpcds);
ptlrpcds = NULL; ptlrpcds = NULL;
} }
} }
...@@ -738,7 +738,7 @@ static int ptlrpcd_init(void) ...@@ -738,7 +738,7 @@ static int ptlrpcd_init(void)
nthreads &= ~1; /* make sure it is even */ nthreads &= ~1; /* make sure it is even */
size = offsetof(struct ptlrpcd, pd_threads[nthreads]); size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
OBD_ALLOC(ptlrpcds, size); ptlrpcds = kzalloc(size, GFP_NOFS);
if (ptlrpcds == NULL) { if (ptlrpcds == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -781,7 +781,7 @@ static int ptlrpcd_init(void) ...@@ -781,7 +781,7 @@ static int ptlrpcd_init(void)
ptlrpcd_free(&ptlrpcds->pd_threads[j]); ptlrpcd_free(&ptlrpcds->pd_threads[j]);
ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0); ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0);
ptlrpcd_free(&ptlrpcds->pd_thread_rcv); ptlrpcd_free(&ptlrpcds->pd_thread_rcv);
OBD_FREE(ptlrpcds, size); kfree(ptlrpcds);
ptlrpcds = NULL; ptlrpcds = NULL;
} }
......
...@@ -866,7 +866,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req) ...@@ -866,7 +866,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
if (req->rq_pool || !req->rq_reqbuf) if (req->rq_pool || !req->rq_reqbuf)
return; return;
OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len); kfree(req->rq_reqbuf);
req->rq_reqbuf = NULL; req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0; req->rq_reqbuf_len = 0;
} }
......
...@@ -210,7 +210,7 @@ static void enc_pools_release_free_pages(long npages) ...@@ -210,7 +210,7 @@ static void enc_pools_release_free_pages(long npages)
/* free unused pools */ /* free unused pools */
while (p_idx_max1 < p_idx_max2) { while (p_idx_max1 < p_idx_max2) {
LASSERT(page_pools.epp_pools[p_idx_max2]); LASSERT(page_pools.epp_pools[p_idx_max2]);
OBD_FREE(page_pools.epp_pools[p_idx_max2], PAGE_CACHE_SIZE); kfree(page_pools.epp_pools[p_idx_max2]);
page_pools.epp_pools[p_idx_max2] = NULL; page_pools.epp_pools[p_idx_max2] = NULL;
p_idx_max2--; p_idx_max2--;
} }
...@@ -294,7 +294,7 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) ...@@ -294,7 +294,7 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools)
cleaned++; cleaned++;
} }
} }
OBD_FREE(pools[i], PAGE_CACHE_SIZE); kfree(pools[i]);
pools[i] = NULL; pools[i] = NULL;
} }
} }
...@@ -409,12 +409,12 @@ static int enc_pools_add_pages(int npages) ...@@ -409,12 +409,12 @@ static int enc_pools_add_pages(int npages)
page_pools.epp_st_grows++; page_pools.epp_st_grows++;
npools = npages_to_npools(npages); npools = npages_to_npools(npages);
OBD_ALLOC(pools, npools * sizeof(*pools)); pools = kcalloc(npools, sizeof(*pools), GFP_NOFS);
if (pools == NULL) if (pools == NULL)
goto out; goto out;
for (i = 0; i < npools; i++) { for (i = 0; i < npools; i++) {
OBD_ALLOC(pools[i], PAGE_CACHE_SIZE); pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (pools[i] == NULL) if (pools[i] == NULL)
goto out_pools; goto out_pools;
...@@ -435,7 +435,7 @@ static int enc_pools_add_pages(int npages) ...@@ -435,7 +435,7 @@ static int enc_pools_add_pages(int npages)
out_pools: out_pools:
enc_pools_cleanup(pools, npools); enc_pools_cleanup(pools, npools);
OBD_FREE(pools, npools * sizeof(*pools)); kfree(pools);
out: out:
if (rc) { if (rc) {
page_pools.epp_st_grow_fails++; page_pools.epp_st_grow_fails++;
...@@ -508,8 +508,8 @@ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc) ...@@ -508,8 +508,8 @@ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc)
if (desc->bd_enc_iov != NULL) if (desc->bd_enc_iov != NULL)
return 0; return 0;
OBD_ALLOC(desc->bd_enc_iov, desc->bd_enc_iov = kcalloc(desc->bd_iov_count,
desc->bd_iov_count * sizeof(*desc->bd_enc_iov)); sizeof(*desc->bd_enc_iov), GFP_NOFS);
if (desc->bd_enc_iov == NULL) if (desc->bd_enc_iov == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -646,8 +646,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) ...@@ -646,8 +646,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
spin_unlock(&page_pools.epp_lock); spin_unlock(&page_pools.epp_lock);
OBD_FREE(desc->bd_enc_iov, kfree(desc->bd_enc_iov);
desc->bd_iov_count * sizeof(*desc->bd_enc_iov));
desc->bd_enc_iov = NULL; desc->bd_enc_iov = NULL;
} }
EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages); EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages);
......
...@@ -242,8 +242,7 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset) ...@@ -242,8 +242,7 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)
(rset->srs_nrule == 0 && rset->srs_rules == NULL)); (rset->srs_nrule == 0 && rset->srs_rules == NULL));
if (rset->srs_nslot) { if (rset->srs_nslot) {
OBD_FREE(rset->srs_rules, kfree(rset->srs_rules);
rset->srs_nslot * sizeof(*rset->srs_rules));
sptlrpc_rule_set_init(rset); sptlrpc_rule_set_init(rset);
} }
} }
...@@ -265,7 +264,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) ...@@ -265,7 +264,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
nslot = rset->srs_nslot + 8; nslot = rset->srs_nslot + 8;
/* better use realloc() if available */ /* better use realloc() if available */
OBD_ALLOC(rules, nslot * sizeof(*rset->srs_rules)); rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS);
if (rules == NULL) if (rules == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -274,8 +273,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) ...@@ -274,8 +273,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
memcpy(rules, rset->srs_rules, memcpy(rules, rset->srs_rules,
rset->srs_nrule * sizeof(*rset->srs_rules)); rset->srs_nrule * sizeof(*rset->srs_rules));
OBD_FREE(rset->srs_rules, kfree(rset->srs_rules);
rset->srs_nslot * sizeof(*rset->srs_rules));
} }
rset->srs_rules = rules; rset->srs_rules = rules;
...@@ -509,7 +507,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf) ...@@ -509,7 +507,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf)
&conf->sc_tgts, sct_list) { &conf->sc_tgts, sct_list) {
sptlrpc_rule_set_free(&conf_tgt->sct_rset); sptlrpc_rule_set_free(&conf_tgt->sct_rset);
list_del(&conf_tgt->sct_list); list_del(&conf_tgt->sct_list);
OBD_FREE_PTR(conf_tgt); kfree(conf_tgt);
} }
LASSERT(list_empty(&conf->sc_tgts)); LASSERT(list_empty(&conf->sc_tgts));
...@@ -523,7 +521,7 @@ static void sptlrpc_conf_free(struct sptlrpc_conf *conf) ...@@ -523,7 +521,7 @@ static void sptlrpc_conf_free(struct sptlrpc_conf *conf)
sptlrpc_conf_free_rsets(conf); sptlrpc_conf_free_rsets(conf);
list_del(&conf->sc_list); list_del(&conf->sc_list);
OBD_FREE_PTR(conf); kfree(conf);
} }
static static
...@@ -541,7 +539,7 @@ struct sptlrpc_conf_tgt *sptlrpc_conf_get_tgt(struct sptlrpc_conf *conf, ...@@ -541,7 +539,7 @@ struct sptlrpc_conf_tgt *sptlrpc_conf_get_tgt(struct sptlrpc_conf *conf,
if (!create) if (!create)
return NULL; return NULL;
OBD_ALLOC_PTR(conf_tgt); conf_tgt = kzalloc(sizeof(*conf_tgt), GFP_NOFS);
if (conf_tgt) { if (conf_tgt) {
strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name)); strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
sptlrpc_rule_set_init(&conf_tgt->sct_rset); sptlrpc_rule_set_init(&conf_tgt->sct_rset);
...@@ -565,7 +563,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname, ...@@ -565,7 +563,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname,
if (!create) if (!create)
return NULL; return NULL;
OBD_ALLOC_PTR(conf); conf = kzalloc(sizeof(*conf), GFP_NOFS);
if (conf == NULL) if (conf == NULL)
return NULL; return NULL;
......
...@@ -376,7 +376,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) ...@@ -376,7 +376,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
{ {
struct ptlrpc_cli_ctx *ctx, *ctx_new; struct ptlrpc_cli_ctx *ctx, *ctx_new;
OBD_ALLOC_PTR(ctx_new); ctx_new = kzalloc(sizeof(*ctx_new), GFP_NOFS);
write_lock(&plsec->pls_lock); write_lock(&plsec->pls_lock);
...@@ -385,7 +385,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec) ...@@ -385,7 +385,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
atomic_inc(&ctx->cc_refcount); atomic_inc(&ctx->cc_refcount);
if (ctx_new) if (ctx_new)
OBD_FREE_PTR(ctx_new); kfree(ctx_new);
} else if (ctx_new) { } else if (ctx_new) {
ctx = ctx_new; ctx = ctx_new;
...@@ -424,7 +424,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) ...@@ -424,7 +424,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec)
class_import_put(sec->ps_import); class_import_put(sec->ps_import);
OBD_FREE_PTR(plsec); kfree(plsec);
} }
static static
...@@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, ...@@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp,
LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN);
OBD_ALLOC_PTR(plsec); plsec = kzalloc(sizeof(*plsec), GFP_NOFS);
if (plsec == NULL) if (plsec == NULL)
return NULL; return NULL;
...@@ -508,7 +508,7 @@ void plain_release_ctx(struct ptlrpc_sec *sec, ...@@ -508,7 +508,7 @@ void plain_release_ctx(struct ptlrpc_sec *sec,
LASSERT(atomic_read(&ctx->cc_refcount) == 0); LASSERT(atomic_read(&ctx->cc_refcount) == 0);
LASSERT(ctx->cc_sec == sec); LASSERT(ctx->cc_sec == sec);
OBD_FREE_PTR(ctx); kfree(ctx);
atomic_dec(&sec->ps_nctx); atomic_dec(&sec->ps_nctx);
sptlrpc_sec_put(sec); sptlrpc_sec_put(sec);
......
...@@ -87,7 +87,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt) ...@@ -87,7 +87,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt)
OBD_CPT_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_cptable, OBD_CPT_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_cptable,
svcpt->scp_cpt, svc->srv_buf_size); svcpt->scp_cpt, svc->srv_buf_size);
if (rqbd->rqbd_buffer == NULL) { if (rqbd->rqbd_buffer == NULL) {
OBD_FREE_PTR(rqbd); kfree(rqbd);
return NULL; return NULL;
} }
...@@ -113,7 +113,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd) ...@@ -113,7 +113,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
spin_unlock(&svcpt->scp_lock); spin_unlock(&svcpt->scp_lock);
OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size); OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size);
OBD_FREE_PTR(rqbd); kfree(rqbd);
} }
int int
...@@ -661,13 +661,12 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, ...@@ -661,13 +661,12 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
failed: failed:
if (array->paa_reqs_count != NULL) { if (array->paa_reqs_count != NULL) {
OBD_FREE(array->paa_reqs_count, sizeof(__u32) * size); kfree(array->paa_reqs_count);
array->paa_reqs_count = NULL; array->paa_reqs_count = NULL;
} }
if (array->paa_reqs_array != NULL) { if (array->paa_reqs_array != NULL) {
OBD_FREE(array->paa_reqs_array, kfree(array->paa_reqs_array);
sizeof(struct list_head) * array->paa_size);
array->paa_reqs_array = NULL; array->paa_reqs_array = NULL;
} }
...@@ -724,17 +723,18 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, ...@@ -724,17 +723,18 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
CERROR("%s: failed to parse CPT array %s: %d\n", CERROR("%s: failed to parse CPT array %s: %d\n",
conf->psc_name, cconf->cc_pattern, rc); conf->psc_name, cconf->cc_pattern, rc);
if (cpts != NULL) if (cpts != NULL)
OBD_FREE(cpts, sizeof(*cpts) * ncpts); kfree(cpts);
return ERR_PTR(rc < 0 ? rc : -EINVAL); return ERR_PTR(rc < 0 ? rc : -EINVAL);
} }
ncpts = rc; ncpts = rc;
} }
} }
OBD_ALLOC(service, offsetof(struct ptlrpc_service, srv_parts[ncpts])); service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
GFP_NOFS);
if (service == NULL) { if (service == NULL) {
if (cpts != NULL) if (cpts != NULL)
OBD_FREE(cpts, sizeof(*cpts) * ncpts); kfree(cpts);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
...@@ -2291,7 +2291,7 @@ static int ptlrpc_main(void *arg) ...@@ -2291,7 +2291,7 @@ static int ptlrpc_main(void *arg)
goto out; goto out;
} }
OBD_ALLOC_PTR(env); env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL) { if (env == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_srv_fini; goto out_srv_fini;
...@@ -2414,7 +2414,7 @@ static int ptlrpc_main(void *arg) ...@@ -2414,7 +2414,7 @@ static int ptlrpc_main(void *arg)
if (env != NULL) { if (env != NULL) {
lu_context_fini(&env->le_ctx); lu_context_fini(&env->le_ctx);
OBD_FREE_PTR(env); kfree(env);
} }
out: out:
CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n", CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n",
...@@ -2596,7 +2596,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) ...@@ -2596,7 +2596,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt)
thread = list_entry(zombie.next, thread = list_entry(zombie.next,
struct ptlrpc_thread, t_link); struct ptlrpc_thread, t_link);
list_del(&thread->t_link); list_del(&thread->t_link);
OBD_FREE_PTR(thread); kfree(thread);
} }
} }
...@@ -2678,7 +2678,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) ...@@ -2678,7 +2678,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
spin_lock(&svcpt->scp_lock); spin_lock(&svcpt->scp_lock);
if (!ptlrpc_threads_increasable(svcpt)) { if (!ptlrpc_threads_increasable(svcpt)) {
spin_unlock(&svcpt->scp_lock); spin_unlock(&svcpt->scp_lock);
OBD_FREE_PTR(thread); kfree(thread);
return -EMFILE; return -EMFILE;
} }
...@@ -2687,7 +2687,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) ...@@ -2687,7 +2687,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
* might require unique and contiguous t_id */ * might require unique and contiguous t_id */
LASSERT(svcpt->scp_nthrs_starting == 1); LASSERT(svcpt->scp_nthrs_starting == 1);
spin_unlock(&svcpt->scp_lock); spin_unlock(&svcpt->scp_lock);
OBD_FREE_PTR(thread); kfree(thread);
if (wait) { if (wait) {
CDEBUG(D_INFO, "Waiting for creating thread %s #%d\n", CDEBUG(D_INFO, "Waiting for creating thread %s #%d\n",
svc->srv_thread_name, svcpt->scp_thr_nextid); svc->srv_thread_name, svcpt->scp_thr_nextid);
...@@ -2733,7 +2733,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) ...@@ -2733,7 +2733,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
} else { } else {
list_del(&thread->t_link); list_del(&thread->t_link);
spin_unlock(&svcpt->scp_lock); spin_unlock(&svcpt->scp_lock);
OBD_FREE_PTR(thread); kfree(thread);
} }
return rc; return rc;
} }
...@@ -2817,8 +2817,7 @@ void ptlrpc_hr_fini(void) ...@@ -2817,8 +2817,7 @@ void ptlrpc_hr_fini(void)
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
if (hrp->hrp_thrs != NULL) { if (hrp->hrp_thrs != NULL) {
OBD_FREE(hrp->hrp_thrs, kfree(hrp->hrp_thrs);
hrp->hrp_nthrs * sizeof(hrp->hrp_thrs[0]));
} }
} }
...@@ -2999,26 +2998,23 @@ ptlrpc_service_free(struct ptlrpc_service *svc) ...@@ -2999,26 +2998,23 @@ ptlrpc_service_free(struct ptlrpc_service *svc)
array = &svcpt->scp_at_array; array = &svcpt->scp_at_array;
if (array->paa_reqs_array != NULL) { if (array->paa_reqs_array != NULL) {
OBD_FREE(array->paa_reqs_array, kfree(array->paa_reqs_array);
sizeof(struct list_head) * array->paa_size);
array->paa_reqs_array = NULL; array->paa_reqs_array = NULL;
} }
if (array->paa_reqs_count != NULL) { if (array->paa_reqs_count != NULL) {
OBD_FREE(array->paa_reqs_count, kfree(array->paa_reqs_count);
sizeof(__u32) * array->paa_size);
array->paa_reqs_count = NULL; array->paa_reqs_count = NULL;
} }
} }
ptlrpc_service_for_each_part(svcpt, i, svc) ptlrpc_service_for_each_part(svcpt, i, svc)
OBD_FREE_PTR(svcpt); kfree(svcpt);
if (svc->srv_cpts != NULL) if (svc->srv_cpts != NULL)
cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts); cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts);
OBD_FREE(svc, offsetof(struct ptlrpc_service, kfree(svc);
srv_parts[svc->srv_ncpts]));
} }
int ptlrpc_unregister_service(struct ptlrpc_service *service) int ptlrpc_unregister_service(struct ptlrpc_service *service)
......
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