Skip to content

Commit

Permalink
SUNRPC: Make the rpciod and xprtiod slab allocation modes consistent
Browse files Browse the repository at this point in the history
Make sure that rpciod and xprtiod are always using the same slab
allocation modes.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Mar 22, 2022
1 parent 059ee82 commit b264801
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions net/sunrpc/backchannel_rqst.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ static int xprt_alloc_xdr_buf(struct xdr_buf *buf, gfp_t gfp_flags)
return 0;
}

static
struct rpc_rqst *xprt_alloc_bc_req(struct rpc_xprt *xprt, gfp_t gfp_flags)
static struct rpc_rqst *xprt_alloc_bc_req(struct rpc_xprt *xprt)
{
gfp_t gfp_flags = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
struct rpc_rqst *req;

/* Pre-allocate one backchannel rpc_rqst */
Expand Down Expand Up @@ -154,7 +154,7 @@ int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
INIT_LIST_HEAD(&tmp_list);
for (i = 0; i < min_reqs; i++) {
/* Pre-allocate one backchannel rpc_rqst */
req = xprt_alloc_bc_req(xprt, GFP_KERNEL);
req = xprt_alloc_bc_req(xprt);
if (req == NULL) {
printk(KERN_ERR "Failed to create bc rpc_rqst\n");
goto out_free;
Expand Down Expand Up @@ -343,7 +343,7 @@ struct rpc_rqst *xprt_lookup_bc_request(struct rpc_xprt *xprt, __be32 xid)
break;
} else if (req)
break;
new = xprt_alloc_bc_req(xprt, GFP_KERNEL);
new = xprt_alloc_bc_req(xprt);
} while (new);
return req;
}
Expand Down
4 changes: 2 additions & 2 deletions net/sunrpc/rpcb_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void rpcb_getport_async(struct rpc_task *task)
goto bailout_nofree;
}

map = kzalloc(sizeof(struct rpcbind_args), GFP_KERNEL);
map = kzalloc(sizeof(struct rpcbind_args), rpc_task_gfp_mask());
if (!map) {
status = -ENOMEM;
goto bailout_release_client;
Expand All @@ -730,7 +730,7 @@ void rpcb_getport_async(struct rpc_task *task)
case RPCBVERS_4:
case RPCBVERS_3:
map->r_netid = xprt->address_strings[RPC_DISPLAY_NETID];
map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
map->r_addr = rpc_sockaddr2uaddr(sap, rpc_task_gfp_mask());
if (!map->r_addr) {
status = -ENOMEM;
goto bailout_free_args;
Expand Down
3 changes: 2 additions & 1 deletion net/sunrpc/socklib.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/pagemap.h>
#include <linux/udp.h>
#include <linux/sunrpc/msg_prot.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/xdr.h>
#include <linux/export.h>

Expand Down Expand Up @@ -222,7 +223,7 @@ static int xprt_send_pagedata(struct socket *sock, struct msghdr *msg,
{
int err;

err = xdr_alloc_bvec(xdr, GFP_KERNEL);
err = xdr_alloc_bvec(xdr, rpc_task_gfp_mask());
if (err < 0)
return err;

Expand Down
5 changes: 1 addition & 4 deletions net/sunrpc/xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1679,15 +1679,12 @@ static bool xprt_throttle_congested(struct rpc_xprt *xprt, struct rpc_task *task
static struct rpc_rqst *xprt_dynamic_alloc_slot(struct rpc_xprt *xprt)
{
struct rpc_rqst *req = ERR_PTR(-EAGAIN);
gfp_t gfp_mask = GFP_KERNEL;

if (xprt->num_reqs >= xprt->max_reqs)
goto out;
++xprt->num_reqs;
spin_unlock(&xprt->reserve_lock);
if (current->flags & PF_WQ_WORKER)
gfp_mask |= __GFP_NORETRY | __GFP_NOWARN;
req = kzalloc(sizeof(*req), gfp_mask);
req = kzalloc(sizeof(*req), rpc_task_gfp_mask());
spin_lock(&xprt->reserve_lock);
if (req != NULL)
goto out;
Expand Down
11 changes: 6 additions & 5 deletions net/sunrpc/xprtsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ xs_read_xdr_buf(struct socket *sock, struct msghdr *msg, int flags,
offset += want;
}

want = xs_alloc_sparse_pages(buf,
min_t(size_t, count - offset, buf->page_len),
GFP_KERNEL);
want = xs_alloc_sparse_pages(
buf, min_t(size_t, count - offset, buf->page_len),
GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
if (seek < want) {
ret = xs_read_bvec(sock, msg, flags, buf->bvec,
xdr_buf_pagecount(buf),
Expand Down Expand Up @@ -826,7 +826,8 @@ static void
xs_stream_prepare_request(struct rpc_rqst *req)
{
xdr_free_bvec(&req->rq_rcv_buf);
req->rq_task->tk_status = xdr_alloc_bvec(&req->rq_rcv_buf, GFP_KERNEL);
req->rq_task->tk_status = xdr_alloc_bvec(
&req->rq_rcv_buf, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
}

/*
Expand Down Expand Up @@ -2487,7 +2488,7 @@ static int bc_malloc(struct rpc_task *task)
return -EINVAL;
}

page = alloc_page(GFP_KERNEL);
page = alloc_page(GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
if (!page)
return -ENOMEM;

Expand Down

0 comments on commit b264801

Please sign in to comment.