Commit 7b81779d authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: mdc: 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 8bcf30c3
...@@ -106,7 +106,7 @@ static ssize_t mdc_kuc_write(struct file *file, ...@@ -106,7 +106,7 @@ static ssize_t mdc_kuc_write(struct file *file,
len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN + len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN +
/* for mockup below */ 2 * cfs_size_round(sizeof(*hai)); /* for mockup below */ 2 * cfs_size_round(sizeof(*hai));
OBD_ALLOC(lh, len); lh = kzalloc(len, GFP_NOFS);
if (!lh) if (!lh)
return -ENOMEM; return -ENOMEM;
...@@ -141,7 +141,7 @@ static ssize_t mdc_kuc_write(struct file *file, ...@@ -141,7 +141,7 @@ static ssize_t mdc_kuc_write(struct file *file,
rc = libcfs_kkuc_msg_put(fp, lh); rc = libcfs_kkuc_msg_put(fp, lh);
fput(fp); fput(fp);
} }
OBD_FREE(lh, len); kfree(lh);
if (rc < 0) if (rc < 0)
return rc; return rc;
return count; return count;
......
...@@ -1251,7 +1251,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, ...@@ -1251,7 +1251,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh); rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh);
out: out:
OBD_FREE_PTR(einfo); kfree(einfo);
minfo->mi_cb(req, minfo, rc); minfo->mi_cb(req, minfo, rc);
return 0; return 0;
} }
......
...@@ -1201,7 +1201,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) ...@@ -1201,7 +1201,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
/* Key is KEY_FID2PATH + getinfo_fid2path description */ /* Key is KEY_FID2PATH + getinfo_fid2path description */
keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf); keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
OBD_ALLOC(key, keylen); key = kzalloc(keylen, GFP_NOFS);
if (key == NULL) if (key == NULL)
return -ENOMEM; return -ENOMEM;
memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
...@@ -1234,7 +1234,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) ...@@ -1234,7 +1234,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path); PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
out: out:
OBD_FREE(key, keylen); kfree(key);
return rc; return rc;
} }
...@@ -1604,7 +1604,7 @@ static int mdc_changelog_send_thread(void *csdata) ...@@ -1604,7 +1604,7 @@ static int mdc_changelog_send_thread(void *csdata)
CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n", CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n",
cs->cs_fp, cs->cs_startrec); cs->cs_fp, cs->cs_startrec);
OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS);
if (cs->cs_buf == NULL) { if (cs->cs_buf == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -1645,8 +1645,8 @@ static int mdc_changelog_send_thread(void *csdata) ...@@ -1645,8 +1645,8 @@ static int mdc_changelog_send_thread(void *csdata)
if (ctxt) if (ctxt)
llog_ctxt_put(ctxt); llog_ctxt_put(ctxt);
if (cs->cs_buf) if (cs->cs_buf)
OBD_FREE(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); kfree(cs->cs_buf);
OBD_FREE_PTR(cs); kfree(cs);
return rc; return rc;
} }
...@@ -1657,7 +1657,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, ...@@ -1657,7 +1657,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
int rc; int rc;
/* Freed in mdc_changelog_send_thread */ /* Freed in mdc_changelog_send_thread */
OBD_ALLOC_PTR(cs); cs = kzalloc(sizeof(*cs), GFP_NOFS);
if (!cs) if (!cs)
return -ENOMEM; return -ENOMEM;
...@@ -1679,7 +1679,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, ...@@ -1679,7 +1679,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
} }
CERROR("Failed to start changelog thread: %d\n", rc); CERROR("Failed to start changelog thread: %d\n", rc);
OBD_FREE_PTR(cs); kfree(cs);
return rc; return rc;
} }
...@@ -1937,7 +1937,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, ...@@ -1937,7 +1937,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
struct if_quotactl *qctl = karg; struct if_quotactl *qctl = karg;
struct obd_quotactl *oqctl; struct obd_quotactl *oqctl;
OBD_ALLOC_PTR(oqctl); oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (oqctl == NULL) { if (oqctl == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -1951,7 +1951,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, ...@@ -1951,7 +1951,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
qctl->obd_uuid = obd->u.cli.cl_target_uuid; qctl->obd_uuid = obd->u.cli.cl_target_uuid;
} }
OBD_FREE_PTR(oqctl); kfree(oqctl);
goto out; goto out;
} }
case LL_IOC_GET_CONNECT_FLAGS: case LL_IOC_GET_CONNECT_FLAGS:
...@@ -2430,14 +2430,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) ...@@ -2430,14 +2430,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
struct lprocfs_static_vars lvars = { NULL }; struct lprocfs_static_vars lvars = { NULL };
int rc; int rc;
OBD_ALLOC(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); cli->cl_rpc_lock = kzalloc(sizeof(*cli->cl_rpc_lock), GFP_NOFS);
if (!cli->cl_rpc_lock) if (!cli->cl_rpc_lock)
return -ENOMEM; return -ENOMEM;
mdc_init_rpc_lock(cli->cl_rpc_lock); mdc_init_rpc_lock(cli->cl_rpc_lock);
ptlrpcd_addref(); ptlrpcd_addref();
OBD_ALLOC(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS);
if (!cli->cl_close_lock) { if (!cli->cl_close_lock) {
rc = -ENOMEM; rc = -ENOMEM;
goto err_rpc_lock; goto err_rpc_lock;
...@@ -2465,9 +2465,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) ...@@ -2465,9 +2465,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
return rc; return rc;
err_close_lock: err_close_lock:
OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); kfree(cli->cl_close_lock);
err_rpc_lock: err_rpc_lock:
OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); kfree(cli->cl_rpc_lock);
ptlrpcd_decref(); ptlrpcd_decref();
return rc; return rc;
} }
...@@ -2525,8 +2525,8 @@ static int mdc_cleanup(struct obd_device *obd) ...@@ -2525,8 +2525,8 @@ static int mdc_cleanup(struct obd_device *obd)
{ {
struct client_obd *cli = &obd->u.cli; struct client_obd *cli = &obd->u.cli;
OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock)); kfree(cli->cl_rpc_lock);
OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock)); kfree(cli->cl_close_lock);
ptlrpcd_decref(); ptlrpcd_decref();
......
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