staging: lustre: mgc: 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: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7b81779d0d
commit
c9b4297faa
1 changed files with 10 additions and 10 deletions
|
@ -149,7 +149,7 @@ static void config_log_put(struct config_llog_data *cld)
|
||||||
sptlrpc_conf_log_stop(cld->cld_logname);
|
sptlrpc_conf_log_stop(cld->cld_logname);
|
||||||
|
|
||||||
class_export_put(cld->cld_mgcexp);
|
class_export_put(cld->cld_mgcexp);
|
||||||
OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1);
|
kfree(cld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd,
|
||||||
CDEBUG(D_MGC, "do adding config log %s:%p\n", logname,
|
CDEBUG(D_MGC, "do adding config log %s:%p\n", logname,
|
||||||
cfg ? cfg->cfg_instance : NULL);
|
cfg ? cfg->cfg_instance : NULL);
|
||||||
|
|
||||||
OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1);
|
cld = kzalloc(sizeof(*cld) + strlen(logname) + 1, GFP_NOFS);
|
||||||
if (!cld)
|
if (!cld)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
@ -1129,14 +1129,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
|
||||||
LASSERT(cfg->cfg_instance != NULL);
|
LASSERT(cfg->cfg_instance != NULL);
|
||||||
LASSERT(cfg->cfg_sb == cfg->cfg_instance);
|
LASSERT(cfg->cfg_sb == cfg->cfg_instance);
|
||||||
|
|
||||||
OBD_ALLOC(inst, PAGE_CACHE_SIZE);
|
inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
|
||||||
if (inst == NULL)
|
if (inst == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (!IS_SERVER(lsi)) {
|
if (!IS_SERVER(lsi)) {
|
||||||
pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance);
|
pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance);
|
||||||
if (pos >= PAGE_CACHE_SIZE) {
|
if (pos >= PAGE_CACHE_SIZE) {
|
||||||
OBD_FREE(inst, PAGE_CACHE_SIZE);
|
kfree(inst);
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1144,7 +1144,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
|
||||||
rc = server_name2svname(lsi->lsi_svname, inst, NULL,
|
rc = server_name2svname(lsi->lsi_svname, inst, NULL,
|
||||||
PAGE_CACHE_SIZE);
|
PAGE_CACHE_SIZE);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
OBD_FREE(inst, PAGE_CACHE_SIZE);
|
kfree(inst);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
pos = strlen(inst);
|
pos = strlen(inst);
|
||||||
|
@ -1302,7 +1302,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
|
||||||
/* continue, even one with error */
|
/* continue, even one with error */
|
||||||
}
|
}
|
||||||
|
|
||||||
OBD_FREE(inst, PAGE_CACHE_SIZE);
|
kfree(inst);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1336,7 +1336,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
|
||||||
if (cfg->cfg_last_idx == 0) /* the first time */
|
if (cfg->cfg_last_idx == 0) /* the first time */
|
||||||
nrpages = CONFIG_READ_NRPAGES_INIT;
|
nrpages = CONFIG_READ_NRPAGES_INIT;
|
||||||
|
|
||||||
OBD_ALLOC(pages, sizeof(*pages) * nrpages);
|
pages = kcalloc(nrpages, sizeof(*pages), GFP_NOFS);
|
||||||
if (pages == NULL) {
|
if (pages == NULL) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1466,7 +1466,7 @@ out:
|
||||||
break;
|
break;
|
||||||
__free_page(pages[i]);
|
__free_page(pages[i]);
|
||||||
}
|
}
|
||||||
OBD_FREE(pages, sizeof(*pages) * nrpages);
|
kfree(pages);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1494,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
|
||||||
if (cld->cld_cfg.cfg_sb)
|
if (cld->cld_cfg.cfg_sb)
|
||||||
lsi = s2lsi(cld->cld_cfg.cfg_sb);
|
lsi = s2lsi(cld->cld_cfg.cfg_sb);
|
||||||
|
|
||||||
OBD_ALLOC_PTR(env);
|
env = kzalloc(sizeof(*env), GFP_NOFS);
|
||||||
if (env == NULL)
|
if (env == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1540,7 +1540,7 @@ out_pop:
|
||||||
|
|
||||||
lu_env_fini(env);
|
lu_env_fini(env);
|
||||||
out_free:
|
out_free:
|
||||||
OBD_FREE_PTR(env);
|
kfree(env);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue