Commit a0022a38 authored by Jeff Layton's avatar Jeff Layton Committed by Chuck Lever
Browse files

sunrpc: allow svc_recv() to return -ETIMEDOUT and -EBUSY



To dynamically adjust the thread count, nfsd requires some information
about how busy things are.

Change svc_recv() to take a timeout value, and then allow the wait for
work to time out if it's set. If a timeout is not defined, then the
schedule will be set to MAX_SCHEDULE_TIMEOUT. If the task waits for the
full timeout, then have it return -ETIMEDOUT to the caller.

If it wakes up, finds that there is more work and that no threads are
available, then attempt to set SP_TASK_STARTING. If wasn't already set,
have the task return -EBUSY to cue to the caller that the service could
use more threads.

Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 7f221b34
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ lockd(void *vrqstp)
	 */
	while (!svc_thread_should_stop(rqstp)) {
		nlmsvc_retry_blocked(rqstp);
		svc_recv(rqstp);
		svc_recv(rqstp, 0);
	}
	if (nlmsvc_ops)
		nlmsvc_invalidate_all();
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ nfs4_callback_svc(void *vrqstp)
	set_freezable();

	while (!svc_thread_should_stop(rqstp))
		svc_recv(rqstp);
		svc_recv(rqstp, 0);

	svc_exit_thread(rqstp);
	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -902,7 +902,7 @@ nfsd(void *vrqstp)
	 * The main request loop
	 */
	while (!svc_thread_should_stop(rqstp)) {
		svc_recv(rqstp);
		svc_recv(rqstp, 0);
		nfsd_file_net_dispose(nn);
	}

+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ enum {
	SP_TASK_PENDING,	/* still work to do even if no xprt is queued */
	SP_NEED_VICTIM,		/* One thread needs to agree to exit */
	SP_VICTIM_REMAINS,	/* One thread needs to actually exit */
	SP_TASK_STARTING,	/* Task has started but not added to idle yet */
};


+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ static inline u32 svc_sock_final_rec(struct svc_sock *svsk)
/*
 * Function prototypes.
 */
void		svc_recv(struct svc_rqst *rqstp);
int		svc_recv(struct svc_rqst *rqstp, long timeo);
void		svc_send(struct svc_rqst *rqstp);
int		svc_addsock(struct svc_serv *serv, struct net *net,
			    const int fd, char *name_return, const size_t len,
Loading