From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 5/8] sm-notify: Refactor insert_host() and recv_rpcbind_reply()
Date: Mon, 12 Sep 2011 18:06:41 -0400 [thread overview]
Message-ID: <20110912220641.10854.80600.stgit@matisse.1015granger.net> (raw)
In-Reply-To: <20110912220304.10854.20972.stgit@matisse.1015granger.net>
Clean up: refactor the logic in recv_rpcbind_reply() that re-schedules
an nsm_host into a separate helper function
Adjust debugging messages so it's always apparent when an nsm_host is
rescheduled.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/statd/sm-notify.c | 42 ++++++++++++++++++++++++++----------------
1 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
index 2421f8b..46447e8 100644
--- a/utils/statd/sm-notify.c
+++ b/utils/statd/sm-notify.c
@@ -252,7 +252,6 @@ smn_get_host(const char *hostname,
return 0;
insert_host(host);
- xlog(D_GENERAL, "Added host %s to notify list", hostname);
return 1;
}
@@ -688,6 +687,25 @@ notify_host(int sock, struct nsm_host *host)
return 0;
}
+static void
+smn_defer(struct nsm_host *host)
+{
+ host->xid = 0;
+ host->send_next = time(NULL) + NSM_MAX_TIMEOUT;
+ host->timeout = NSM_MAX_TIMEOUT;
+ insert_host(host);
+}
+
+static void
+smn_schedule(struct nsm_host *host)
+{
+ host->xid = 0;
+ host->send_next = time(NULL);
+ if (host->timeout >= NSM_MAX_TIMEOUT / 4)
+ host->timeout = NSM_MAX_TIMEOUT / 4;
+ insert_host(host);
+}
+
/*
* Extract the returned port number and set up the SM_NOTIFY call.
*/
@@ -696,21 +714,16 @@ recv_rpcbind_reply(struct sockaddr *sap, struct nsm_host *host, XDR *xdr)
{
uint16_t port = nsm_recv_rpcbind(sap->sa_family, xdr);
- host->send_next = time(NULL);
- host->xid = 0;
-
if (port == 0) {
/* No binding for statd... */
xlog(D_GENERAL, "No statd on host %s", host->name);
- host->timeout = NSM_MAX_TIMEOUT;
- host->send_next += NSM_MAX_TIMEOUT;
+ smn_defer(host);
} else {
+ xlog(D_GENERAL, "Processing rpcbind reply for %s (port %u)",
+ host->name, port);
nfs_set_port(sap, port);
- if (host->timeout >= NSM_MAX_TIMEOUT / 4)
- host->timeout = NSM_MAX_TIMEOUT / 4;
+ smn_schedule(host);
}
-
- insert_host(host);
}
/*
@@ -727,11 +740,7 @@ recv_notify_reply(struct nsm_host *host)
if (dot != NULL) {
*dot = '\0';
- host->send_next = time(NULL);
- host->xid = 0;
- if (host->timeout >= NSM_MAX_TIMEOUT / 4)
- host->timeout = NSM_MAX_TIMEOUT / 4;
- insert_host(host);
+ smn_schedule(host);
} else {
xlog(D_GENERAL, "Host %s notified successfully", host->name);
smn_forget_host(host);
@@ -780,7 +789,7 @@ out:
}
/*
- * Insert host into sorted list
+ * Insert host into notification list, sorted by next send time
*/
static void
insert_host(struct nsm_host *host)
@@ -805,6 +814,7 @@ insert_host(struct nsm_host *host)
host->next = *where;
*where = host;
+ xlog(D_GENERAL, "Added host %s to notify list", host->name);
}
/*
next prev parent reply other threads:[~2011-09-12 22:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-12 22:05 [PATCH 0/8] Fixes for nfs-utils-1.2.next Chuck Lever
2011-09-12 22:06 ` [PATCH 1/8] configure.ac: Fix help string for --with-statedir= option Chuck Lever
2011-09-12 22:06 ` [PATCH 2/8] configure.ac: Clean up help string for --enable-mount Chuck Lever
2011-09-12 22:06 ` [PATCH 3/8] configure.ac: Add --with-statd-extension configure option Chuck Lever
2011-09-17 12:28 ` Steve Dickson
2011-09-18 11:49 ` Jeff Layton
2011-09-19 10:46 ` Steve Dickson
2011-09-19 17:56 ` Steve Dickson
2011-09-19 18:13 ` Jeff Layton
2011-09-19 19:36 ` Chuck Lever
2011-09-20 11:53 ` Steve Dickson
2011-09-20 16:14 ` Chuck Lever
2011-09-12 22:06 ` [PATCH 4/8] nfsumount: Squelch compiler warning Chuck Lever
2011-09-12 22:06 ` Chuck Lever [this message]
2011-09-12 22:06 ` [PATCH 6/8] sm-notify: Use correct retransmit timeout when sending a fresh RPC Chuck Lever
2011-09-12 22:06 ` [PATCH 7/8] sm-notify: Avoid extra rpcbind queries Chuck Lever
2011-09-12 22:07 ` [PATCH 8/8] sm-notify: sm-notify leaves monitor records in sm.bak Chuck Lever
2011-09-20 11:36 ` [PATCH 0/8] Fixes for nfs-utils-1.2.next 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=20110912220641.10854.80600.stgit@matisse.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).