RPC: Synchronous RPC calls allocate rpc_task on the stack Reduce stack utilization for all synchronous NFS operations by using a dynamically allocated rpc_task structure instead of allocating one on the stack. This reduces stack utilization by over 200 bytes for all synchronous NFS operations. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust clnt.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff -X /home/cel/src/linux/dont-diff -Naurp 08-nfs-odirect-write/net/sunrpc/clnt.c 09-rpc_call_sync/net/sunrpc/clnt.c --- 08-nfs-odirect-write/net/sunrpc/clnt.c 2004-08-14 06:55:19.000000000 -0400 +++ 09-rpc_call_sync/net/sunrpc/clnt.c 2004-08-17 15:13:15.457927000 -0400 @@ -335,7 +335,7 @@ void rpc_clnt_sigunmask(struct rpc_clnt */ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) { - struct rpc_task my_task, *task = &my_task; + struct rpc_task *task; sigset_t oldset; int status; @@ -343,15 +343,15 @@ int rpc_call_sync(struct rpc_clnt *clnt, if (clnt->cl_dead) return -EIO; - if (flags & RPC_TASK_ASYNC) { - printk("rpc_call_sync: Illegal flag combination for synchronous task\n"); - flags &= ~RPC_TASK_ASYNC; - } + BUG_ON(flags & RPC_TASK_ASYNC); rpc_clnt_sigmask(clnt, &oldset); - /* Create/initialize a new RPC task */ - rpc_init_task(task, clnt, NULL, flags); + status = -ENOMEM; + task = rpc_new_task(clnt, NULL, flags); + if (task == NULL) + goto out; + rpc_call_setup(task, msg, 0); /* Set up the call info struct and execute the task */ @@ -362,6 +361,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, rpc_release_task(task); } +out: rpc_clnt_sigunmask(clnt, &oldset); return status;