staging: lustre: osc: 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: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Amitoj Kaur Chawla 2016-02-26 14:24:55 +05:30 committed by Greg Kroah-Hartman
parent 1c147c83f3
commit c4418daca7
7 changed files with 9 additions and 9 deletions

View File

@ -347,7 +347,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj)
{ {
struct osc_extent *ext; struct osc_extent *ext;
ext = kmem_cache_alloc(osc_extent_kmem, GFP_NOFS | __GFP_ZERO); ext = kmem_cache_zalloc(osc_extent_kmem, GFP_NOFS);
if (!ext) if (!ext)
return NULL; return NULL;

View File

@ -122,7 +122,7 @@ static void *osc_key_init(const struct lu_context *ctx,
{ {
struct osc_thread_info *info; struct osc_thread_info *info;
info = kmem_cache_alloc(osc_thread_kmem, GFP_NOFS | __GFP_ZERO); info = kmem_cache_zalloc(osc_thread_kmem, GFP_NOFS);
if (!info) if (!info)
info = ERR_PTR(-ENOMEM); info = ERR_PTR(-ENOMEM);
return info; return info;
@ -147,7 +147,7 @@ static void *osc_session_init(const struct lu_context *ctx,
{ {
struct osc_session *info; struct osc_session *info;
info = kmem_cache_alloc(osc_session_kmem, GFP_NOFS | __GFP_ZERO); info = kmem_cache_zalloc(osc_session_kmem, GFP_NOFS);
if (!info) if (!info)
info = ERR_PTR(-ENOMEM); info = ERR_PTR(-ENOMEM);
return info; return info;

View File

@ -803,7 +803,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev,
struct osc_req *or; struct osc_req *or;
int result; int result;
or = kmem_cache_alloc(osc_req_kmem, GFP_NOFS | __GFP_ZERO); or = kmem_cache_zalloc(osc_req_kmem, GFP_NOFS);
if (or) { if (or) {
cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops); cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops);
result = 0; result = 0;

View File

@ -1567,7 +1567,7 @@ int osc_lock_init(const struct lu_env *env,
struct osc_lock *clk; struct osc_lock *clk;
int result; int result;
clk = kmem_cache_alloc(osc_lock_kmem, GFP_NOFS | __GFP_ZERO); clk = kmem_cache_zalloc(osc_lock_kmem, GFP_NOFS);
if (clk) { if (clk) {
__u32 enqflags = lock->cll_descr.cld_enq_flags; __u32 enqflags = lock->cll_descr.cld_enq_flags;

View File

@ -255,7 +255,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env,
struct osc_object *osc; struct osc_object *osc;
struct lu_object *obj; struct lu_object *obj;
osc = kmem_cache_alloc(osc_object_kmem, GFP_NOFS | __GFP_ZERO); osc = kmem_cache_zalloc(osc_object_kmem, GFP_NOFS);
if (osc) { if (osc) {
obj = osc2lu(osc); obj = osc2lu(osc);
lu_object_init(obj, NULL, dev); lu_object_init(obj, NULL, dev);

View File

@ -30,7 +30,7 @@ static inline struct osc_quota_info *osc_oqi_alloc(u32 id)
{ {
struct osc_quota_info *oqi; struct osc_quota_info *oqi;
oqi = kmem_cache_alloc(osc_quota_kmem, GFP_NOFS | __GFP_ZERO); oqi = kmem_cache_zalloc(osc_quota_kmem, GFP_NOFS);
if (oqi) if (oqi)
oqi->oqi_id = id; oqi->oqi_id = id;

View File

@ -1896,7 +1896,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
goto out; goto out;
} }
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; goto out;
@ -2958,7 +2958,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
aa = ptlrpc_req_async_args(req); aa = ptlrpc_req_async_args(req);
oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
if (!oa) { if (!oa) {
ptlrpc_req_finished(req); ptlrpc_req_finished(req);
return -ENOMEM; return -ENOMEM;