Commit 8bcf30c3 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: lmv: 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 352f7891
...@@ -99,7 +99,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, ...@@ -99,7 +99,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
goto out; goto out;
} }
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) { if (op_data == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -142,7 +142,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, ...@@ -142,7 +142,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
it->d.lustre.it_lock_mode = pmode; it->d.lustre.it_lock_mode = pmode;
out_free_op_data: out_free_op_data:
OBD_FREE_PTR(op_data); kfree(op_data);
out: out:
if (rc && pmode) if (rc && pmode)
ldlm_lock_decref(&plock, pmode); ldlm_lock_decref(&plock, pmode);
......
...@@ -442,7 +442,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index) ...@@ -442,7 +442,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index)
if (lmv->tgts[index] == NULL) if (lmv->tgts[index] == NULL)
return; return;
OBD_FREE_PTR(lmv->tgts[index]); kfree(lmv->tgts[index]);
lmv->tgts[index] = NULL; lmv->tgts[index] = NULL;
return; return;
} }
...@@ -488,7 +488,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, ...@@ -488,7 +488,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
while (newsize < index + 1) while (newsize < index + 1)
newsize <<= 1; newsize <<= 1;
OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS);
if (newtgts == NULL) { if (newtgts == NULL) {
lmv_init_unlock(lmv); lmv_init_unlock(lmv);
return -ENOMEM; return -ENOMEM;
...@@ -505,13 +505,13 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, ...@@ -505,13 +505,13 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
lmv->tgts_size = newsize; lmv->tgts_size = newsize;
smp_rmb(); smp_rmb();
if (old) if (old)
OBD_FREE(old, sizeof(*old) * oldsize); kfree(old);
CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts, CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts,
lmv->tgts_size); lmv->tgts_size);
} }
OBD_ALLOC_PTR(tgt); tgt = kzalloc(sizeof(*tgt), GFP_NOFS);
if (!tgt) { if (!tgt) {
lmv_init_unlock(lmv); lmv_init_unlock(lmv);
return -ENOMEM; return -ENOMEM;
...@@ -750,7 +750,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) ...@@ -750,7 +750,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg)
/* sigh, has to go to another MDT to do path building further */ /* sigh, has to go to another MDT to do path building further */
if (remote_gf == NULL) { if (remote_gf == NULL) {
remote_gf_size = sizeof(*remote_gf) + PATH_MAX; remote_gf_size = sizeof(*remote_gf) + PATH_MAX;
OBD_ALLOC(remote_gf, remote_gf_size); remote_gf = kzalloc(remote_gf_size, GFP_NOFS);
if (remote_gf == NULL) { if (remote_gf == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_fid2path; goto out_fid2path;
...@@ -781,7 +781,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) ...@@ -781,7 +781,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg)
out_fid2path: out_fid2path:
if (remote_gf != NULL) if (remote_gf != NULL)
OBD_FREE(remote_gf, remote_gf_size); kfree(remote_gf);
return rc; return rc;
} }
...@@ -984,7 +984,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, ...@@ -984,7 +984,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
return -EAGAIN; return -EAGAIN;
LASSERT(tgt && tgt->ltd_exp); LASSERT(tgt && tgt->ltd_exp);
OBD_ALLOC_PTR(oqctl); oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl) if (!oqctl)
return -ENOMEM; return -ENOMEM;
...@@ -995,7 +995,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, ...@@ -995,7 +995,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
qctl->qc_valid = QC_MDTIDX; qctl->qc_valid = QC_MDTIDX;
qctl->obd_uuid = tgt->ltd_uuid; qctl->obd_uuid = tgt->ltd_uuid;
} }
OBD_FREE_PTR(oqctl); kfree(oqctl);
break; break;
} }
case OBD_IOC_CHANGELOG_SEND: case OBD_IOC_CHANGELOG_SEND:
...@@ -1327,7 +1327,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) ...@@ -1327,7 +1327,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
return -EINVAL; return -EINVAL;
} }
OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32); lmv->tgts = kcalloc(32, sizeof(*lmv->tgts), GFP_NOFS);
if (lmv->tgts == NULL) if (lmv->tgts == NULL)
return -ENOMEM; return -ENOMEM;
lmv->tgts_size = 32; lmv->tgts_size = 32;
...@@ -1380,7 +1380,7 @@ static int lmv_cleanup(struct obd_device *obd) ...@@ -1380,7 +1380,7 @@ static int lmv_cleanup(struct obd_device *obd)
continue; continue;
lmv_del_target(lmv, i); lmv_del_target(lmv, i);
} }
OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size); kfree(lmv->tgts);
lmv->tgts_size = 0; lmv->tgts_size = 0;
} }
return 0; return 0;
...@@ -1437,7 +1437,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, ...@@ -1437,7 +1437,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
if (rc) if (rc)
return rc; return rc;
OBD_ALLOC(temp, sizeof(*temp)); temp = kzalloc(sizeof(*temp), GFP_NOFS);
if (temp == NULL) if (temp == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1473,7 +1473,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, ...@@ -1473,7 +1473,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
} }
out_free_temp: out_free_temp:
OBD_FREE(temp, sizeof(*temp)); kfree(temp);
return rc; return rc;
} }
...@@ -1769,7 +1769,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, ...@@ -1769,7 +1769,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
goto out; goto out;
} }
OBD_ALLOC_PTR(rdata); rdata = kzalloc(sizeof(*rdata), GFP_NOFS);
if (rdata == NULL) { if (rdata == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -1780,7 +1780,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, ...@@ -1780,7 +1780,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh, rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
lmm, lmmsize, NULL, extra_lock_flags); lmm, lmmsize, NULL, extra_lock_flags);
OBD_FREE_PTR(rdata); kfree(rdata);
out: out:
ldlm_lock_decref(&plock, pmode); ldlm_lock_decref(&plock, pmode);
return rc; return 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