staging: lustre: lov: Replace kmem_cache_alloc with kmem_cache_zalloc
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Fri, 26 Feb 2016 08:54:35 +0000 (14:24 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2016 03:18:42 +0000 (19:18 -0800)
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: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/lov/lov_dev.c
drivers/staging/lustre/lustre/lov/lov_ea.c
drivers/staging/lustre/lustre/lov/lov_lock.c
drivers/staging/lustre/lustre/lov/lov_object.c
drivers/staging/lustre/lustre/lov/lov_request.c
drivers/staging/lustre/lustre/lov/lovsub_dev.c
drivers/staging/lustre/lustre/lov/lovsub_lock.c
drivers/staging/lustre/lustre/lov/lovsub_object.c

index ee093e09646ae1d63f4ea090416dec9afb8784c0..532ef87dfb44f3e63c96e99d67d0eab34265c04e 100644 (file)
@@ -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;
index cdf4e8e12a4a49f510902e30aac7e5b340d6dbd4..b6529401c713e3158147ffe81368ce3c37142e82 100644 (file)
@@ -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;
index 455dad2debc32d6450d6ecee40db650f6b3bd367..1169a8095c6012d79f53ebe0a7fe02afc35b8ed8 100644 (file)
@@ -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;
index 9cea9dcbf57a0cb5604a383056bf1a6963444bcf..1f8ed95a6d890653e4cc981bdcf96dcfb5415fd9 100644 (file)
@@ -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);
index 42660f2c83c1eb404e9e166ab277673d8e0f2a5c..4f568f0ae839ab0cdfaeee9c6d26e35f0e409650 100644 (file)
@@ -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;
index 233740cd8cc639bcee6b3e6b2e04b8f553dda7bb..c335c020f4f4cad57235b43509de103ba84126a0 100644 (file)
@@ -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;
index b0417396ba546b47ea2aaf8da7849b7cb85c61fb..3bb0c9068a9057fff600a2ada4b48ec55ec04997 100644 (file)
@@ -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);
index 0a9bf51a9c21009c9d247854bb922e6e751753d3..6c5430d938d022b71ab192d18c1c26573cd3117f 100644 (file)
@@ -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;