Commit 21068c46 authored by Amitoj Kaur Chawla's avatar Amitoj Kaur Chawla Committed by Greg Kroah-Hartman

staging: lustre: llite: 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 3eed2d00
...@@ -64,7 +64,7 @@ static struct ll_file_data *ll_file_data_get(void) ...@@ -64,7 +64,7 @@ static struct ll_file_data *ll_file_data_get(void)
{ {
struct ll_file_data *fd; 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) if (!fd)
return NULL; return NULL;
fd->fd_write_failed = false; fd->fd_write_failed = false;
...@@ -1280,7 +1280,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) ...@@ -1280,7 +1280,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx)
int rc = 0; int rc = 0;
struct lov_stripe_md *lsm = NULL, *lsm2; 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) if (!oa)
return -ENOMEM; return -ENOMEM;
......
...@@ -225,7 +225,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) ...@@ -225,7 +225,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
inode->i_ino, inode->i_generation, inode->i_ino, inode->i_generation,
lli->lli_flags); lli->lli_flags);
oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
if (!oa) { if (!oa) {
CERROR("can't allocate memory for Size-on-MDS update.\n"); CERROR("can't allocate memory for Size-on-MDS update.\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -1789,8 +1789,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, ...@@ -1789,8 +1789,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
return 0; return 0;
} }
oinfo.oi_oa = kmem_cache_alloc(obdo_cachep, oinfo.oi_oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
GFP_NOFS | __GFP_ZERO);
if (!oinfo.oi_oa) { if (!oinfo.oi_oa) {
ccc_inode_lsm_put(inode, lsm); ccc_inode_lsm_put(inode, lsm);
return -ENOMEM; return -ENOMEM;
......
...@@ -887,7 +887,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) ...@@ -887,7 +887,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
} }
LASSERT(rc >= sizeof(*lsm)); LASSERT(rc >= sizeof(*lsm));
oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
if (!oa) { if (!oa) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_free_memmd; goto out_free_memmd;
......
...@@ -61,7 +61,7 @@ static inline struct ll_remote_perm *alloc_ll_remote_perm(void) ...@@ -61,7 +61,7 @@ static inline struct ll_remote_perm *alloc_ll_remote_perm(void)
{ {
struct ll_remote_perm *lrp; 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) if (lrp)
INIT_HLIST_NODE(&lrp->lrp_list); INIT_HLIST_NODE(&lrp->lrp_list);
return lrp; return lrp;
...@@ -82,7 +82,7 @@ static struct hlist_head *alloc_rmtperm_hash(void) ...@@ -82,7 +82,7 @@ static struct hlist_head *alloc_rmtperm_hash(void)
struct hlist_head *hash; struct hlist_head *hash;
int i; 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) if (!hash)
return NULL; return NULL;
......
...@@ -53,7 +53,7 @@ static struct inode *ll_alloc_inode(struct super_block *sb) ...@@ -53,7 +53,7 @@ static struct inode *ll_alloc_inode(struct super_block *sb)
struct ll_inode_info *lli; struct ll_inode_info *lli;
ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); 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) if (!lli)
return NULL; return NULL;
......
...@@ -79,7 +79,7 @@ static void *vvp_key_init(const struct lu_context *ctx, ...@@ -79,7 +79,7 @@ static void *vvp_key_init(const struct lu_context *ctx,
{ {
struct vvp_thread_info *info; 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) if (!info)
info = ERR_PTR(-ENOMEM); info = ERR_PTR(-ENOMEM);
return info; return info;
...@@ -98,7 +98,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx, ...@@ -98,7 +98,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx,
{ {
struct vvp_session *session; 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) if (!session)
session = ERR_PTR(-ENOMEM); session = ERR_PTR(-ENOMEM);
return session; return session;
......
...@@ -114,7 +114,7 @@ static int ll_xattr_cache_add(struct list_head *cache, ...@@ -114,7 +114,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
return -EPROTO; return -EPROTO;
} }
xattr = kmem_cache_alloc(xattr_kmem, GFP_NOFS | __GFP_ZERO); xattr = kmem_cache_zalloc(xattr_kmem, GFP_NOFS);
if (!xattr) { if (!xattr) {
CDEBUG(D_CACHE, "failed to allocate xattr\n"); CDEBUG(D_CACHE, "failed to allocate xattr\n");
return -ENOMEM; return -ENOMEM;
......
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