Linux NFS development
 help / color / mirror / Atom feed
From: Olaf Kirch <okir@suse.de>
To: nfs@lists.sourceforge.net
Subject: task->tk_timeout = 0
Date: Thu, 26 Feb 2004 12:08:02 +0100	[thread overview]
Message-ID: <20040226110802.GE1197@suse.de> (raw)

Hi all,

I've been debugging mysterious hangs in the NFS clients for a while
now. The symptoms were always the same: NFS server goes away, comes back
after a long time, but the mount point remains stuck.

When inspecting the list of RPC tasks, I often found that one process
was on the pending queue (i.e. waiting for a reply) but task->tk_timeout
was 0.

I added a couple of diagnostic printks, and one of them triggered
yesterday, pointing to this piece of code in xprt_transmit:

if (!xprt->nocong) {
	int timer = task->tk_msg.rpc_proc->p_timer;
	timeout = rpc_calc_rto(clnt->cl_rtt, timer);
	timeout <<= rpc_ntimeo(clnt->cl_rtt, timer);
	timeout <<= clnt->cl_timeout.to_retries
		- req->rq_timeout.to_retries;
	if (timeout > req->rq_timeout.to_maxval)
		timeout = req->rq_timeout.to_maxval;
	else if (timeout == 0) {
		printk(KERN_ERR "RPC task timeout == 0, please tell okir\n");
		timeout = req->rq_timeout.to_maxval;
	}
	...
}

So apparently one of the shift operations above overflows.  I suspect
rpc_ntimeo because it can be arbitrarily large. But the ntimeouts value
isn't updated until we've received a reply (is this intentional, Trond?)

So what would have to happen for this bug to trigger is

	send request
	server hangs
	retransmit request 1000 times
	server comes back
	retransmit request
	receive reply, set ntimeout = 1000

	send another request. timeout overflows and becomes 0
	request gets lost
	task waits indefinitely.

I think the most robust way to fix this is simply this:

		- req->rq_timeout.to_retries;
	if (timeout > req->rq_timeout.to_maxval)
		timeout = req->rq_timeout.to_maxval;
-	if (timeout > req->rq_timeout.to_maxval)
+	if (!timeout || timeout > req->rq_timeout.to_maxval)
		timeout = req->rq_timeout.to_maxval;

It may also make sense to clamp the ntimeouts value to something
reasonable (e.g. 8)

Olaf
-- 
Olaf Kirch     |  Stop wasting entropy - start using predictable
okir@suse.de   |  tempfile names today!
---------------+ 


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

             reply	other threads:[~2004-02-26 11:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-26 11:08 Olaf Kirch [this message]
2004-02-26 12:50 ` task->tk_timeout = 0 trond.myklebust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040226110802.GE1197@suse.de \
    --to=okir@suse.de \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox