Skip to content

Commit

Permalink
NFS: Fix memory allocation in rpc_alloc_task()
Browse files Browse the repository at this point in the history
As for rpc_malloc(), we first try allocating from the slab, then fall
back to a non-waiting allocation from the mempool.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Mar 22, 2022
1 parent 33e5c76 commit 910ad38
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/sunrpc/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,10 +1108,14 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
rpc_init_task_statistics(task);
}

static struct rpc_task *
rpc_alloc_task(void)
static struct rpc_task *rpc_alloc_task(void)
{
return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_KERNEL);
struct rpc_task *task;

task = kmem_cache_alloc(rpc_task_slabp, rpc_task_gfp_mask());
if (task)
return task;
return mempool_alloc(rpc_task_mempool, GFP_NOWAIT);
}

/*
Expand Down

0 comments on commit 910ad38

Please sign in to comment.