NFS: Fix memory allocation in rpc_alloc_task()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 21 Mar 2022 21:37:01 +0000 (17:37 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 22 Mar 2022 19:52:55 +0000 (15:52 -0400)
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>
net/sunrpc/sched.c

index d59a033820bea90902979e681f29e72e37adc437..b258b87a3ec22c54bc2f815e7db27b8d7eacf5d6 100644 (file)
@@ -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);
 }
 
 /*