Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 92858
b: refs/heads/master
c: 32bfb5c
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Feb 26, 2008
1 parent 0c6b08b commit e632830
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 383ba71938519959be8e0b598ec658f0c211ff45
refs/heads/master: 32bfb5c0f495dd88ef6bac4b76885d0820563739
1 change: 1 addition & 0 deletions trunk/include/linux/sunrpc/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ struct rpc_task_setup {
const struct rpc_message *rpc_message;
const struct rpc_call_ops *callback_ops;
void *callback_data;
struct workqueue_struct *workqueue;
unsigned short flags;
signed char priority;
};
Expand Down
29 changes: 21 additions & 8 deletions trunk/net/sunrpc/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static void rpc_make_runnable(struct rpc_task *task)
int status;

INIT_WORK(&task->u.tk_work, rpc_async_schedule);
status = queue_work(task->tk_workqueue, &task->u.tk_work);
status = queue_work(rpciod_workqueue, &task->u.tk_work);
if (status < 0) {
printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status);
task->tk_status = status;
Expand Down Expand Up @@ -832,7 +832,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
task->tk_owner = current->tgid;

/* Initialize workqueue for async tasks */
task->tk_workqueue = rpciod_workqueue;
task->tk_workqueue = task_setup_data->workqueue;

task->tk_client = task_setup_data->rpc_client;
if (task->tk_client != NULL) {
Expand Down Expand Up @@ -868,7 +868,7 @@ rpc_alloc_task(void)
return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS);
}

static void rpc_free_task(struct rcu_head *rcu)
static void rpc_free_task_rcu(struct rcu_head *rcu)
{
struct rpc_task *task = container_of(rcu, struct rpc_task, u.tk_rcu);
dprintk("RPC: %5u freeing task\n", task->tk_pid);
Expand Down Expand Up @@ -898,12 +898,23 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data)
return task;
}


void rpc_put_task(struct rpc_task *task)
static void rpc_free_task(struct rpc_task *task)
{
const struct rpc_call_ops *tk_ops = task->tk_ops;
void *calldata = task->tk_calldata;

if (task->tk_flags & RPC_TASK_DYNAMIC)
call_rcu_bh(&task->u.tk_rcu, rpc_free_task_rcu);
rpc_release_calldata(tk_ops, calldata);
}

static void rpc_async_release(struct work_struct *work)
{
rpc_free_task(container_of(work, struct rpc_task, u.tk_work));
}

void rpc_put_task(struct rpc_task *task)
{
if (!atomic_dec_and_test(&task->tk_count))
return;
/* Release resources */
Expand All @@ -915,9 +926,11 @@ void rpc_put_task(struct rpc_task *task)
rpc_release_client(task->tk_client);
task->tk_client = NULL;
}
if (task->tk_flags & RPC_TASK_DYNAMIC)
call_rcu_bh(&task->u.tk_rcu, rpc_free_task);
rpc_release_calldata(tk_ops, calldata);
if (task->tk_workqueue != NULL) {
INIT_WORK(&task->u.tk_work, rpc_async_release);
queue_work(task->tk_workqueue, &task->u.tk_work);
} else
rpc_free_task(task);
}
EXPORT_SYMBOL_GPL(rpc_put_task);

Expand Down

0 comments on commit e632830

Please sign in to comment.