SUNRPC: Fix possible autodisconnect during connect due to stale last_used
diff mbox series

Message ID 1561578606-24602-1-git-send-email-dwysocha@redhat.com
State New
Headers show
Series
  • SUNRPC: Fix possible autodisconnect during connect due to stale last_used
Related show

Commit Message

Dave Wysochanski June 26, 2019, 7:50 p.m. UTC
When a connection is successful ensure last_used is updated before calling
xprt_schedule_autodisconnect inside xprt_unlock_connect.  This avoids a
possible xprt_autoclose firing immediately after connect sequence due to
an old value of last_used given to mod_timer in xprt_schedule_autodisconnect.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
---
 net/sunrpc/xprt.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Trond Myklebust June 26, 2019, 8:11 p.m. UTC | #1
On Wed, 2019-06-26 at 15:50 -0400, Dave Wysochanski wrote:
> When a connection is successful ensure last_used is updated before
> calling
> xprt_schedule_autodisconnect inside xprt_unlock_connect.  This avoids
> a
> possible xprt_autoclose firing immediately after connect sequence due
> to
> an old value of last_used given to mod_timer in
> xprt_schedule_autodisconnect.
> 
> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> ---
>  net/sunrpc/xprt.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> index f6c82b1..fceaede 100644
> --- a/net/sunrpc/xprt.c
> +++ b/net/sunrpc/xprt.c
> @@ -800,6 +800,7 @@ void xprt_unlock_connect(struct rpc_xprt *xprt,
> void *cookie)
>  		goto out;
>  	xprt->snd_task =NULL;
>  	xprt->ops->release_xprt(xprt, NULL);
> +	xprt->last_used = jiffies;
>  	xprt_schedule_autodisconnect(xprt);
>  out:
>  	spin_unlock_bh(&xprt->transport_lock);

Let's just move that line into xprt_schedule_autodisconnect(), since in
practice this means all callers are doing the same thing.
Dave Wysochanski June 26, 2019, 8:14 p.m. UTC | #2
On Wed, 2019-06-26 at 20:11 +0000, Trond Myklebust wrote:
> On Wed, 2019-06-26 at 15:50 -0400, Dave Wysochanski wrote:
> > When a connection is successful ensure last_used is updated before
> > calling
> > xprt_schedule_autodisconnect inside xprt_unlock_connect.  This
> > avoids
> > a
> > possible xprt_autoclose firing immediately after connect sequence
> > due
> > to
> > an old value of last_used given to mod_timer in
> > xprt_schedule_autodisconnect.
> > 
> > Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> > ---
> >  net/sunrpc/xprt.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> > index f6c82b1..fceaede 100644
> > --- a/net/sunrpc/xprt.c
> > +++ b/net/sunrpc/xprt.c
> > @@ -800,6 +800,7 @@ void xprt_unlock_connect(struct rpc_xprt *xprt,
> > void *cookie)
> >  		goto out;
> >  	xprt->snd_task =NULL;
> >  	xprt->ops->release_xprt(xprt, NULL);
> > +	xprt->last_used = jiffies;
> >  	xprt_schedule_autodisconnect(xprt);
> >  out:
> >  	spin_unlock_bh(&xprt->transport_lock);
> 
> Let's just move that line into xprt_schedule_autodisconnect(), since
> in
> practice this means all callers are doing the same thing.
> 
> 

Will do and resubmit - thanks!

Patch
diff mbox series

diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index f6c82b1..fceaede 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -800,6 +800,7 @@  void xprt_unlock_connect(struct rpc_xprt *xprt, void *cookie)
 		goto out;
 	xprt->snd_task =NULL;
 	xprt->ops->release_xprt(xprt, NULL);
+	xprt->last_used = jiffies;
 	xprt_schedule_autodisconnect(xprt);
 out:
 	spin_unlock_bh(&xprt->transport_lock);