Skip to content

Commit

Permalink
SUNRPC: Fix a regression when reconnecting
Browse files Browse the repository at this point in the history
If the task needs to give up the socket lock in order to allow a
reconnect to occur, then it must also clear the 'rq_bytes_sent' field
so that when it retransmits, it knows to start from the beginning.

Fixes: 718ba5b ("SUNRPC: Add helpers to prevent socket create from racing")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Trond Myklebust committed Mar 27, 2015
1 parent 09a330f commit 0695314
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions net/sunrpc/xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ static void __xprt_lock_write_next_cong(struct rpc_xprt *xprt)
xprt_clear_locked(xprt);
}

static void xprt_task_clear_bytes_sent(struct rpc_task *task)
{
if (task != NULL) {
struct rpc_rqst *req = task->tk_rqstp;
if (req != NULL)
req->rq_bytes_sent = 0;
}
}

/**
* xprt_release_xprt - allow other requests to use a transport
* @xprt: transport with other tasks potentially waiting
Expand All @@ -336,11 +345,7 @@ static void __xprt_lock_write_next_cong(struct rpc_xprt *xprt)
void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
{
if (xprt->snd_task == task) {
if (task != NULL) {
struct rpc_rqst *req = task->tk_rqstp;
if (req != NULL)
req->rq_bytes_sent = 0;
}
xprt_task_clear_bytes_sent(task);
xprt_clear_locked(xprt);
__xprt_lock_write_next(xprt);
}
Expand All @@ -358,11 +363,7 @@ EXPORT_SYMBOL_GPL(xprt_release_xprt);
void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task)
{
if (xprt->snd_task == task) {
if (task != NULL) {
struct rpc_rqst *req = task->tk_rqstp;
if (req != NULL)
req->rq_bytes_sent = 0;
}
xprt_task_clear_bytes_sent(task);
xprt_clear_locked(xprt);
__xprt_lock_write_next_cong(xprt);
}
Expand Down Expand Up @@ -700,6 +701,7 @@ bool xprt_lock_connect(struct rpc_xprt *xprt,
goto out;
if (xprt->snd_task != task)
goto out;
xprt_task_clear_bytes_sent(task);
xprt->snd_task = cookie;
ret = true;
out:
Expand Down

0 comments on commit 0695314

Please sign in to comment.