sunrpc: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Tue, 17 Oct 2017 00:29:42 +0000 (17:29 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Oct 2017 11:40:27 +0000 (12:40 +0100)
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: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sunrpc/sched.c
net/sunrpc/svc.c
net/sunrpc/svc_xprt.c
net/sunrpc/xprt.c

index 0cc83839c13c3621a70a4b9e8ded773217a2edf3..5dea47eb31bba79adac47e9e13c8af32dfd20659 100644 (file)
@@ -44,7 +44,7 @@ static mempool_t      *rpc_buffer_mempool __read_mostly;
 
 static void                    rpc_async_schedule(struct work_struct *);
 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.
@@ -228,7 +228,7 @@ static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const c
        queue->maxpriority = nr_queues - 1;
        rpc_reset_waitqueue_priority(queue);
        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);
        rpc_assign_waitqueue_name(queue, qname);
 }
@@ -635,9 +635,9 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int 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;
        unsigned long expires, now, timeo;
 
index aa04666f929db314b6daa46d206e1d405170e2b6..33f4ae68426d65837b15a9e91b625bfc36ca05c4 100644 (file)
@@ -455,7 +455,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
        serv->sv_xdrsize   = xdrsize;
        INIT_LIST_HEAD(&serv->sv_tempsocks);
        INIT_LIST_HEAD(&serv->sv_permsocks);
-       init_timer(&serv->sv_temptimer);
+       timer_setup(&serv->sv_temptimer, NULL, 0);
        spin_lock_init(&serv->sv_lock);
 
        __svc_init_bc(serv);
index d16a8b423c20b613fa2bf8b8fbbd87b5ecb95033..71de77bd44236dee6bd7ea1e86b8e317aee65060 100644 (file)
@@ -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 int svc_deferred_recv(struct svc_rqst *rqstp);
 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);
 
 /* 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
        serv->sv_tmpcnt++;
        if (serv->sv_temptimer.function == NULL) {
                /* setup timer to age temp transports */
-               setup_timer(&serv->sv_temptimer, svc_age_temp_xprts,
-                           (unsigned long)serv);
+               serv->sv_temptimer.function = (TIMER_FUNC_TYPE)svc_age_temp_xprts;
                mod_timer(&serv->sv_temptimer,
                          jiffies + svc_conn_age_period * HZ);
        }
@@ -960,9 +959,9 @@ out:
  * Timer function to close old temporary transports, using
  * 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 list_head *le, *next;
 
index e741ec2b4d8e6ea5d08a8e942e3021e5a20e4c6a..4b00302e18674d632639a547bf079d038ece04f7 100644 (file)
@@ -696,9 +696,9 @@ xprt_schedule_autodisconnect(struct rpc_xprt *xprt)
 }
 
 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);
        if (!list_empty(&xprt->recv))
@@ -1422,10 +1422,9 @@ found:
                xprt->idle_timeout = 0;
        INIT_WORK(&xprt->task_cleanup, xprt_autoclose);
        if (xprt_has_timer(xprt))
-               setup_timer(&xprt->timer, xprt_init_autodisconnect,
-                           (unsigned long)xprt);
+               timer_setup(&xprt->timer, xprt_init_autodisconnect, 0);
        else
-               init_timer(&xprt->timer);
+               timer_setup(&xprt->timer, NULL, 0);
 
        if (strlen(args->servername) > RPC_MAXNETNAMELEN) {
                xprt_destroy(xprt);