From: Amitoj Kaur Chawla Date: Fri, 26 Feb 2016 08:54:35 +0000 (+0530) Subject: staging: lustre: lov: Replace kmem_cache_alloc with kmem_cache_zalloc X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=8210132b230e926747596cad1a5ba9d59c08ae82;p=linux-beck.git 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: // @@ expression e,f; @@ - kmem_cache_alloc(e, f |__GFP_ZERO) + kmem_cache_zalloc(e, f) // Signed-off-by: Amitoj Kaur Chawla Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index ee093e09646a..532ef87dfb44 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -142,7 +142,7 @@ static void *lov_key_init(const struct lu_context *ctx, { 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) INIT_LIST_HEAD(&info->lti_closure.clc_list); else @@ -170,7 +170,7 @@ static void *lov_session_key_init(const struct lu_context *ctx, { 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) info = ERR_PTR(-ENOMEM); return info; @@ -261,7 +261,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, struct lov_req *lr; int result; - lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO); + lr = kmem_cache_zalloc(lov_req_kmem, GFP_NOFS); if (lr) { cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); result = 0; diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index cdf4e8e12a4a..b6529401c713 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -100,7 +100,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) return NULL; 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) goto err; lsm->lsm_oinfo[i] = loi; diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 455dad2debc3..1169a8095c60 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -144,7 +144,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, 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) { struct lov_sublock_env *subenv; struct lov_lock_sub *lls; @@ -1107,7 +1107,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result; - lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO); + lck = kmem_cache_zalloc(lov_lock_kmem, GFP_NOFS); if (lck) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops); 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, struct lov_lock *lck; 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) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops); lck->lls_orig = lock->cll_descr; diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 9cea9dcbf57a..1f8ed95a6d89 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -899,7 +899,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, struct lov_object *lov; 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) { obj = lov2lu(lov); lu_object_init(obj, NULL, dev); diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 42660f2c83c1..4f568f0ae839 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -200,7 +200,7 @@ static int common_attr_done(struct lov_request_set *set) if (!atomic_read(&set->set_success)) 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) { rc = -ENOMEM; goto out; @@ -307,8 +307,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, req->rq_stripe = i; req->rq_idx = loi->loi_ost_idx; - req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, - GFP_NOFS | __GFP_ZERO); + req->rq_oi.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS); if (!req->rq_oi.oi_oa) { kfree(req); rc = -ENOMEM; @@ -390,8 +389,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, req->rq_stripe = i; req->rq_idx = loi->loi_ost_idx; - req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, - GFP_NOFS | __GFP_ZERO); + req->rq_oi.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS); if (!req->rq_oi.oi_oa) { kfree(req); rc = -ENOMEM; @@ -507,8 +505,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, req->rq_stripe = i; req->rq_idx = loi->loi_ost_idx; - req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep, - GFP_NOFS | __GFP_ZERO); + req->rq_oi.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS); if (!req->rq_oi.oi_oa) { kfree(req); rc = -ENOMEM; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 233740cd8cc6..c335c020f4f4 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -147,7 +147,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev, struct lovsub_req *lsr; int result; - lsr = kmem_cache_alloc(lovsub_req_kmem, GFP_NOFS | __GFP_ZERO); + lsr = kmem_cache_zalloc(lovsub_req_kmem, GFP_NOFS); if (lsr) { cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops); result = 0; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index b0417396ba54..3bb0c9068a90 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -455,7 +455,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, struct lovsub_lock *lsk; int result; - lsk = kmem_cache_alloc(lovsub_lock_kmem, GFP_NOFS | __GFP_ZERO); + lsk = kmem_cache_zalloc(lovsub_lock_kmem, GFP_NOFS); if (lsk) { INIT_LIST_HEAD(&lsk->lss_parents); cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 0a9bf51a9c21..6c5430d938d0 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -143,7 +143,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, struct lovsub_object *los; 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) { struct cl_object_header *hdr;