Commit 8210132b authored by Amitoj Kaur Chawla's avatar Amitoj Kaur Chawla Committed by Greg Kroah-Hartman

staging: lustre: lov: Replace kmem_cache_alloc with kmem_cache_zalloc

Use kmem_cache_zalloc instead of manually setting kmem_cache_alloc
with flag GFP_ZERO since kmem_alloc_zalloc sets allocated memory
to zero.

The Coccinelle semantic patch used to make this change is as
follows:
// <smpl>
@@
expression e,f;
@@
- kmem_cache_alloc(e, f |__GFP_ZERO)
+ kmem_cache_zalloc(e, f)
// </smpl>
Signed-off-by: default avatarAmitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 99815cb5
...@@ -142,7 +142,7 @@ static void *lov_key_init(const struct lu_context *ctx, ...@@ -142,7 +142,7 @@ static void *lov_key_init(const struct lu_context *ctx,
{ {
struct lov_thread_info *info; struct lov_thread_info *info;
info = kmem_cache_alloc(lov_thread_kmem, GFP_NOFS | __GFP_ZERO); info = kmem_cache_zalloc(lov_thread_kmem, GFP_NOFS);
if (info) if (info)
INIT_LIST_HEAD(&info->lti_closure.clc_list); INIT_LIST_HEAD(&info->lti_closure.clc_list);
else else
...@@ -170,7 +170,7 @@ static void *lov_session_key_init(const struct lu_context *ctx, ...@@ -170,7 +170,7 @@ static void *lov_session_key_init(const struct lu_context *ctx,
{ {
struct lov_session *info; struct lov_session *info;
info = kmem_cache_alloc(lov_session_kmem, GFP_NOFS | __GFP_ZERO); info = kmem_cache_zalloc(lov_session_kmem, GFP_NOFS);
if (!info) if (!info)
info = ERR_PTR(-ENOMEM); info = ERR_PTR(-ENOMEM);
return info; return info;
...@@ -261,7 +261,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, ...@@ -261,7 +261,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev,
struct lov_req *lr; struct lov_req *lr;
int result; int result;
lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO); lr = kmem_cache_zalloc(lov_req_kmem, GFP_NOFS);
if (lr) { if (lr) {
cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops);
result = 0; result = 0;
......
...@@ -100,7 +100,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) ...@@ -100,7 +100,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size)
return NULL; return NULL;
for (i = 0; i < stripe_count; i++) { for (i = 0; i < stripe_count; i++) {
loi = kmem_cache_alloc(lov_oinfo_slab, GFP_NOFS | __GFP_ZERO); loi = kmem_cache_zalloc(lov_oinfo_slab, GFP_NOFS);
if (!loi) if (!loi)
goto err; goto err;
lsm->lsm_oinfo[i] = loi; lsm->lsm_oinfo[i] = loi;
......
...@@ -144,7 +144,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, ...@@ -144,7 +144,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env,
LASSERT(idx < lck->lls_nr); LASSERT(idx < lck->lls_nr);
link = kmem_cache_alloc(lov_lock_link_kmem, GFP_NOFS | __GFP_ZERO); link = kmem_cache_zalloc(lov_lock_link_kmem, GFP_NOFS);
if (link) { if (link) {
struct lov_sublock_env *subenv; struct lov_sublock_env *subenv;
struct lov_lock_sub *lls; struct lov_lock_sub *lls;
...@@ -1107,7 +1107,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, ...@@ -1107,7 +1107,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj,
struct lov_lock *lck; struct lov_lock *lck;
int result; int result;
lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO); lck = kmem_cache_zalloc(lov_lock_kmem, GFP_NOFS);
if (lck) { if (lck) {
cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops); cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops);
result = lov_lock_sub_init(env, lck, io); result = lov_lock_sub_init(env, lck, io);
...@@ -1144,7 +1144,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, ...@@ -1144,7 +1144,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj,
struct lov_lock *lck; struct lov_lock *lck;
int result = -ENOMEM; int result = -ENOMEM;
lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO); lck = kmem_cache_zalloc(lov_lock_kmem, GFP_NOFS);
if (lck) { if (lck) {
cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops); cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops);
lck->lls_orig = lock->cll_descr; lck->lls_orig = lock->cll_descr;
......
...@@ -899,7 +899,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, ...@@ -899,7 +899,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env,
struct lov_object *lov; struct lov_object *lov;
struct lu_object *obj; struct lu_object *obj;
lov = kmem_cache_alloc(lov_object_kmem, GFP_NOFS | __GFP_ZERO); lov = kmem_cache_zalloc(lov_object_kmem, GFP_NOFS);
if (lov) { if (lov) {
obj = lov2lu(lov); obj = lov2lu(lov);
lu_object_init(obj, NULL, dev); lu_object_init(obj, NULL, dev);
......
...@@ -200,7 +200,7 @@ static int common_attr_done(struct lov_request_set *set) ...@@ -200,7 +200,7 @@ static int common_attr_done(struct lov_request_set *set)
if (!atomic_read(&set->set_success)) if (!atomic_read(&set->set_success))
return -EIO; return -EIO;
tmp_oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); tmp_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
if (!tmp_oa) { if (!tmp_oa) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -307,8 +307,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -307,8 +307,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
req->rq_stripe = i; req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx; req->rq_idx = loi->loi_ost_idx;
req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, req->rq_oi.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
GFP_NOFS | __GFP_ZERO);
if (!req->rq_oi.oi_oa) { if (!req->rq_oi.oi_oa) {
kfree(req); kfree(req);
rc = -ENOMEM; rc = -ENOMEM;
...@@ -390,8 +389,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -390,8 +389,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
req->rq_stripe = i; req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx; req->rq_idx = loi->loi_ost_idx;
req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, req->rq_oi.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
GFP_NOFS | __GFP_ZERO);
if (!req->rq_oi.oi_oa) { if (!req->rq_oi.oi_oa) {
kfree(req); kfree(req);
rc = -ENOMEM; rc = -ENOMEM;
...@@ -507,8 +505,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -507,8 +505,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
req->rq_stripe = i; req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx; req->rq_idx = loi->loi_ost_idx;
req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, req->rq_oi.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
GFP_NOFS | __GFP_ZERO);
if (!req->rq_oi.oi_oa) { if (!req->rq_oi.oi_oa) {
kfree(req); kfree(req);
rc = -ENOMEM; rc = -ENOMEM;
......
...@@ -147,7 +147,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev, ...@@ -147,7 +147,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev,
struct lovsub_req *lsr; struct lovsub_req *lsr;
int result; int result;
lsr = kmem_cache_alloc(lovsub_req_kmem, GFP_NOFS | __GFP_ZERO); lsr = kmem_cache_zalloc(lovsub_req_kmem, GFP_NOFS);
if (lsr) { if (lsr) {
cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops); cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops);
result = 0; result = 0;
......
...@@ -455,7 +455,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, ...@@ -455,7 +455,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj,
struct lovsub_lock *lsk; struct lovsub_lock *lsk;
int result; int result;
lsk = kmem_cache_alloc(lovsub_lock_kmem, GFP_NOFS | __GFP_ZERO); lsk = kmem_cache_zalloc(lovsub_lock_kmem, GFP_NOFS);
if (lsk) { if (lsk) {
INIT_LIST_HEAD(&lsk->lss_parents); INIT_LIST_HEAD(&lsk->lss_parents);
cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops);
......
...@@ -143,7 +143,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, ...@@ -143,7 +143,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env,
struct lovsub_object *los; struct lovsub_object *los;
struct lu_object *obj; struct lu_object *obj;
los = kmem_cache_alloc(lovsub_object_kmem, GFP_NOFS | __GFP_ZERO); los = kmem_cache_zalloc(lovsub_object_kmem, GFP_NOFS);
if (los) { if (los) {
struct cl_object_header *hdr; struct cl_object_header *hdr;
......
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