Skip to content

Commit

Permalink
lustre: ptlrpc: Replace uses of OBD_{ALLOC,FREE}_LARGE
Browse files Browse the repository at this point in the history
Replace uses of OBD_ALLOC_LARGE by libcfs_kvzalloc and OBD_FREE_LARGE by
kvfree.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression ptr,size;
@@

- OBD_ALLOC_LARGE(ptr,size)
+ ptr = libcfs_kvzalloc(size, GFP_NOFS)

@@
expression ptr,size;
@@

- OBD_FREE_LARGE(ptr, size);
+ kvfree(ptr);
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
JuliaLawall authored and gregkh committed Jun 11, 2015
1 parent 6b0e43d commit ee0ec19
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 34 deletions.
4 changes: 2 additions & 2 deletions drivers/staging/lustre/lustre/ptlrpc/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
list_del(&req->rq_list);
LASSERT(req->rq_reqbuf);
LASSERT(req->rq_reqbuf_len == pool->prp_rq_size);
OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size);
kvfree(req->rq_reqbuf);
ptlrpc_request_cache_free(req);
}
spin_unlock(&pool->prp_lock);
Expand Down Expand Up @@ -469,7 +469,7 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
req = ptlrpc_request_cache_alloc(GFP_NOFS);
if (!req)
return;
OBD_ALLOC_LARGE(msg, size);
msg = libcfs_kvzalloc(size, GFP_NOFS);
if (!msg) {
ptlrpc_request_cache_free(req);
return;
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/lustre/lustre/ptlrpc/sec.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
/* save request message */
reqmsg_size = req->rq_reqlen;
if (reqmsg_size != 0) {
OBD_ALLOC_LARGE(reqmsg, reqmsg_size);
reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS);
if (reqmsg == NULL)
return -ENOMEM;
memcpy(reqmsg, req->rq_reqmsg, reqmsg_size);
Expand Down Expand Up @@ -497,7 +497,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
req->rq_flvr = old_flvr;
}

OBD_FREE_LARGE(reqmsg, reqmsg_size);
kvfree(reqmsg);
}
return rc;
}
Expand Down Expand Up @@ -1093,7 +1093,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,

early_size = req->rq_nob_received;
early_bufsz = size_roundup_power2(early_size);
OBD_ALLOC_LARGE(early_buf, early_bufsz);
early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS);
if (early_buf == NULL) {
rc = -ENOMEM;
goto err_req;
Expand Down Expand Up @@ -1163,7 +1163,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
err_ctx:
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
err_buf:
OBD_FREE_LARGE(early_buf, early_bufsz);
kvfree(early_buf);
err_req:
ptlrpc_request_cache_free(early_req);
return rc;
Expand All @@ -1181,7 +1181,7 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req)
LASSERT(early_req->rq_repmsg);

sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len);
kvfree(early_req->rq_repbuf);
ptlrpc_request_cache_free(early_req);
}

Expand Down
11 changes: 5 additions & 6 deletions drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,19 +689,18 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_del_user);
static inline void enc_pools_alloc(void)
{
LASSERT(page_pools.epp_max_pools);
OBD_ALLOC_LARGE(page_pools.epp_pools,
page_pools.epp_max_pools *
sizeof(*page_pools.epp_pools));
page_pools.epp_pools =
libcfs_kvzalloc(page_pools.epp_max_pools *
sizeof(*page_pools.epp_pools),
GFP_NOFS);
}

static inline void enc_pools_free(void)
{
LASSERT(page_pools.epp_max_pools);
LASSERT(page_pools.epp_pools);

OBD_FREE_LARGE(page_pools.epp_pools,
page_pools.epp_max_pools *
sizeof(*page_pools.epp_pools));
kvfree(page_pools.epp_pools);
}

static struct shrinker pools_shrinker = {
Expand Down
16 changes: 8 additions & 8 deletions drivers/staging/lustre/lustre/ptlrpc/sec_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int null_alloc_reqbuf(struct ptlrpc_sec *sec,
int alloc_size = size_roundup_power2(msgsize);

LASSERT(!req->rq_pool);
OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size);
req->rq_reqbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS);
if (!req->rq_reqbuf)
return -ENOMEM;

Expand All @@ -186,7 +186,7 @@ void null_free_reqbuf(struct ptlrpc_sec *sec,
"req %p: reqlen %d should smaller than buflen %d\n",
req, req->rq_reqlen, req->rq_reqbuf_len);

OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
kvfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
Expand All @@ -202,7 +202,7 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec,

msgsize = size_roundup_power2(msgsize);

OBD_ALLOC_LARGE(req->rq_repbuf, msgsize);
req->rq_repbuf = libcfs_kvzalloc(msgsize, GFP_NOFS);
if (!req->rq_repbuf)
return -ENOMEM;

