Commit 352f7891 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: ldlm: 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 00c40c16
......@@ -73,7 +73,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
}
if (create) {
OBD_ALLOC(imp_conn, sizeof(*imp_conn));
imp_conn = kzalloc(sizeof(*imp_conn), GFP_NOFS);
if (!imp_conn) {
rc = -ENOMEM;
goto out_put;
......@@ -120,7 +120,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
return 0;
out_free:
if (imp_conn)
OBD_FREE(imp_conn, sizeof(*imp_conn));
kfree(imp_conn);
out_put:
ptlrpc_connection_put(ptlrpc_conn);
return rc;
......@@ -179,7 +179,7 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
list_del(&imp_conn->oic_item);
ptlrpc_connection_put(imp_conn->oic_conn);
OBD_FREE(imp_conn, sizeof(*imp_conn));
kfree(imp_conn);
CDEBUG(D_HA, "imp %p@%s: remove connection %s\n",
imp, imp->imp_obd->obd_name, uuid->uuid);
rc = 0;
......
......@@ -209,7 +209,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
}
if (lock->l_lvb_data != NULL)
OBD_FREE(lock->l_lvb_data, lock->l_lvb_len);
kfree(lock->l_lvb_data);
ldlm_interval_free(ldlm_interval_detach(lock));
lu_ref_fini(&lock->l_reference);
......@@ -1527,7 +1527,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
if (lvb_len) {
lock->l_lvb_len = lvb_len;
OBD_ALLOC(lock->l_lvb_data, lvb_len);
lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lock->l_lvb_data == NULL)
goto out;
}
......@@ -1791,7 +1791,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
LDLM_LOCK_RELEASE(lock);
if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0)
OBD_FREE_PTR(gl_work);
kfree(gl_work);
return rc;
}
......@@ -1812,7 +1812,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
if (list_empty(rpc_list))
return 0;
OBD_ALLOC_PTR(arg);
arg = kzalloc(sizeof(*arg), GFP_NOFS);
if (arg == NULL)
return -ENOMEM;
......@@ -1857,7 +1857,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
rc = atomic_read(&arg->restart) ? -ERESTART : 0;
goto out;
out:
OBD_FREE_PTR(arg);
kfree(arg);
return rc;
}
......
......@@ -220,7 +220,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
* variable length */
void *lvb_data;
OBD_ALLOC(lvb_data, lvb_len);
lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lvb_data == NULL) {
LDLM_ERROR(lock, "No memory: %d.\n", lvb_len);
rc = -ENOMEM;
......@@ -448,7 +448,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
if (cancel_flags & LCF_ASYNC) {
struct ldlm_bl_work_item *blwi;
OBD_ALLOC(blwi, sizeof(*blwi));
blwi = kzalloc(sizeof(*blwi), GFP_NOFS);
if (blwi == NULL)
return -ENOMEM;
init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags);
......@@ -849,7 +849,7 @@ static int ldlm_bl_thread_main(void *arg)
memory_pressure_clr();
if (blwi->blwi_flags & LCF_ASYNC)
OBD_FREE(blwi, sizeof(*blwi));
kfree(blwi);
else
complete(&blwi->blwi_comp);
}
......@@ -1012,7 +1012,7 @@ static int ldlm_setup(void)
if (ldlm_state != NULL)
return -EALREADY;
OBD_ALLOC(ldlm_state, sizeof(*ldlm_state));
ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS);
if (ldlm_state == NULL)
return -ENOMEM;
......@@ -1059,7 +1059,7 @@ static int ldlm_setup(void)
}
OBD_ALLOC(blp, sizeof(*blp));
blp = kzalloc(sizeof(*blp), GFP_NOFS);
if (blp == NULL) {
rc = -ENOMEM;
goto out;
......@@ -1129,7 +1129,7 @@ static int ldlm_cleanup(void)
wait_for_completion(&blp->blp_comp);
}
OBD_FREE(blp, sizeof(*blp));
kfree(blp);
}
if (ldlm_state->ldlm_cb_service != NULL)
......@@ -1138,7 +1138,7 @@ static int ldlm_cleanup(void)
ldlm_proc_cleanup();
OBD_FREE(ldlm_state, sizeof(*ldlm_state));
kfree(ldlm_state);
ldlm_state = NULL;
return 0;
......
......@@ -746,7 +746,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
char *var_name = NULL;
int rc = 0;
OBD_ALLOC(var_name, MAX_STRING_SIZE + 1);
var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS);
if (!var_name)
return -ENOMEM;
......@@ -828,7 +828,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats);
out_free_name:
OBD_FREE(var_name, MAX_STRING_SIZE + 1);
kfree(var_name);
return rc;
}
......@@ -1383,7 +1383,7 @@ static int ldlm_pools_thread_start(void)
if (ldlm_pools_thread != NULL)
return -EALREADY;
OBD_ALLOC_PTR(ldlm_pools_thread);
ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
if (ldlm_pools_thread == NULL)
return -ENOMEM;
......@@ -1394,7 +1394,7 @@ static int ldlm_pools_thread_start(void)
"ldlm_poold");
if (IS_ERR(task)) {
CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task));
OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread));
kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
return PTR_ERR(task);
}
......@@ -1417,7 +1417,7 @@ static void ldlm_pools_thread_stop(void)
* in pools thread.
*/
wait_for_completion(&ldlm_pools_comp);
OBD_FREE_PTR(ldlm_pools_thread);
kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
}
......
......@@ -590,7 +590,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
break;
}
OBD_ALLOC_PTR(ns);
ns = kzalloc(sizeof(*ns), GFP_NOFS);
if (!ns)
goto out_ref;
......@@ -657,7 +657,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
out_hash:
cfs_hash_putref(ns->ns_rs_hash);
out_ns:
OBD_FREE_PTR(ns);
kfree(ns);
out_ref:
ldlm_put_ref();
return NULL;
......@@ -904,7 +904,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
* this will cause issues related to using freed \a ns in poold
* thread. */
LASSERT(list_empty(&ns->ns_list_chain));
OBD_FREE_PTR(ns);
kfree(ns);
ldlm_put_ref();
}
......@@ -1138,7 +1138,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
ns->ns_obd->obd_name, name->name[0],
name->name[1], rc);
if (res->lr_lvb_data) {
OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
kfree(res->lr_lvb_data);
res->lr_lvb_data = NULL;
}
res->lr_lvb_len = rc;
......
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