Skip to content

Commit

Permalink
SUNRPC: Ensure that the transport layer respect major timeouts
Browse files Browse the repository at this point in the history
Ensure that when in the transport layer, we don't sleep past
a major timeout.

Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
trondmy authored and amschuma-ntap committed Apr 25, 2019
1 parent 4312358 commit 9e910bf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions net/sunrpc/xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ static void xprt_destroy(struct rpc_xprt *xprt);
static DEFINE_SPINLOCK(xprt_list_lock);
static LIST_HEAD(xprt_list);

static unsigned long xprt_request_timeout(const struct rpc_rqst *req)
{
unsigned long timeout = jiffies + req->rq_timeout;

if (time_before(timeout, req->rq_majortimeo))
return timeout;
return req->rq_majortimeo;
}

/**
* xprt_register_transport - register a transport implementation
* @transport: transport to register
Expand Down Expand Up @@ -212,7 +221,7 @@ int xprt_reserve_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
task->tk_status = -EAGAIN;
if (RPC_IS_SOFT(task))
rpc_sleep_on_timeout(&xprt->sending, task, NULL,
jiffies + req->rq_timeout);
xprt_request_timeout(req));
else
rpc_sleep_on(&xprt->sending, task, NULL);
return 0;
Expand Down Expand Up @@ -279,7 +288,7 @@ int xprt_reserve_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task)
task->tk_status = -EAGAIN;
if (RPC_IS_SOFT(task))
rpc_sleep_on_timeout(&xprt->sending, task, NULL,
jiffies + req->rq_timeout);
xprt_request_timeout(req));
else
rpc_sleep_on(&xprt->sending, task, NULL);
return 0;
Expand Down Expand Up @@ -795,7 +804,7 @@ void xprt_connect(struct rpc_task *task)
if (!xprt_connected(xprt)) {
task->tk_rqstp->rq_connect_cookie = xprt->connect_cookie;
rpc_sleep_on_timeout(&xprt->pending, task, NULL,
jiffies + task->tk_rqstp->rq_timeout);
xprt_request_timeout(task->tk_rqstp));

if (test_bit(XPRT_CLOSING, &xprt->state))
return;
Expand Down Expand Up @@ -1087,7 +1096,7 @@ void xprt_wait_for_reply_request_def(struct rpc_task *task)
struct rpc_rqst *req = task->tk_rqstp;

rpc_sleep_on_timeout(&req->rq_xprt->pending, task, xprt_timer,
jiffies + req->rq_timeout);
xprt_request_timeout(req));
}
EXPORT_SYMBOL_GPL(xprt_wait_for_reply_request_def);

Expand Down

0 comments on commit 9e910bf

Please sign in to comment.