Skip to content

Commit c743b42

Browse files
neilbrownchucklever
authored andcommitted
SUNRPC: remove timeout arg from svc_recv()
Most svc threads have no interest in a timeout. nfsd sets it to 1 hour, but this is a wart of no significance. lockd uses the timeout so that it can call nlmsvc_retry_blocked(). It also sometimes calls svc_wake_up() to ensure this is called. So change lockd to be consistent and always use svc_wake_up() to trigger nlmsvc_retry_blocked() - using a timer instead of a timeout to svc_recv(). And change svc_recv() to not take a timeout arg. This makes the sp_threads_timedout counter always zero. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 7b719e2 commit c743b42

File tree

9 files changed

+34
-32
lines changed

9 files changed

+34
-32
lines changed

fs/lockd/svc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ static unsigned int nlmsvc_users;
5656
static struct svc_serv *nlmsvc_serv;
5757
unsigned long nlmsvc_timeout;
5858

59+
static void nlmsvc_request_retry(struct timer_list *tl)
60+
{
61+
svc_wake_up(nlmsvc_serv);
62+
}
63+
DEFINE_TIMER(nlmsvc_retry, nlmsvc_request_retry);
64+
5965
unsigned int lockd_net_id;
6066

6167
/*
@@ -130,14 +136,11 @@ lockd(void *vrqstp)
130136
* NFS mount or NFS daemon has gone away.
131137
*/
132138
while (!kthread_should_stop()) {
133-
long timeout = MAX_SCHEDULE_TIMEOUT;
134-
135139
/* update sv_maxconn if it has changed */
136140
rqstp->rq_server->sv_maxconn = nlm_max_connections;
137141

138-
timeout = nlmsvc_retry_blocked();
139-
140-
svc_recv(rqstp, timeout);
142+
nlmsvc_retry_blocked();
143+
svc_recv(rqstp);
141144
}
142145
if (nlmsvc_ops)
143146
nlmsvc_invalidate_all();
@@ -371,6 +374,7 @@ static void lockd_put(void)
371374
#endif
372375

373376
svc_set_num_threads(nlmsvc_serv, NULL, 0);
377+
timer_delete_sync(&nlmsvc_retry);
374378
nlmsvc_serv = NULL;
375379
dprintk("lockd_down: service destroyed\n");
376380
}

fs/lockd/svclock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ retry_deferred_block(struct nlm_block *block)
10191019
* picks up locks that can be granted, or grant notifications that must
10201020
* be retransmitted.
10211021
*/
1022-
unsigned long
1022+
void
10231023
nlmsvc_retry_blocked(void)
10241024
{
10251025
unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
@@ -1049,5 +1049,6 @@ nlmsvc_retry_blocked(void)
10491049
}
10501050
spin_unlock(&nlm_blocked_lock);
10511051

1052-
return timeout;
1052+
if (timeout < MAX_SCHEDULE_TIMEOUT)
1053+
mod_timer(&nlmsvc_retry, jiffies + timeout);
10531054
}

fs/nfs/callback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ nfs4_callback_svc(void *vrqstp)
7979
set_freezable();
8080

8181
while (!kthread_freezable_should_stop(NULL))
82-
svc_recv(rqstp, MAX_SCHEDULE_TIMEOUT);
82+
svc_recv(rqstp);
8383

8484
svc_exit_thread(rqstp);
8585
return 0;

fs/nfsd/nfssvc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ nfsd(void *vrqstp)
961961
/* Update sv_maxconn if it has changed */
962962
rqstp->rq_server->sv_maxconn = nn->max_connections;
963963

964-
svc_recv(rqstp, 60*60*HZ);
964+
svc_recv(rqstp);
965965
validate_process_creds();
966966
}
967967

include/linux/lockd/lockd.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ extern unsigned long nlmsvc_timeout;
204204
extern bool nsm_use_hostnames;
205205
extern u32 nsm_local_state;
206206

207+
extern struct timer_list nlmsvc_retry;
208+
207209
/*
208210
* Lockd client functions
209211
*/
@@ -280,7 +282,7 @@ __be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *,
280282
struct nlm_host *, struct nlm_lock *,
281283
struct nlm_lock *, struct nlm_cookie *);
282284
__be32 nlmsvc_cancel_blocked(struct net *net, struct nlm_file *, struct nlm_lock *);
283-
unsigned long nlmsvc_retry_blocked(void);
285+
void nlmsvc_retry_blocked(void);
284286
void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
285287
nlm_host_match_fn_t match);
286288
void nlmsvc_grant_reply(struct nlm_cookie *, __be32);

