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

staging: lustre: obdclass: 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 c9b4297f
...@@ -104,12 +104,12 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header, ...@@ -104,12 +104,12 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
if (unlikely(old_count <= new_count)) if (unlikely(old_count <= new_count))
return old_size; return old_size;
OBD_ALLOC(new, new_size); new = kzalloc(new_size, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return -ENOMEM; return -ENOMEM;
memcpy(new, *header, new_size); memcpy(new, *header, new_size);
OBD_FREE(*header, old_size); kfree(*header);
*header = new; *header = new;
return new_size; return new_size;
} }
...@@ -126,12 +126,12 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header, ...@@ -126,12 +126,12 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header,
if (unlikely(old_count <= ext_count)) if (unlikely(old_count <= ext_count))
return 0; return 0;
OBD_ALLOC(new, ext_size); new = kzalloc(ext_size, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return -ENOMEM; return -ENOMEM;
memcpy(new, *header, ext_size); memcpy(new, *header, ext_size);
OBD_FREE(*header, old_size); kfree(*header);
*header = new; *header = new;
return 0; return 0;
} }
...@@ -152,7 +152,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) ...@@ -152,7 +152,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size)
else else
count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr);
esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr);
OBD_ALLOC(new, esize); new = kzalloc(esize, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -183,7 +183,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, ...@@ -183,7 +183,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
if (size < sizeof(*new)) if (size < sizeof(*new))
return -EINVAL; return -EINVAL;
OBD_ALLOC(new, size); new = kzalloc(size, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return -ENOMEM; return -ENOMEM;
...@@ -232,7 +232,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, ...@@ -232,7 +232,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
_out: _out:
if (rc) { if (rc) {
OBD_FREE(new, size); kfree(new);
size = rc; size = rc;
} }
return size; return size;
...@@ -244,7 +244,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_filter); ...@@ -244,7 +244,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_filter);
*/ */
void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size) void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size)
{ {
OBD_FREE(header, size); kfree(header);
} }
EXPORT_SYMBOL(lustre_posix_acl_xattr_free); EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
...@@ -253,8 +253,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_free); ...@@ -253,8 +253,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
*/ */
void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header) void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header)
{ {
OBD_FREE(header, CFS_ACL_XATTR_SIZE(le32_to_cpu(header->a_count), \ kfree(header);
ext_acl_xattr));
} }
EXPORT_SYMBOL(lustre_ext_acl_xattr_free); EXPORT_SYMBOL(lustre_ext_acl_xattr_free);
...@@ -309,7 +308,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, ...@@ -309,7 +308,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
/* there are only base ACL entries at most. */ /* there are only base ACL entries at most. */
posix_count = 3; posix_count = 3;
posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr);
OBD_ALLOC(new, posix_size); new = kzalloc(posix_size, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return -ENOMEM; return -ENOMEM;
...@@ -360,7 +359,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, ...@@ -360,7 +359,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
posix_count = ori_posix_count + ext_count; posix_count = ori_posix_count + ext_count;
posix_size = posix_size =
CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr);
OBD_ALLOC(new, posix_size); new = kzalloc(posix_size, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return -ENOMEM; return -ENOMEM;
...@@ -402,7 +401,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, ...@@ -402,7 +401,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
_out: _out:
if (rc) { if (rc) {
OBD_FREE(new, posix_size); kfree(new);
posix_size = rc; posix_size = rc;
} }
return posix_size; return posix_size;
...@@ -432,7 +431,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, ...@@ -432,7 +431,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
ext_count = posix_count + ori_ext_count; ext_count = posix_count + ori_ext_count;
ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr);
OBD_ALLOC(new, ext_size); new = kzalloc(ext_size, GFP_NOFS);
if (unlikely(new == NULL)) if (unlikely(new == NULL))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -538,7 +537,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, ...@@ -538,7 +537,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
out: out:
if (rc) { if (rc) {
OBD_FREE(new, ext_size); kfree(new);
new = ERR_PTR(rc); new = ERR_PTR(rc);
} }
return new; return new;
......
...@@ -87,7 +87,7 @@ struct hlist_head *init_capa_hash(void) ...@@ -87,7 +87,7 @@ struct hlist_head *init_capa_hash(void)
struct hlist_head *hash; struct hlist_head *hash;
int nr_hash, i; int nr_hash, i;
OBD_ALLOC(hash, PAGE_CACHE_SIZE); hash = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (!hash) if (!hash)
return NULL; return NULL;
...@@ -129,7 +129,7 @@ void cleanup_capa_hash(struct hlist_head *hash) ...@@ -129,7 +129,7 @@ void cleanup_capa_hash(struct hlist_head *hash)
} }
spin_unlock(&capa_lock); spin_unlock(&capa_lock);
OBD_FREE(hash, PAGE_CACHE_SIZE); kfree(hash);
} }
EXPORT_SYMBOL(cleanup_capa_hash); EXPORT_SYMBOL(cleanup_capa_hash);
......
...@@ -612,7 +612,7 @@ EXPORT_SYMBOL(cl_io_lock_add); ...@@ -612,7 +612,7 @@ EXPORT_SYMBOL(cl_io_lock_add);
static void cl_free_io_lock_link(const struct lu_env *env, static void cl_free_io_lock_link(const struct lu_env *env,
struct cl_io_lock_link *link) struct cl_io_lock_link *link)
{ {
OBD_FREE_PTR(link); kfree(link);
} }
/** /**
...@@ -624,7 +624,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, ...@@ -624,7 +624,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io,
struct cl_io_lock_link *link; struct cl_io_lock_link *link;
int result; int result;
OBD_ALLOC_PTR(link); link = kzalloc(sizeof(*link), GFP_NOFS);
if (link != NULL) { if (link != NULL) {
link->cill_descr = *descr; link->cill_descr = *descr;
link->cill_fini = cl_free_io_lock_link; link->cill_fini = cl_free_io_lock_link;
...@@ -1387,9 +1387,9 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) ...@@ -1387,9 +1387,9 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req)
cl_object_put(env, obj); cl_object_put(env, obj);
} }
} }
OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof(req->crq_o[0])); kfree(req->crq_o);
} }
OBD_FREE_PTR(req); kfree(req);
} }
static int cl_req_init(const struct lu_env *env, struct cl_req *req, static int cl_req_init(const struct lu_env *env, struct cl_req *req,
...@@ -1448,7 +1448,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, ...@@ -1448,7 +1448,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page,
LINVRNT(nr_objects > 0); LINVRNT(nr_objects > 0);
OBD_ALLOC_PTR(req); req = kzalloc(sizeof(*req), GFP_NOFS);
if (req != NULL) { if (req != NULL) {
int result; int result;
...@@ -1456,7 +1456,8 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, ...@@ -1456,7 +1456,8 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page,
INIT_LIST_HEAD(&req->crq_pages); INIT_LIST_HEAD(&req->crq_pages);
INIT_LIST_HEAD(&req->crq_layers); INIT_LIST_HEAD(&req->crq_layers);
OBD_ALLOC(req->crq_o, nr_objects * sizeof(req->crq_o[0])); req->crq_o = kcalloc(nr_objects, sizeof(req->crq_o[0]),
GFP_NOFS);
if (req->crq_o != NULL) { if (req->crq_o != NULL) {
req->crq_nrobjs = nr_objects; req->crq_nrobjs = nr_objects;
result = cl_req_init(env, req, page); result = cl_req_init(env, req, page);
......
...@@ -270,7 +270,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) ...@@ -270,7 +270,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
cl_object_put(env, obj); cl_object_put(env, obj);
lu_ref_fini(&page->cp_reference); lu_ref_fini(&page->cp_reference);
OBD_FREE(page, pagesize); kfree(page);
} }
/** /**
......
...@@ -231,7 +231,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) ...@@ -231,7 +231,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
err = -EINVAL; err = -EINVAL;
goto out; goto out;
} }
OBD_ALLOC(lcfg, data->ioc_plen1); lcfg = kzalloc(data->ioc_plen1, GFP_NOFS);
if (lcfg == NULL) { if (lcfg == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
...@@ -243,7 +243,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) ...@@ -243,7 +243,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
if (!err) if (!err)
err = class_process_config(lcfg); err = class_process_config(lcfg);
OBD_FREE(lcfg, data->ioc_plen1); kfree(lcfg);
goto out; goto out;
} }
......
...@@ -171,13 +171,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, ...@@ -171,13 +171,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
} }
rc = -ENOMEM; rc = -ENOMEM;
OBD_ALLOC(type, sizeof(*type)); type = kzalloc(sizeof(*type), GFP_NOFS);
if (type == NULL) if (type == NULL)
return rc; return rc;
OBD_ALLOC_PTR(type->typ_dt_ops); type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
OBD_ALLOC_PTR(type->typ_md_ops); type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
OBD_ALLOC(type->typ_name, strlen(name) + 1); type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
if (type->typ_dt_ops == NULL || if (type->typ_dt_ops == NULL ||
type->typ_md_ops == NULL || type->typ_md_ops == NULL ||
...@@ -214,12 +214,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, ...@@ -214,12 +214,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
failed: failed:
if (type->typ_name != NULL) if (type->typ_name != NULL)
OBD_FREE(type->typ_name, strlen(name) + 1); kfree(type->typ_name);
if (type->typ_md_ops != NULL) if (type->typ_md_ops != NULL)
OBD_FREE_PTR(type->typ_md_ops); kfree(type->typ_md_ops);
if (type->typ_dt_ops != NULL) if (type->typ_dt_ops != NULL)
OBD_FREE_PTR(type->typ_dt_ops); kfree(type->typ_dt_ops);
OBD_FREE(type, sizeof(*type)); kfree(type);
return rc; return rc;
} }
EXPORT_SYMBOL(class_register_type); EXPORT_SYMBOL(class_register_type);
...@@ -237,8 +237,8 @@ int class_unregister_type(const char *name) ...@@ -237,8 +237,8 @@ int class_unregister_type(const char *name)
CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt);
/* This is a bad situation, let's make the best of it */ /* This is a bad situation, let's make the best of it */
/* Remove ops, but leave the name for debugging */ /* Remove ops, but leave the name for debugging */
OBD_FREE_PTR(type->typ_dt_ops); kfree(type->typ_dt_ops);
OBD_FREE_PTR(type->typ_md_ops); kfree(type->typ_md_ops);
return -EBUSY; return -EBUSY;
} }
...@@ -252,12 +252,12 @@ int class_unregister_type(const char *name) ...@@ -252,12 +252,12 @@ int class_unregister_type(const char *name)
spin_lock(&obd_types_lock); spin_lock(&obd_types_lock);
list_del(&type->typ_chain); list_del(&type->typ_chain);
spin_unlock(&obd_types_lock); spin_unlock(&obd_types_lock);
OBD_FREE(type->typ_name, strlen(name) + 1); kfree(type->typ_name);
if (type->typ_dt_ops != NULL) if (type->typ_dt_ops != NULL)
OBD_FREE_PTR(type->typ_dt_ops); kfree(type->typ_dt_ops);
if (type->typ_md_ops != NULL) if (type->typ_md_ops != NULL)
OBD_FREE_PTR(type->typ_md_ops); kfree(type->typ_md_ops);
OBD_FREE(type, sizeof(*type)); kfree(type);
return 0; return 0;
} /* class_unregister_type */ } /* class_unregister_type */
EXPORT_SYMBOL(class_unregister_type); EXPORT_SYMBOL(class_unregister_type);
...@@ -819,7 +819,7 @@ struct obd_export *class_new_export(struct obd_device *obd, ...@@ -819,7 +819,7 @@ struct obd_export *class_new_export(struct obd_device *obd,
struct cfs_hash *hash = NULL; struct cfs_hash *hash = NULL;
int rc = 0; int rc = 0;
OBD_ALLOC_PTR(export); export = kzalloc(sizeof(*export), GFP_NOFS);
if (!export) if (!export)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -904,7 +904,7 @@ struct obd_export *class_new_export(struct obd_device *obd, ...@@ -904,7 +904,7 @@ struct obd_export *class_new_export(struct obd_device *obd,
class_handle_unhash(&export->exp_handle); class_handle_unhash(&export->exp_handle);
LASSERT(hlist_unhashed(&export->exp_uuid_hash)); LASSERT(hlist_unhashed(&export->exp_uuid_hash));
obd_destroy_export(export); obd_destroy_export(export);
OBD_FREE_PTR(export); kfree(export);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
EXPORT_SYMBOL(class_new_export); EXPORT_SYMBOL(class_new_export);
...@@ -945,7 +945,7 @@ static void class_import_destroy(struct obd_import *imp) ...@@ -945,7 +945,7 @@ static void class_import_destroy(struct obd_import *imp)
struct obd_import_conn, oic_item); struct obd_import_conn, oic_item);
list_del_init(&imp_conn->oic_item); list_del_init(&imp_conn->oic_item);
ptlrpc_put_connection_superhack(imp_conn->oic_conn); ptlrpc_put_connection_superhack(imp_conn->oic_conn);
OBD_FREE(imp_conn, sizeof(*imp_conn)); kfree(imp_conn);
} }
LASSERT(imp->imp_sec == NULL); LASSERT(imp->imp_sec == NULL);
...@@ -1008,7 +1008,7 @@ struct obd_import *class_new_import(struct obd_device *obd) ...@@ -1008,7 +1008,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
{ {
struct obd_import *imp; struct obd_import *imp;
OBD_ALLOC(imp, sizeof(*imp)); imp = kzalloc(sizeof(*imp), GFP_NOFS);
if (imp == NULL) if (imp == NULL)
return NULL; return NULL;
...@@ -1811,7 +1811,7 @@ void *kuc_alloc(int payload_len, int transport, int type) ...@@ -1811,7 +1811,7 @@ void *kuc_alloc(int payload_len, int transport, int type)
struct kuc_hdr *lh; struct kuc_hdr *lh;
int len = kuc_len(payload_len); int len = kuc_len(payload_len);
OBD_ALLOC(lh, len); lh = kzalloc(len, GFP_NOFS);
if (lh == NULL) if (lh == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1828,6 +1828,6 @@ EXPORT_SYMBOL(kuc_alloc); ...@@ -1828,6 +1828,6 @@ EXPORT_SYMBOL(kuc_alloc);
inline void kuc_free(void *p, int payload_len) inline void kuc_free(void *p, int payload_len)
{ {
struct kuc_hdr *lh = kuc_ptr(p); struct kuc_hdr *lh = kuc_ptr(p);
OBD_FREE(lh, kuc_len(payload_len)); kfree(lh);
} }
EXPORT_SYMBOL(kuc_free); EXPORT_SYMBOL(kuc_free);
...@@ -60,7 +60,7 @@ static struct llog_handle *llog_alloc_handle(void) ...@@ -60,7 +60,7 @@ static struct llog_handle *llog_alloc_handle(void)
{ {
struct llog_handle *loghandle; struct llog_handle *loghandle;
OBD_ALLOC_PTR(loghandle); loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS);
if (loghandle == NULL) if (loghandle == NULL)
return NULL; return NULL;
...@@ -88,9 +88,9 @@ static void llog_free_handle(struct llog_handle *loghandle) ...@@ -88,9 +88,9 @@ static void llog_free_handle(struct llog_handle *loghandle)
else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
LASSERT(list_empty(&loghandle->u.chd.chd_head)); LASSERT(list_empty(&loghandle->u.chd.chd_head));
LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE); LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE);
OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE); kfree(loghandle->lgh_hdr);
out: out:
OBD_FREE_PTR(loghandle); kfree(loghandle);
} }
void llog_handle_get(struct llog_handle *loghandle) void llog_handle_get(struct llog_handle *loghandle)
...@@ -207,7 +207,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, ...@@ -207,7 +207,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
LASSERT(handle->lgh_hdr == NULL); LASSERT(handle->lgh_hdr == NULL);
OBD_ALLOC_PTR(llh); llh = kzalloc(sizeof(*llh), GFP_NOFS);
if (llh == NULL) if (llh == NULL)
return -ENOMEM; return -ENOMEM;
handle->lgh_hdr = llh; handle->lgh_hdr = llh;
...@@ -261,7 +261,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, ...@@ -261,7 +261,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
} }
out: out:
if (rc) { if (rc) {
OBD_FREE_PTR(llh); kfree(llh);
handle->lgh_hdr = NULL; handle->lgh_hdr = NULL;
} }
return rc; return rc;
...@@ -283,7 +283,7 @@ static int llog_process_thread(void *arg) ...@@ -283,7 +283,7 @@ static int llog_process_thread(void *arg)
LASSERT(llh); LASSERT(llh);
OBD_ALLOC(buf, LLOG_CHUNK_SIZE); buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS);
if (!buf) { if (!buf) {
lpi->lpi_rc = -ENOMEM; lpi->lpi_rc = -ENOMEM;
return 0; return 0;
...@@ -400,7 +400,7 @@ static int llog_process_thread(void *arg) ...@@ -400,7 +400,7 @@ static int llog_process_thread(void *arg)
if (cd != NULL) if (cd != NULL)
cd->lpcd_last_idx = last_called_index; cd->lpcd_last_idx = last_called_index;
OBD_FREE(buf, LLOG_CHUNK_SIZE); kfree(buf);
lpi->lpi_rc = rc; lpi->lpi_rc = rc;
return 0; return 0;
} }
...@@ -434,7 +434,7 @@ int llog_process_or_fork(const struct lu_env *env, ...@@ -434,7 +434,7 @@ int llog_process_or_fork(const struct lu_env *env,
struct llog_process_info *lpi; struct llog_process_info *lpi;
int rc; int rc;
OBD_ALLOC_PTR(lpi); lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
if (lpi == NULL) { if (lpi == NULL) {
CERROR("cannot alloc pointer\n"); CERROR("cannot alloc pointer\n");
return -ENOMEM; return -ENOMEM;
...@@ -454,7 +454,7 @@ int llog_process_or_fork(const struct lu_env *env, ...@@ -454,7 +454,7 @@ int llog_process_or_fork(const struct lu_env *env,
if (IS_ERR_VALUE(rc)) { if (IS_ERR_VALUE(rc)) {
CERROR("%s: cannot start thread: rc = %d\n", CERROR("%s: cannot start thread: rc = %d\n",
loghandle->lgh_ctxt->loc_obd->obd_name, rc); loghandle->lgh_ctxt->loc_obd->obd_name, rc);
OBD_FREE_PTR(lpi); kfree(lpi);
return rc; return rc;
} }
wait_for_completion(&lpi->lpi_completion); wait_for_completion(&lpi->lpi_completion);
...@@ -463,7 +463,7 @@ int llog_process_or_fork(const struct lu_env *env, ...@@ -463,7 +463,7 @@ int llog_process_or_fork(const struct lu_env *env,
llog_process_thread(lpi); llog_process_thread(lpi);
} }
rc = lpi->lpi_rc; rc = lpi->lpi_rc;
OBD_FREE_PTR(lpi); kfree(lpi);
return rc; return rc;
} }
EXPORT_SYMBOL(llog_process_or_fork); EXPORT_SYMBOL(llog_process_or_fork);
...@@ -484,7 +484,7 @@ int llog_reverse_process(const struct lu_env *env, ...@@ -484,7 +484,7 @@ int llog_reverse_process(const struct lu_env *env,
void *buf; void *buf;
int rc = 0, first_index = 1, index, idx; int rc = 0, first_index = 1, index, idx;
OBD_ALLOC(buf, LLOG_CHUNK_SIZE); buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -564,7 +564,7 @@ int llog_reverse_process(const struct lu_env *env, ...@@ -564,7 +564,7 @@ int llog_reverse_process(const struct lu_env *env,
out: out:
if (buf) if (buf)
OBD_FREE(buf, LLOG_CHUNK_SIZE); kfree(buf);
return rc; return rc;
} }
EXPORT_SYMBOL(llog_reverse_process); EXPORT_SYMBOL(llog_reverse_process);
......
...@@ -46,7 +46,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd) ...@@ -46,7 +46,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd)
{ {
struct llog_ctxt *ctxt; struct llog_ctxt *ctxt;
OBD_ALLOC_PTR(ctxt); ctxt = kzalloc(sizeof(*ctxt), GFP_NOFS);
if (!ctxt) if (!ctxt)
return NULL; return NULL;
...@@ -66,7 +66,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt) ...@@ -66,7 +66,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt)
class_import_put(ctxt->loc_imp); class_import_put(ctxt->loc_imp);
ctxt->loc_imp = NULL; ctxt->loc_imp = NULL;
} }
OBD_FREE_PTR(ctxt); kfree(ctxt);
} }
int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt)
......
...@@ -276,7 +276,7 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name, ...@@ -276,7 +276,7 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name,
if (parent == NULL || format == NULL) if (parent == NULL || format == NULL)
return NULL; return NULL;
OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1); dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL);
if (dest == NULL) if (dest == NULL)
return NULL; return NULL;
...@@ -289,7 +289,7 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name, ...@@ -289,7 +289,7 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name,
CERROR("LprocFS: Could not create symbolic link from %s to %s", CERROR("LprocFS: Could not create symbolic link from %s to %s",
name, dest); name, dest);
OBD_FREE(dest, MAX_STRING_SIZE + 1); kfree(dest);
return entry; return entry;
} }
EXPORT_SYMBOL(lprocfs_add_symlink); EXPORT_SYMBOL(lprocfs_add_symlink);
...@@ -1006,7 +1006,7 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat) ...@@ -1006,7 +1006,7 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat)
if (client_stat->nid_ldlm_stats) if (client_stat->nid_ldlm_stats)
lprocfs_free_stats(&client_stat->nid_ldlm_stats); lprocfs_free_stats(&client_stat->nid_ldlm_stats);
OBD_FREE_PTR(client_stat); kfree(client_stat);
return; return;
} }
...@@ -1681,7 +1681,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) ...@@ -1681,7 +1681,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash); CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
OBD_ALLOC_PTR(new_stat); new_stat = kzalloc(sizeof(*new_stat), GFP_NOFS);
if (new_stat == NULL) if (new_stat == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1711,7 +1711,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) ...@@ -1711,7 +1711,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
goto destroy_new; goto destroy_new;
} }
/* not found - create */ /* not found - create */
OBD_ALLOC(buffer, LNET_NIDSTR_SIZE); buffer = kzalloc(LNET_NIDSTR_SIZE, GFP_NOFS);
if (buffer == NULL) { if (buffer == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto destroy_new; goto destroy_new;
...@@ -1721,7 +1721,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) ...@@ -1721,7 +1721,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
new_stat->nid_proc = lprocfs_register(buffer, new_stat->nid_proc = lprocfs_register(buffer,
obd->obd_proc_exports_entry, obd->obd_proc_exports_entry,
NULL, NULL); NULL, NULL);
OBD_FREE(buffer, LNET_NIDSTR_SIZE); kfree(buffer);
if (IS_ERR(new_stat->nid_proc)) { if (IS_ERR(new_stat->nid_proc)) {
CERROR("Error making export directory for nid %s\n", CERROR("Error making export directory for nid %s\n",
...@@ -1763,7 +1763,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) ...@@ -1763,7 +1763,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
destroy_new: destroy_new:
nidstat_putref(new_stat); nidstat_putref(new_stat);
OBD_FREE_PTR(new_stat); kfree(new_stat);
return rc; return rc;
} }
EXPORT_SYMBOL(lprocfs_exp_setup); EXPORT_SYMBOL(lprocfs_exp_setup);
......
...@@ -1532,7 +1532,7 @@ static void keys_fini(struct lu_context *ctx) ...@@ -1532,7 +1532,7 @@ static void keys_fini(struct lu_context *ctx)
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) for (i = 0; i < ARRAY_SIZE(lu_keys); ++i)
key_fini(ctx, i); key_fini(ctx, i);
OBD_FREE(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0])); kfree(ctx->lc_value);
ctx->lc_value = NULL; ctx->lc_value = NULL;
} }
...@@ -1581,8 +1581,8 @@ static int keys_fill(struct lu_context *ctx) ...@@ -1581,8 +1581,8 @@ static int keys_fill(struct lu_context *ctx)
static int keys_init(struct lu_context *ctx) static int keys_init(struct lu_context *ctx)
{ {
OBD_ALLOC(ctx->lc_value, ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]),
ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0])); GFP_NOFS);
if (likely(ctx->lc_value != NULL)) if (likely(ctx->lc_value != NULL))
return keys_fill(ctx); return keys_fill(ctx);
......
...@@ -186,7 +186,7 @@ void class_handle_free_cb(struct rcu_head *rcu) ...@@ -186,7 +186,7 @@ void class_handle_free_cb(struct rcu_head *rcu)
if (h->h_ops->hop_free != NULL) if (h->h_ops->hop_free != NULL)
h->h_ops->hop_free(ptr, h->h_size); h->h_ops->hop_free(ptr, h->h_size);
else else
OBD_FREE(ptr, h->h_size); kfree(ptr);
} }
EXPORT_SYMBOL(class_handle_free_cb); EXPORT_SYMBOL(class_handle_free_cb);
......
...@@ -104,7 +104,7 @@ int class_add_uuid(const char *uuid, __u64 nid) ...@@ -104,7 +104,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
if (strlen(uuid) > UUID_MAX - 1) if (strlen(uuid) > UUID_MAX - 1)
return -EOVERFLOW; return -EOVERFLOW;
OBD_ALLOC_PTR(data); data = kzalloc(sizeof(*data), GFP_NOFS);
if (data == NULL) if (data == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -136,7 +136,7 @@ int class_add_uuid(const char *uuid, __u64 nid) ...@@ -136,7 +136,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
if (found) { if (found) {
CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid, CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
libcfs_nid2str(nid), entry->un_nid_count); libcfs_nid2str(nid), entry->un_nid_count);
OBD_FREE(data, sizeof(*data)); kfree(data);
} else { } else {
CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid)); CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid));
} }
...@@ -180,7 +180,7 @@ int class_del_uuid(const char *uuid) ...@@ -180,7 +180,7 @@ int class_del_uuid(const char *uuid)
libcfs_nid2str(data->un_nids[0]), libcfs_nid2str(data->un_nids[0]),
data->un_nid_count); data->un_nid_count);
OBD_FREE(data, sizeof(*data)); kfree(data);
} }
return 0; return 0;
......
...@@ -860,13 +860,13 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, ...@@ -860,13 +860,13 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
CDEBUG(D_CONFIG, "Add profile %s\n", prof); CDEBUG(D_CONFIG, "Add profile %s\n", prof);
OBD_ALLOC(lprof, sizeof(*lprof)); lprof = kzalloc(sizeof(*lprof), GFP_NOFS);
if (lprof == NULL) if (lprof == NULL)
return -ENOMEM; return -ENOMEM;
INIT_LIST_HEAD(&lprof->lp_list); INIT_LIST_HEAD(&lprof->lp_list);
LASSERT(proflen == (strlen(prof) + 1)); LASSERT(proflen == (strlen(prof) + 1));
OBD_ALLOC(lprof->lp_profile, proflen); lprof->lp_profile = kzalloc(proflen, GFP_NOFS);
if (lprof->lp_profile == NULL) { if (lprof->lp_profile == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
...@@ -874,7 +874,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, ...@@ -874,7 +874,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
memcpy(lprof->lp_profile, prof, proflen); memcpy(lprof->lp_profile, prof, proflen);
LASSERT(osclen == (strlen(osc) + 1)); LASSERT(osclen == (strlen(osc) + 1));
OBD_ALLOC(lprof->lp_dt, osclen); lprof->lp_dt = kzalloc(osclen, GFP_NOFS);
if (lprof->lp_dt == NULL) { if (lprof->lp_dt == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
...@@ -883,7 +883,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, ...@@ -883,7 +883,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
if (mdclen > 0) { if (mdclen > 0) {
LASSERT(mdclen == (strlen(mdc) + 1)); LASSERT(mdclen == (strlen(mdc) + 1));
OBD_ALLOC(lprof->lp_md, mdclen); lprof->lp_md = kzalloc(mdclen, GFP_NOFS);
if (lprof->lp_md == NULL) { if (lprof->lp_md == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
...@@ -896,12 +896,12 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, ...@@ -896,12 +896,12 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
out: out:
if (lprof->lp_md) if (lprof->lp_md)
OBD_FREE(lprof->lp_md, mdclen); kfree(lprof->lp_md);
if (lprof->lp_dt) if (lprof->lp_dt)
OBD_FREE(lprof->lp_dt, osclen); kfree(lprof->lp_dt);
if (lprof->lp_profile) if (lprof->lp_profile)
OBD_FREE(lprof->lp_profile, proflen); kfree(lprof->lp_profile);
OBD_FREE(lprof, sizeof(*lprof)); kfree(lprof);
return err; return err;
} }
...@@ -914,11 +914,11 @@ void class_del_profile(const char *prof) ...@@ -914,11 +914,11 @@ void class_del_profile(const char *prof)
lprof = class_get_profile(prof); lprof = class_get_profile(prof);
if (lprof) { if (lprof) {
list_del(&lprof->lp_list); list_del(&lprof->lp_list);
OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); kfree(lprof->lp_profile);
OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1); kfree(lprof->lp_dt);
if (lprof->lp_md) if (lprof->lp_md)
OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); kfree(lprof->lp_md);
OBD_FREE(lprof, sizeof(*lprof)); kfree(lprof);
} }
} }
EXPORT_SYMBOL(class_del_profile); EXPORT_SYMBOL(class_del_profile);
...@@ -930,11 +930,11 @@ void class_del_profiles(void) ...@@ -930,11 +930,11 @@ void class_del_profiles(void)
list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) { list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) {
list_del(&lprof->lp_list); list_del(&lprof->lp_list);
OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); kfree(lprof->lp_profile);
OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1); kfree(lprof->lp_dt);
if (lprof->lp_md) if (lprof->lp_md)
OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); kfree(lprof->lp_md);
OBD_FREE(lprof, sizeof(*lprof)); kfree(lprof);
} }
} }
EXPORT_SYMBOL(class_del_profiles); EXPORT_SYMBOL(class_del_profiles);
...@@ -1011,7 +1011,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, ...@@ -1011,7 +1011,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len; new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len;
OBD_ALLOC(new_param, new_len); new_param = kzalloc(new_len, GFP_NOFS);
if (new_param == NULL) if (new_param == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1019,9 +1019,9 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, ...@@ -1019,9 +1019,9 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
if (value != NULL) if (value != NULL)
strcat(new_param, value); strcat(new_param, value);
OBD_ALLOC_PTR(bufs); bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
if (bufs == NULL) { if (bufs == NULL) {
OBD_FREE(new_param, new_len); kfree(new_param);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
...@@ -1031,8 +1031,8 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, ...@@ -1031,8 +1031,8 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs); new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs);
OBD_FREE(new_param, new_len); kfree(new_param);
OBD_FREE_PTR(bufs); kfree(bufs);
if (new_cfg == NULL) if (new_cfg == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1493,7 +1493,7 @@ int class_config_llog_handler(const struct lu_env *env, ...@@ -1493,7 +1493,7 @@ int class_config_llog_handler(const struct lu_env *env,
inst = 1; inst = 1;
inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
sizeof(clli->cfg_instance) * 2 + 4; sizeof(clli->cfg_instance) * 2 + 4;
OBD_ALLOC(inst_name, inst_len); inst_name = kzalloc(inst_len, GFP_NOFS);
if (inst_name == NULL) { if (inst_name == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -1556,7 +1556,7 @@ int class_config_llog_handler(const struct lu_env *env, ...@@ -1556,7 +1556,7 @@ int class_config_llog_handler(const struct lu_env *env,
lustre_cfg_free(lcfg_new); lustre_cfg_free(lcfg_new);
if (inst) if (inst)
OBD_FREE(inst_name, inst_len); kfree(inst_name);
break; break;
} }
default: default:
...@@ -1671,7 +1671,7 @@ int class_config_dump_handler(const struct lu_env *env, ...@@ -1671,7 +1671,7 @@ int class_config_dump_handler(const struct lu_env *env,
char *outstr; char *outstr;
int rc = 0; int rc = 0;
OBD_ALLOC(outstr, 256); outstr = kzalloc(256, GFP_NOFS);
if (outstr == NULL) if (outstr == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1683,7 +1683,7 @@ int class_config_dump_handler(const struct lu_env *env, ...@@ -1683,7 +1683,7 @@ int class_config_dump_handler(const struct lu_env *env,
rc = -EINVAL; rc = -EINVAL;
} }
OBD_FREE(outstr, 256); kfree(outstr);
return rc; return rc;
} }
......
...@@ -84,7 +84,7 @@ int lustre_process_log(struct super_block *sb, char *logname, ...@@ -84,7 +84,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
LASSERT(mgc); LASSERT(mgc);
LASSERT(cfg); LASSERT(cfg);
OBD_ALLOC_PTR(bufs); bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
if (bufs == NULL) if (bufs == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -97,7 +97,7 @@ int lustre_process_log(struct super_block *sb, char *logname, ...@@ -97,7 +97,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
lustre_cfg_free(lcfg); lustre_cfg_free(lcfg);
OBD_FREE_PTR(bufs); kfree(bufs);
if (rc == -EINVAL) if (rc == -EINVAL)
LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n", LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n",
...@@ -247,8 +247,8 @@ int lustre_start_mgc(struct super_block *sb) ...@@ -247,8 +247,8 @@ int lustre_start_mgc(struct super_block *sb)
mutex_lock(&mgc_start_lock); mutex_lock(&mgc_start_lock);
len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1; len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1;
OBD_ALLOC(mgcname, len); mgcname = kzalloc(len, GFP_NOFS);
OBD_ALLOC(niduuid, len + 2); niduuid = kzalloc(len + 2, GFP_NOFS);
if (!mgcname || !niduuid) { if (!mgcname || !niduuid) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_free; goto out_free;
...@@ -257,7 +257,7 @@ int lustre_start_mgc(struct super_block *sb) ...@@ -257,7 +257,7 @@ int lustre_start_mgc(struct super_block *sb)
mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : ""; mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
OBD_ALLOC_PTR(data); data = kzalloc(sizeof(*data), GFP_NOFS);
if (data == NULL) { if (data == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_free; goto out_free;
...@@ -375,7 +375,7 @@ int lustre_start_mgc(struct super_block *sb) ...@@ -375,7 +375,7 @@ int lustre_start_mgc(struct super_block *sb)
lsi->lsi_lmd->lmd_mgs_failnodes = 1; lsi->lsi_lmd->lmd_mgs_failnodes = 1;
/* Random uuid for MGC allows easier reconnects */ /* Random uuid for MGC allows easier reconnects */
OBD_ALLOC_PTR(uuid); uuid = kzalloc(sizeof(*uuid), GFP_NOFS);
if (!uuid) { if (!uuid) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_free; goto out_free;
...@@ -388,7 +388,7 @@ int lustre_start_mgc(struct super_block *sb) ...@@ -388,7 +388,7 @@ int lustre_start_mgc(struct super_block *sb)
rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
(char *)uuid->uuid, LUSTRE_MGS_OBDNAME, (char *)uuid->uuid, LUSTRE_MGS_OBDNAME,
niduuid, NULL, NULL); niduuid, NULL, NULL);
OBD_FREE_PTR(uuid); kfree(uuid);
if (rc) if (rc)
goto out_free; goto out_free;
...@@ -465,11 +465,11 @@ int lustre_start_mgc(struct super_block *sb) ...@@ -465,11 +465,11 @@ int lustre_start_mgc(struct super_block *sb)
mutex_unlock(&mgc_start_lock); mutex_unlock(&mgc_start_lock);
if (data) if (data)
OBD_FREE_PTR(data); kfree(data);
if (mgcname) if (mgcname)
OBD_FREE(mgcname, len); kfree(mgcname);
if (niduuid) if (niduuid)
OBD_FREE(niduuid, len + 2); kfree(niduuid);
return rc; return rc;
} }
...@@ -513,7 +513,7 @@ static int lustre_stop_mgc(struct super_block *sb) ...@@ -513,7 +513,7 @@ static int lustre_stop_mgc(struct super_block *sb)
/* Save the obdname for cleaning the nid uuids, which are /* Save the obdname for cleaning the nid uuids, which are
obdname_XX */ obdname_XX */
len = strlen(obd->obd_name) + 6; len = strlen(obd->obd_name) + 6;
OBD_ALLOC(niduuid, len); niduuid = kzalloc(len, GFP_NOFS);
if (niduuid) { if (niduuid) {
strcpy(niduuid, obd->obd_name); strcpy(niduuid, obd->obd_name);
ptr = niduuid + strlen(niduuid); ptr = niduuid + strlen(niduuid);
...@@ -539,7 +539,7 @@ static int lustre_stop_mgc(struct super_block *sb) ...@@ -539,7 +539,7 @@ static int lustre_stop_mgc(struct super_block *sb)
} }
out: out:
if (niduuid) if (niduuid)
OBD_FREE(niduuid, len); kfree(niduuid);
/* class_import_put will get rid of the additional connections */ /* class_import_put will get rid of the additional connections */
mutex_unlock(&mgc_start_lock); mutex_unlock(&mgc_start_lock);
...@@ -552,12 +552,12 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) ...@@ -552,12 +552,12 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
{ {
struct lustre_sb_info *lsi; struct lustre_sb_info *lsi;
OBD_ALLOC_PTR(lsi); lsi = kzalloc(sizeof(*lsi), GFP_NOFS);
if (!lsi) if (!lsi)
return NULL; return NULL;
OBD_ALLOC_PTR(lsi->lsi_lmd); lsi->lsi_lmd = kzalloc(sizeof(*lsi->lsi_lmd), GFP_NOFS);
if (!lsi->lsi_lmd) { if (!lsi->lsi_lmd) {
OBD_FREE_PTR(lsi); kfree(lsi);
return NULL; return NULL;
} }
...@@ -586,35 +586,27 @@ static int lustre_free_lsi(struct super_block *sb) ...@@ -586,35 +586,27 @@ static int lustre_free_lsi(struct super_block *sb)
if (lsi->lsi_lmd != NULL) { if (lsi->lsi_lmd != NULL) {
if (lsi->lsi_lmd->lmd_dev != NULL) if (lsi->lsi_lmd->lmd_dev != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_dev, kfree(lsi->lsi_lmd->lmd_dev);
strlen(lsi->lsi_lmd->lmd_dev) + 1);
if (lsi->lsi_lmd->lmd_profile != NULL) if (lsi->lsi_lmd->lmd_profile != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_profile, kfree(lsi->lsi_lmd->lmd_profile);
strlen(lsi->lsi_lmd->lmd_profile) + 1);
if (lsi->lsi_lmd->lmd_mgssec != NULL) if (lsi->lsi_lmd->lmd_mgssec != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_mgssec, kfree(lsi->lsi_lmd->lmd_mgssec);
strlen(lsi->lsi_lmd->lmd_mgssec) + 1);
if (lsi->lsi_lmd->lmd_opts != NULL) if (lsi->lsi_lmd->lmd_opts != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_opts, kfree(lsi->lsi_lmd->lmd_opts);
strlen(lsi->lsi_lmd->lmd_opts) + 1);
if (lsi->lsi_lmd->lmd_exclude_count) if (lsi->lsi_lmd->lmd_exclude_count)
OBD_FREE(lsi->lsi_lmd->lmd_exclude, kfree(lsi->lsi_lmd->lmd_exclude);
sizeof(lsi->lsi_lmd->lmd_exclude[0]) *
lsi->lsi_lmd->lmd_exclude_count);
if (lsi->lsi_lmd->lmd_mgs != NULL) if (lsi->lsi_lmd->lmd_mgs != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_mgs, kfree(lsi->lsi_lmd->lmd_mgs);
strlen(lsi->lsi_lmd->lmd_mgs) + 1);
if (lsi->lsi_lmd->lmd_osd_type != NULL) if (lsi->lsi_lmd->lmd_osd_type != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_osd_type, kfree(lsi->lsi_lmd->lmd_osd_type);
strlen(lsi->lsi_lmd->lmd_osd_type) + 1);
if (lsi->lsi_lmd->lmd_params != NULL) if (lsi->lsi_lmd->lmd_params != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_params, 4096); kfree(lsi->lsi_lmd->lmd_params);
OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd)); kfree(lsi->lsi_lmd);
} }
LASSERT(lsi->lsi_llsbi == NULL); LASSERT(lsi->lsi_llsbi == NULL);
OBD_FREE(lsi, sizeof(*lsi)); kfree(lsi);
s2lsi_nocast(sb) = NULL; s2lsi_nocast(sb) = NULL;
return 0; return 0;
...@@ -846,7 +838,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) ...@@ -846,7 +838,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
devmax = strlen(ptr) / 8 + 1; devmax = strlen(ptr) / 8 + 1;
/* temp storage until we figure out how many we have */ /* temp storage until we figure out how many we have */
OBD_ALLOC(exclude_list, sizeof(index) * devmax); exclude_list = kcalloc(devmax, sizeof(index), GFP_NOFS);
if (!exclude_list) if (!exclude_list)
return -ENOMEM; return -ENOMEM;
...@@ -875,8 +867,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) ...@@ -875,8 +867,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
if (lmd->lmd_exclude_count) { if (lmd->lmd_exclude_count) {
/* permanent, freed in lustre_free_lsi */ /* permanent, freed in lustre_free_lsi */
OBD_ALLOC(lmd->lmd_exclude, sizeof(index) * lmd->lmd_exclude = kcalloc(lmd->lmd_exclude_count,
lmd->lmd_exclude_count); sizeof(index), GFP_NOFS);
if (lmd->lmd_exclude) { if (lmd->lmd_exclude) {
memcpy(lmd->lmd_exclude, exclude_list, memcpy(lmd->lmd_exclude, exclude_list,
sizeof(index) * lmd->lmd_exclude_count); sizeof(index) * lmd->lmd_exclude_count);
...@@ -885,7 +877,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) ...@@ -885,7 +877,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
lmd->lmd_exclude_count = 0; lmd->lmd_exclude_count = 0;
} }
} }
OBD_FREE(exclude_list, sizeof(index) * devmax); kfree(exclude_list);
return rc; return rc;
} }
...@@ -895,7 +887,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) ...@@ -895,7 +887,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
int length; int length;
if (lmd->lmd_mgssec != NULL) { if (lmd->lmd_mgssec != NULL) {
OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1); kfree(lmd->lmd_mgssec);
lmd->lmd_mgssec = NULL; lmd->lmd_mgssec = NULL;
} }
...@@ -905,7 +897,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) ...@@ -905,7 +897,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
else else
length = tail - ptr; length = tail - ptr;
OBD_ALLOC(lmd->lmd_mgssec, length + 1); lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS);
if (lmd->lmd_mgssec == NULL) if (lmd->lmd_mgssec == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -923,7 +915,7 @@ static int lmd_parse_string(char **handle, char *ptr) ...@@ -923,7 +915,7 @@ static int lmd_parse_string(char **handle, char *ptr)
return -EINVAL; return -EINVAL;
if (*handle != NULL) { if (*handle != NULL) {
OBD_FREE(*handle, strlen(*handle) + 1); kfree(*handle);
*handle = NULL; *handle = NULL;
} }
...@@ -933,7 +925,7 @@ static int lmd_parse_string(char **handle, char *ptr) ...@@ -933,7 +925,7 @@ static int lmd_parse_string(char **handle, char *ptr)
else else
length = tail - ptr; length = tail - ptr;
OBD_ALLOC(*handle, length + 1); *handle = kzalloc(length + 1, GFP_NOFS);
if (*handle == NULL) if (*handle == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -963,7 +955,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) ...@@ -963,7 +955,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
if (lmd->lmd_mgs != NULL) if (lmd->lmd_mgs != NULL)
oldlen = strlen(lmd->lmd_mgs) + 1; oldlen = strlen(lmd->lmd_mgs) + 1;
OBD_ALLOC(mgsnid, oldlen + length + 1); mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS);
if (mgsnid == NULL) if (mgsnid == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -971,7 +963,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) ...@@ -971,7 +963,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
/* Multiple mgsnid= are taken to mean failover locations */ /* Multiple mgsnid= are taken to mean failover locations */
memcpy(mgsnid, lmd->lmd_mgs, oldlen); memcpy(mgsnid, lmd->lmd_mgs, oldlen);
mgsnid[oldlen - 1] = ':'; mgsnid[oldlen - 1] = ':';
OBD_FREE(lmd->lmd_mgs, oldlen); kfree(lmd->lmd_mgs);
} }
memcpy(mgsnid + oldlen, *ptr, length); memcpy(mgsnid + oldlen, *ptr, length);
mgsnid[oldlen + length] = '\0'; mgsnid[oldlen + length] = '\0';
...@@ -1005,7 +997,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) ...@@ -1005,7 +997,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
} }
lmd->lmd_magic = LMD_MAGIC; lmd->lmd_magic = LMD_MAGIC;
OBD_ALLOC(lmd->lmd_params, 4096); lmd->lmd_params = kzalloc(4096, GFP_NOFS);
if (lmd->lmd_params == NULL) if (lmd->lmd_params == NULL)
return -ENOMEM; return -ENOMEM;
lmd->lmd_params[0] = '\0'; lmd->lmd_params[0] = '\0';
...@@ -1143,14 +1135,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) ...@@ -1143,14 +1135,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
/* Remove leading /s from fsname */ /* Remove leading /s from fsname */
while (*++s1 == '/') ; while (*++s1 == '/') ;
/* Freed in lustre_free_lsi */ /* Freed in lustre_free_lsi */
OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8); lmd->lmd_profile = kzalloc(strlen(s1) + 8, GFP_NOFS);
if (!lmd->lmd_profile) if (!lmd->lmd_profile)
return -ENOMEM; return -ENOMEM;
sprintf(lmd->lmd_profile, "%s-client", s1); sprintf(lmd->lmd_profile, "%s-client", s1);
} }
/* Freed in lustre_free_lsi */ /* Freed in lustre_free_lsi */
OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1); lmd->lmd_dev = kzalloc(strlen(devname) + 1, GFP_NOFS);
if (!lmd->lmd_dev) if (!lmd->lmd_dev)
return -ENOMEM; return -ENOMEM;
strcpy(lmd->lmd_dev, devname); strcpy(lmd->lmd_dev, devname);
...@@ -1161,7 +1153,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) ...@@ -1161,7 +1153,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
*s1-- = 0; *s1-- = 0;
if (*options != 0) { if (*options != 0) {
/* Freed in lustre_free_lsi */ /* Freed in lustre_free_lsi */
OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1); lmd->lmd_opts = kzalloc(strlen(options) + 1, GFP_NOFS);
if (!lmd->lmd_opts) if (!lmd->lmd_opts)
return -ENOMEM; return -ENOMEM;
strcpy(lmd->lmd_opts, options); strcpy(lmd->lmd_opts, options);
......
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