Commit ff861c4d authored by Kees Cook's avatar Kees Cook Committed by David S. Miller

sunrpc: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Jeff Layton <jlayton@poochiereds.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-nfs@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1ab791dc
...@@ -44,7 +44,7 @@ static mempool_t *rpc_buffer_mempool __read_mostly; ...@@ -44,7 +44,7 @@ static mempool_t *rpc_buffer_mempool __read_mostly;
static void rpc_async_schedule(struct work_struct *); static void rpc_async_schedule(struct work_struct *);
static void rpc_release_task(struct rpc_task *task); static void rpc_release_task(struct rpc_task *task);
static void __rpc_queue_timer_fn(unsigned long ptr); static void __rpc_queue_timer_fn(struct timer_list *t);
/* /*
* RPC tasks sit here while waiting for conditions to improve. * RPC tasks sit here while waiting for conditions to improve.
...@@ -228,7 +228,7 @@ static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const c ...@@ -228,7 +228,7 @@ static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const c
queue->maxpriority = nr_queues - 1; queue->maxpriority = nr_queues - 1;
rpc_reset_waitqueue_priority(queue); rpc_reset_waitqueue_priority(queue);
queue->qlen = 0; queue->qlen = 0;
setup_timer(&queue->timer_list.timer, __rpc_queue_timer_fn, (unsigned long)queue); timer_setup(&queue->timer_list.timer, __rpc_queue_timer_fn, 0);
INIT_LIST_HEAD(&queue->timer_list.list); INIT_LIST_HEAD(&queue->timer_list.list);
rpc_assign_waitqueue_name(queue, qname); rpc_assign_waitqueue_name(queue, qname);
} }
...@@ -635,9 +635,9 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status) ...@@ -635,9 +635,9 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status)
} }
EXPORT_SYMBOL_GPL(rpc_wake_up_status); EXPORT_SYMBOL_GPL(rpc_wake_up_status);
static void __rpc_queue_timer_fn(unsigned long ptr) static void __rpc_queue_timer_fn(struct timer_list *t)
{ {
struct rpc_wait_queue *queue = (struct rpc_wait_queue *)ptr; struct rpc_wait_queue *queue = from_timer(queue, t, timer_list.timer);
struct rpc_task *task, *n; struct rpc_task *task, *n;
unsigned long expires, now, timeo; unsigned long expires, now, timeo;
......
...@@ -455,7 +455,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, ...@@ -455,7 +455,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
serv->sv_xdrsize = xdrsize; serv->sv_xdrsize = xdrsize;
INIT_LIST_HEAD(&serv->sv_tempsocks); INIT_LIST_HEAD(&serv->sv_tempsocks);
INIT_LIST_HEAD(&serv->sv_permsocks); INIT_LIST_HEAD(&serv->sv_permsocks);
init_timer(&serv->sv_temptimer); timer_setup(&serv->sv_temptimer, NULL, 0);
spin_lock_init(&serv->sv_lock); spin_lock_init(&serv->sv_lock);
__svc_init_bc(serv); __svc_init_bc(serv);
......
...@@ -28,7 +28,7 @@ module_param(svc_rpc_per_connection_limit, uint, 0644); ...@@ -28,7 +28,7 @@ module_param(svc_rpc_per_connection_limit, uint, 0644);
static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt); static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt);
static int svc_deferred_recv(struct svc_rqst *rqstp); static int svc_deferred_recv(struct svc_rqst *rqstp);
static struct cache_deferred_req *svc_defer(struct cache_req *req); static struct cache_deferred_req *svc_defer(struct cache_req *req);
static void svc_age_temp_xprts(unsigned long closure); static void svc_age_temp_xprts(struct timer_list *t);
static void svc_delete_xprt(struct svc_xprt *xprt); static void svc_delete_xprt(struct svc_xprt *xprt);
/* apparently the "standard" is that clients close /* apparently the "standard" is that clients close
...@@ -785,8 +785,7 @@ static void svc_add_new_temp_xprt(struct svc_serv *serv, struct svc_xprt *newxpt ...@@ -785,8 +785,7 @@ static void svc_add_new_temp_xprt(struct svc_serv *serv, struct svc_xprt *newxpt
serv->sv_tmpcnt++; serv->sv_tmpcnt++;
if (serv->sv_temptimer.function == NULL) { if (serv->sv_temptimer.function == NULL) {
/* setup timer to age temp transports */ /* setup timer to age temp transports */
setup_timer(&serv->sv_temptimer, svc_age_temp_xprts, serv->sv_temptimer.function = (TIMER_FUNC_TYPE)svc_age_temp_xprts;
(unsigned long)serv);
mod_timer(&serv->sv_temptimer, mod_timer(&serv->sv_temptimer,
jiffies + svc_conn_age_period * HZ); jiffies + svc_conn_age_period * HZ);
} }
...@@ -960,9 +959,9 @@ int svc_send(struct svc_rqst *rqstp) ...@@ -960,9 +959,9 @@ int svc_send(struct svc_rqst *rqstp)
* Timer function to close old temporary transports, using * Timer function to close old temporary transports, using
* a mark-and-sweep algorithm. * a mark-and-sweep algorithm.
*/ */
static void svc_age_temp_xprts(unsigned long closure) static void svc_age_temp_xprts(struct timer_list *t)
{ {
struct svc_serv *serv = (struct svc_serv *)closure; struct svc_serv *serv = from_timer(serv, t, sv_temptimer);
struct svc_xprt *xprt; struct svc_xprt *xprt;
struct list_head *le, *next; struct list_head *le, *next;
......
...@@ -696,9 +696,9 @@ xprt_schedule_autodisconnect(struct rpc_xprt *xprt) ...@@ -696,9 +696,9 @@ xprt_schedule_autodisconnect(struct rpc_xprt *xprt)
} }
static void static void
xprt_init_autodisconnect(unsigned long data) xprt_init_autodisconnect(struct timer_list *t)
{ {
struct rpc_xprt *xprt = (struct rpc_xprt *)data; struct rpc_xprt *xprt = from_timer(xprt, t, timer);
spin_lock(&xprt->transport_lock); spin_lock(&xprt->transport_lock);
if (!list_empty(&xprt->recv)) if (!list_empty(&xprt->recv))
...@@ -1422,10 +1422,9 @@ struct rpc_xprt *xprt_create_transport(struct xprt_create *args) ...@@ -1422,10 +1422,9 @@ struct rpc_xprt *xprt_create_transport(struct xprt_create *args)
xprt->idle_timeout = 0; xprt->idle_timeout = 0;
INIT_WORK(&xprt->task_cleanup, xprt_autoclose); INIT_WORK(&xprt->task_cleanup, xprt_autoclose);
if (xprt_has_timer(xprt)) if (xprt_has_timer(xprt))
setup_timer(&xprt->timer, xprt_init_autodisconnect, timer_setup(&xprt->timer, xprt_init_autodisconnect, 0);
(unsigned long)xprt);
else else
init_timer(&xprt->timer); timer_setup(&xprt->timer, NULL, 0);
if (strlen(args->servername) > RPC_MAXNETNAMELEN) { if (strlen(args->servername) > RPC_MAXNETNAMELEN) {
xprt_destroy(xprt); xprt_destroy(xprt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment