staging: lustre: llite: Replace kmem_cache_alloc with kmem_cache_zalloc
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Fri, 26 Feb 2016 08:55:09 +0000 (14:25 +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/llite/file.c
drivers/staging/lustre/lustre/llite/llite_close.c
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/llite/namei.c
drivers/staging/lustre/lustre/llite/remote_perm.c
drivers/staging/lustre/lustre/llite/super25.c
drivers/staging/lustre/lustre/llite/vvp_dev.c
drivers/staging/lustre/lustre/llite/xattr_cache.c

index 2e30c524db3a534dc7ed93fa022502122c96262f..d4971cc113fc4711eb83092d726cc7ade04795d0 100644 (file)
@@ -64,7 +64,7 @@ static struct ll_file_data *ll_file_data_get(void)
 {
        struct ll_file_data *fd;
 
-       fd = kmem_cache_alloc(ll_file_data_slab, GFP_NOFS | __GFP_ZERO);
+       fd = kmem_cache_zalloc(ll_file_data_slab, GFP_NOFS);
        if (!fd)
                return NULL;
        fd->fd_write_failed = false;
@@ -1280,7 +1280,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx)
        int rc = 0;
        struct lov_stripe_md *lsm = NULL, *lsm2;
 
-       oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
+       oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
        if (!oa)
                return -ENOMEM;
 
index d3195c3a0d6117a07e8436268810790ae6f4d886..a55ac4dccd9014d800cdcce8532e29e37f2c726a 100644 (file)
@@ -225,7 +225,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
                       inode->i_ino, inode->i_generation,
                       lli->lli_flags);
 
-       oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
+       oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
        if (!oa) {
                CERROR("can't allocate memory for Size-on-MDS update.\n");
                return -ENOMEM;
index 0cdaa48a9f42b2fc95757febd22ff60a344f56ab..465118c804bf57af033db27eff03a1808633d011 100644 (file)
@@ -1789,8 +1789,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                        return 0;
                }
 
-               oinfo.oi_oa = kmem_cache_alloc(obdo_cachep,
-                                              GFP_NOFS | __GFP_ZERO);
+               oinfo.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
                if (!oinfo.oi_oa) {
                        ccc_inode_lsm_put(inode, lsm);
                        return -ENOMEM;
index 46be850cb7289aeb2d1c7cbbd8f5ac60b581137e..f8f98e4e82584260eb352d3bf19e07cd593f30f4 100644 (file)
@@ -887,7 +887,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
        }
        LASSERT(rc >= sizeof(*lsm));
 
-       oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
+       oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
        if (!oa) {
                rc = -ENOMEM;
                goto out_free_memmd;
index fe4a72268e3aadf1b695cb1621641c5f6da4838e..e9d25317cd28dc53fb507f99611104e2aa3d652b 100644 (file)
@@ -61,7 +61,7 @@ static inline struct ll_remote_perm *alloc_ll_remote_perm(void)
 {
        struct ll_remote_perm *lrp;
 
-       lrp = kmem_cache_alloc(ll_remote_perm_cachep, GFP_KERNEL | __GFP_ZERO);
+       lrp = kmem_cache_zalloc(ll_remote_perm_cachep, GFP_KERNEL);
        if (lrp)
                INIT_HLIST_NODE(&lrp->lrp_list);
        return lrp;
@@ -82,7 +82,7 @@ static struct hlist_head *alloc_rmtperm_hash(void)
        struct hlist_head *hash;
        int i;
 
-       hash = kmem_cache_alloc(ll_rmtperm_hash_cachep, GFP_NOFS | __GFP_ZERO);
+       hash = kmem_cache_zalloc(ll_rmtperm_hash_cachep, GFP_NOFS);
        if (!hash)
                return NULL;
 
index 79e1322127c29f3e4613fa2253b16188761818d8..b9036f2fcaf96cd3191ad80177c9da53e430afdd 100644 (file)
@@ -53,7 +53,7 @@ static struct inode *ll_alloc_inode(struct super_block *sb)
        struct ll_inode_info *lli;
 
        ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1);
-       lli = kmem_cache_alloc(ll_inode_cachep, GFP_NOFS | __GFP_ZERO);
+       lli = kmem_cache_zalloc(ll_inode_cachep, GFP_NOFS);
        if (!lli)
                return NULL;
 
index 6075ccfdc749ea3ba5bb277aea355e4ea426dca1..282b70b776dae2a44b2be9ccb225c01145e2a55c 100644 (file)
@@ -79,7 +79,7 @@ static void *vvp_key_init(const struct lu_context *ctx,
 {
        struct vvp_thread_info *info;
 
-       info = kmem_cache_alloc(vvp_thread_kmem, GFP_NOFS | __GFP_ZERO);
+       info = kmem_cache_zalloc(vvp_thread_kmem, GFP_NOFS);
        if (!info)
                info = ERR_PTR(-ENOMEM);
        return info;
@@ -98,7 +98,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx,
 {
        struct vvp_session *session;
 
-       session = kmem_cache_alloc(vvp_session_kmem, GFP_NOFS | __GFP_ZERO);
+       session = kmem_cache_zalloc(vvp_session_kmem, GFP_NOFS);
        if (!session)
                session = ERR_PTR(-ENOMEM);
        return session;
index c069f8b92ad8dcbe686c520918e97258a1e93f3d..3480ce2bb3cc4ae881e5d568695705bd775f5391 100644 (file)
@@ -114,7 +114,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
                return -EPROTO;
        }
 
-       xattr = kmem_cache_alloc(xattr_kmem, GFP_NOFS | __GFP_ZERO);
+       xattr = kmem_cache_zalloc(xattr_kmem, GFP_NOFS);
        if (!xattr) {
                CDEBUG(D_CACHE, "failed to allocate xattr\n");
                return -ENOMEM;