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:
// <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>
diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c
index ee093e0..532ef87 100644
--- a/drivers/staging/lustre/lustre/lov/lov_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lov_dev.c
@@ -142,7 +142,7 @@
{
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 @@
{
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 @@
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 cdf4e8e..b652940 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -100,7 +100,7 @@
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 455dad2..1169a80 100644
--- a/drivers/staging/lustre/lustre/lov/lov_lock.c
+++ b/drivers/staging/lustre/lustre/lov/lov_lock.c
@@ -144,7 +144,7 @@
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 @@
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 @@
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 9cea9dc..1f8ed95 100644
--- a/drivers/staging/lustre/lustre/lov/lov_object.c
+++ b/drivers/staging/lustre/lustre/lov/lov_object.c
@@ -899,7 +899,7 @@
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 42660f2..4f568f0 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -200,7 +200,7 @@
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 @@
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 @@
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 @@
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 233740c..c335c02 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
@@ -147,7 +147,7 @@
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 b041739..3bb0c90 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c
@@ -455,7 +455,7 @@
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 0a9bf51..6c5430d 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_object.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c
@@ -143,7 +143,7 @@
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;