include/linux/sunrpc/svc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct svc_pool {
4141
/* statistics on pool operation */
4242
struct percpu_counter sp_sockets_queued;
4343
struct percpu_counter sp_threads_woken;
44-
struct percpu_counter sp_threads_timedout;
4544

4645
#define SP_TASK_PENDING (0) /* still work to do even if no
4746
* xprt is queued. */

include/linux/sunrpc/svcsock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline u32 svc_sock_final_rec(struct svc_sock *svsk)
5757
* Function prototypes.
5858
*/
5959
void svc_close_net(struct svc_serv *, struct net *);
60-
void svc_recv(struct svc_rqst *, long);
60+
void svc_recv(struct svc_rqst *rqstp);
6161
void svc_send(struct svc_rqst *rqstp);
6262
void svc_drop(struct svc_rqst *);
6363
void svc_sock_update_bufs(struct svc_serv *serv);

net/sunrpc/svc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
515515

516516
percpu_counter_init(&pool->sp_sockets_queued, 0, GFP_KERNEL);
517517
percpu_counter_init(&pool->sp_threads_woken, 0, GFP_KERNEL);
518-
percpu_counter_init(&pool->sp_threads_timedout, 0, GFP_KERNEL);
519518
}
520519

521520
return serv;
@@ -590,7 +589,6 @@ svc_destroy(struct kref *ref)
590589

591590
percpu_counter_destroy(&pool->sp_sockets_queued);
592591
percpu_counter_destroy(&pool->sp_threads_woken);
593-
percpu_counter_destroy(&pool->sp_threads_timedout);
594592
}
595593
kfree(serv->sv_pools);
596594
kfree(serv);

net/sunrpc/svc_xprt.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,9 @@ rqst_should_sleep(struct svc_rqst *rqstp)
750750
return true;
751751
}
752752

753-
static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
753+
static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp)
754754
{
755755
struct svc_pool *pool = rqstp->rq_pool;
756-
long time_left = 0;
757756

758757
/* rq_xprt should be clear on entry */
759758
WARN_ON_ONCE(rqstp->rq_xprt);
@@ -769,7 +768,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
769768
smp_mb__after_atomic();
770769

771770
if (likely(rqst_should_sleep(rqstp)))
772-
time_left = schedule_timeout(timeout);
771+
schedule();
773772
else
774773
__set_current_state(TASK_RUNNING);
775774

@@ -781,9 +780,6 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
781780
if (rqstp->rq_xprt)
782781
goto out_found;
783782

784-
if (!time_left)
785-
percpu_counter_inc(&pool->sp_threads_timedout);
786-
787783
if (kthread_should_stop())
788784
return NULL;
789785
return NULL;
@@ -863,12 +859,15 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
863859
return len;
864860
}
865861

866-
/*
867-
* Receive the next request on any transport. This code is carefully
868-
* organised not to touch any cachelines in the shared svc_serv
869-
* structure, only cachelines in the local svc_pool.
862+
/**
863+
* svc_recv - Receive and process the next request on any transport
864+
* @rqstp: an idle RPC service thread
865+
*
866+
* This code is carefully organised not to touch any cachelines in
867+
* the shared svc_serv structure, only cachelines in the local
868+
* svc_pool.
870869
*/
871-
void svc_recv(struct svc_rqst *rqstp, long timeout)
870+
void svc_recv(struct svc_rqst *rqstp)
872871
{
873872
struct svc_xprt *xprt = NULL;
874873
struct svc_serv *serv = rqstp->rq_server;
@@ -882,7 +881,7 @@ void svc_recv(struct svc_rqst *rqstp, long timeout)
882881
if (kthread_should_stop())
883882
goto out;
884883

885-
xprt = svc_get_next_xprt(rqstp, timeout);
884+
xprt = svc_get_next_xprt(rqstp);
886885
if (!xprt)
887886
goto out;
888887

@@ -1447,12 +1446,11 @@ static int svc_pool_stats_show(struct seq_file *m, void *p)
14471446
return 0;
14481447
}
14491448

1450-
seq_printf(m, "%u %llu %llu %llu %llu\n",
1451-
pool->sp_id,
1452-
percpu_counter_sum_positive(&pool->sp_sockets_queued),
1453-
percpu_counter_sum_positive(&pool->sp_sockets_queued),
1454-
percpu_counter_sum_positive(&pool->sp_threads_woken),
1455-
percpu_counter_sum_positive(&pool->sp_threads_timedout));
1449+
seq_printf(m, "%u %llu %llu %llu 0\n",
1450+
pool->sp_id,
1451+
percpu_counter_sum_positive(&pool->sp_sockets_queued),
1452+
percpu_counter_sum_positive(&pool->sp_sockets_queued),
1453+
percpu_counter_sum_positive(&pool->sp_threads_woken));
14561454

14571455
return 0;
14581456
}

0 commit comments

Comments
 (0)