瀏覽代碼

SUNRPC: allow the caller of rpc_run_task to preallocate the struct rpc_task

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Trond Myklebust 17 年之前
父節點
當前提交
e8f5d77c80
共有 2 個文件被更改,包括 11 次插入6 次删除
  1. 1 0
      include/linux/sunrpc/sched.h
  2. 10 6
      net/sunrpc/sched.c

+ 1 - 0
include/linux/sunrpc/sched.h

@@ -118,6 +118,7 @@ struct rpc_call_ops {
 };
 
 struct rpc_task_setup {
+	struct rpc_task *task;
 	struct rpc_clnt *rpc_client;
 	const struct rpc_message *rpc_message;
 	const struct rpc_call_ops *callback_ops;

+ 10 - 6
net/sunrpc/sched.c

@@ -885,16 +885,20 @@ static void rpc_free_task(struct rcu_head *rcu)
  */
 struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data)
 {
-	struct rpc_task	*task;
-
-	task = rpc_alloc_task();
-	if (!task)
-		goto out;
+	struct rpc_task	*task = setup_data->task;
+	unsigned short flags = 0;
+
+	if (task == NULL) {
+		task = rpc_alloc_task();
+		if (task == NULL)
+			goto out;
+		flags = RPC_TASK_DYNAMIC;
+	}
 
 	rpc_init_task(task, setup_data);
 
+	task->tk_flags |= flags;
 	dprintk("RPC:       allocated task %p\n", task);
-	task->tk_flags |= RPC_TASK_DYNAMIC;
 out:
 	return task;
 }