Expand All @@ -216,7 +216,7 @@ void null_free_repbuf(struct ptlrpc_sec *sec,
{
LASSERT(req->rq_repbuf);

OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
kvfree(req->rq_repbuf);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
if (req->rq_reqbuf_len < newmsg_size) {
alloc_size = size_roundup_power2(newmsg_size);

OBD_ALLOC_LARGE(newbuf, alloc_size);
newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS);
if (newbuf == NULL)
return -ENOMEM;

Expand All @@ -261,7 +261,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
spin_lock(&req->rq_import->imp_lock);
memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);

OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
kvfree(req->rq_reqbuf);
req->rq_reqbuf = req->rq_reqmsg = newbuf;
req->rq_reqbuf_len = alloc_size;

Expand Down Expand Up @@ -316,7 +316,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize)
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
OBD_ALLOC_LARGE(rs, rs_size);
rs = libcfs_kvzalloc(rs_size, GFP_NOFS);
if (rs == NULL)
return -ENOMEM;

Expand All @@ -341,7 +341,7 @@ void null_free_rs(struct ptlrpc_reply_state *rs)
atomic_dec(&rs->rs_svc_ctx->sc_refcount);

if (!rs->rs_prealloc)
OBD_FREE_LARGE(rs, rs->rs_size);
kvfree(rs);
}

static
Expand Down
16 changes: 8 additions & 8 deletions drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
LASSERT(!req->rq_pool);

alloc_len = size_roundup_power2(alloc_len);
OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len);
req->rq_reqbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS);
if (!req->rq_reqbuf)
return -ENOMEM;

Expand All @@ -584,7 +584,7 @@ void plain_free_reqbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
if (!req->rq_pool) {
OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
kvfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
Expand Down Expand Up @@ -613,7 +613,7 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec,

alloc_len = size_roundup_power2(alloc_len);

OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len);
req->rq_repbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS);
if (!req->rq_repbuf)
return -ENOMEM;

Expand All @@ -625,7 +625,7 @@ static
void plain_free_repbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
kvfree(req->rq_repbuf);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
Expand Down Expand Up @@ -664,7 +664,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
if (req->rq_reqbuf_len < newbuf_size) {
newbuf_size = size_roundup_power2(newbuf_size);

OBD_ALLOC_LARGE(newbuf, newbuf_size);
newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS);
if (newbuf == NULL)
return -ENOMEM;

Expand All @@ -679,7 +679,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,

memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);

OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
kvfree(req->rq_reqbuf);
req->rq_reqbuf = newbuf;
req->rq_reqbuf_len = newbuf_size;
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf,
Expand Down Expand Up @@ -800,7 +800,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize)
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
OBD_ALLOC_LARGE(rs, rs_size);
rs = libcfs_kvzalloc(rs_size, GFP_NOFS);
if (rs == NULL)
return -ENOMEM;

Expand All @@ -826,7 +826,7 @@ void plain_free_rs(struct ptlrpc_reply_state *rs)
atomic_dec(&rs->rs_svc_ctx->sc_refcount);

if (!rs->rs_prealloc)
OBD_FREE_LARGE(rs, rs->rs_size);
kvfree(rs);
}

static
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/lustre/lustre/ptlrpc/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
svcpt->scp_nrqbds_total--;
spin_unlock(&svcpt->scp_lock);

OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size);
kvfree(rqbd->rqbd_buffer);
kfree(rqbd);
}

Expand Down Expand Up @@ -1310,7 +1310,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req)
reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS);
if (reqcopy == NULL)
return -ENOMEM;
OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen);
reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS);
if (!reqmsg) {
rc = -ENOMEM;
goto out_free;
Expand Down Expand Up @@ -1374,7 +1374,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req)
class_export_put(reqcopy->rq_export);
out:
sptlrpc_svc_ctx_decref(reqcopy);
OBD_FREE_LARGE(reqmsg, req->rq_reqlen);
kvfree(reqmsg);
out_free:
ptlrpc_request_cache_free(reqcopy);
return rc;
Expand Down Expand Up @@ -2323,7 +2323,7 @@ static int ptlrpc_main(void *arg)
}

/* Alloc reply state structure for this one */
OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size);
rs = libcfs_kvzalloc(svc->srv_max_reply_size, GFP_NOFS);
if (!rs) {
rc = -ENOMEM;
goto out_srv_fini;
Expand Down Expand Up @@ -2987,7 +2987,7 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc)
struct ptlrpc_reply_state,
rs_list);
list_del(&rs->rs_list);
OBD_FREE_LARGE(rs, svc->srv_max_reply_size);
kvfree(rs);
}
}
}
Expand Down

0 comments on commit ee0ec19

Please sign in to comment.