Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFS: Fix memory allocation in rpc_alloc_task()

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>

+7 -3
+7 -3
net/sunrpc/sched.c
··· 1108 1108 rpc_init_task_statistics(task); 1109 1109 } 1110 1110 1111 - static struct rpc_task * 1112 - rpc_alloc_task(void) 1111 + static struct rpc_task *rpc_alloc_task(void) 1113 1112 { 1114 - return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_KERNEL); 1113 + struct rpc_task *task; 1114 + 1115 + task = kmem_cache_alloc(rpc_task_slabp, rpc_task_gfp_mask()); 1116 + if (task) 1117 + return task; 1118 + return mempool_alloc(rpc_task_mempool, GFP_NOWAIT); 1115 1119 } 1116 1120 1117 1121 /*