From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 2/2] showmount: Use CLNT_CONTROL for version fallback
Date: Thu, 07 Jan 2010 11:26:30 -0500 [thread overview]
Message-ID: <20100107162630.27102.9464.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100107162421.27102.21422.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
When retrying MNT requests with lower RPC protocol versions, the
showmount command leaves several TCP sockets in TIME_WAIT: at least
one socket for each rpcbind GETPORT call, and one for each attempted
MNT request. Note that TIME_WAIT sockets may not be a problem on
an individual client, but this does tie up potentially valuable
network resources on the server for up to 120 seconds.
To reduce the resources required when retrying, downshift the RPC
protocol version of the existing RPC client using CLNT_CONTROL(),
rather than creating a new RPC client for each RPC protocol version.
Without this patch, "showmount -e" targeting a TCP-capable server with
a single export takes 64 packets and leaves 6 sockets in TIME_WAIT if
the server supports only MNTv1. With it, showmount takes 29 packets
and leaves two TIME_WAIT sockets.
Newer versions of libtirpc will reduce that by one more socket (on
IPv4), and a handful of packets.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/showmount/showmount.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index 652aa85..343f94b 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -193,12 +193,12 @@ int main(int argc, char **argv)
break;
}
-again:
mclient = nfs_get_mount_client(hostname, mount_vers_tbl[vers]);
mclient->cl_auth = authunix_create_default();
total_timeout.tv_sec = TOTAL_TIMEOUT;
total_timeout.tv_usec = 0;
+again:
if (eflag) {
memset(&exportlist, '\0', sizeof(exportlist));
@@ -207,8 +207,11 @@ again:
(xdrproc_t) xdr_exports, (caddr_t) &exportlist,
total_timeout);
if (clnt_stat == RPC_PROGVERSMISMATCH) {
- if (++vers < max_vers_tblsz)
+ if (++vers < max_vers_tblsz) {
+ (void)CLNT_CONTROL(mclient, CLSET_VERS,
+ (void *)&mount_vers_tbl[vers]);
goto again;
+ }
}
if (clnt_stat != RPC_SUCCESS) {
clnt_perror(mclient, "rpc mount export");
@@ -246,8 +249,11 @@ again:
(xdrproc_t) xdr_mountlist, (caddr_t) &dumplist,
total_timeout);
if (clnt_stat == RPC_PROGVERSMISMATCH) {
- if (++vers < max_vers_tblsz)
+ if (++vers < max_vers_tblsz) {
+ (void)CLNT_CONTROL(mclient, CLSET_VERS,
+ (void *)&mount_vers_tbl[vers]);
goto again;
+ }
}
if (clnt_stat != RPC_SUCCESS) {
clnt_perror(mclient, "rpc mount dump");
next prev parent reply other threads:[~2010-01-07 16:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-07 16:26 [PATCH 0/2] showmount bug fixes Chuck Lever
[not found] ` <20100107162421.27102.21422.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-01-07 16:26 ` [PATCH 1/2] showmount: Eliminate compiler warnings Chuck Lever
2010-01-07 16:26 ` Chuck Lever [this message]
2010-01-07 17:52 ` [PATCH 0/2] showmount bug fixes Steve Dickson
[not found] ` <4B461F48.4070906-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-07 18:38 ` Chuck Lever
2010-01-07 20:25 ` Steve Dickson
[not found] ` <4B464355.1000405-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-07 22:43 ` Chuck Lever
2010-01-07 23:32 ` Steve Dickson
2010-01-12 12:26 ` Steve Dickson
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=20100107162630.27102.9464.stgit@localhost.localdomain \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/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