Blame SOURCES/nfs-utils-1.3.0-statd-notify-grace-period.patch

fc3648
diff --git a/nfs.conf b/nfs.conf
fc3648
new file mode 100644
fc3648
index 0000000..690645c
fc3648
--- /dev/null
fc3648
+++ b/nfs.conf
fc3648
@@ -0,0 +1,71 @@
fc3648
+#
fc3648
+# This is a general conifguration for the 
fc3648
+# NFS daemons and tools
fc3648
+#
fc3648
+#[exportfs]
fc3648
+# debug=0
fc3648
+#
fc3648
+#[gssd]
fc3648
+# use-memcache=0
fc3648
+# use-machine-creds=1
fc3648
+# avoid-dns=1
fc3648
+# limit-to-legacy-enctypes=0
fc3648
+# context-timeout=0
fc3648
+# rpc-timeout=5
fc3648
+# pipefs-directory=/var/lib/nfs/rpc_pipefs
fc3648
+# keytab-file=/etc/krb5.keytab
fc3648
+# cred-cache-directory=
fc3648
+# preferred-realm=
fc3648
+#
fc3648
+#[lockd]
fc3648
+# port=0
fc3648
+# udp-port=0
fc3648
+#
fc3648
+#[mountd]
fc3648
+# debug=0
fc3648
+# manage_gids=n
fc3648
+# descriptors=0
fc3648
+# port=0
fc3648
+# threads=1
fc3648
+# reverse-lookup=n
fc3648
+# state-directory-path=/var/lib/nfs
fc3648
+# ha-callout=
fc3648
+#
fc3648
+#[nfsdcltrack]
fc3648
+# debug=0
fc3648
+# storagedir=/var/lib/nfs/nfsdcltrack
fc3648
+#
fc3648
+#[nfsd]
fc3648
+# debug=0
fc3648
+# threads=8
fc3648
+# host=
fc3648
+# port=0
fc3648
+# grace-time=90
fc3648
+# lease-time=90
fc3648
+# udp=y
fc3648
+# tcp=y
fc3648
+# vers2=n
fc3648
+# vers3=y
fc3648
+# vers4=y
fc3648
+# vers4.0=y
fc3648
+# vers4.1=y
fc3648
+# vers4.2=y
fc3648
+# rdma=n
fc3648
+#
fc3648
+#[statd]
fc3648
+# debug=0
fc3648
+# port=0
fc3648
+# outgoing-port=0
fc3648
+# name=
fc3648
+# state-directory-path=/var/lib/nfs/statd
fc3648
+# ha-callout=
fc3648
+#
fc3648
+#[sm-notify]
fc3648
+# debug=0
fc3648
+# retry-time=900
fc3648
+# outgoing-port=
fc3648
+# outgoing-addr=
fc3648
+# lift-grace=y
fc3648
+#
fc3648
+#[svcgssd]
fc3648
+# principal=
fc3648
diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
fc3648
index dcb85a3..ec59311 100644
fc3648
--- a/utils/statd/sm-notify.c
fc3648
+++ b/utils/statd/sm-notify.c
fc3648
@@ -46,6 +46,10 @@
fc3648
 #define NSM_TIMEOUT	2
fc3648
 #define NSM_MAX_TIMEOUT	120	/* don't make this too big */
fc3648
 
fc3648
+#define NLM_END_GRACE_FILE	"/proc/fs/lockd/nlm_end_grace"
fc3648
+
fc3648
+int lift_grace = 1;
fc3648
+
fc3648
 struct nsm_host {
fc3648
 	struct nsm_host *	next;
fc3648
 	char *			name;
fc3648
@@ -456,6 +460,28 @@ retry:
fc3648
 	return sock;
fc3648
 }
fc3648
 
fc3648
+/* Inform the kernel that it's OK to lift lockd's grace period */
fc3648
+static void
fc3648
+nsm_lift_grace_period(void)
fc3648
+{
fc3648
+	int fd;
fc3648
+
fc3648
+	fd = open(NLM_END_GRACE_FILE, O_WRONLY);
fc3648
+	if (fd < 0) {
fc3648
+		/* Don't warn if file isn't present */
fc3648
+		if (errno != ENOENT)
fc3648
+			xlog(L_WARNING, "Unable to open %s: %m",
fc3648
+				NLM_END_GRACE_FILE);
fc3648
+		return;
fc3648
+	}
fc3648
+
fc3648
+	if (write(fd, "Y", 1) < 0)
fc3648
+		xlog(L_WARNING, "Unable to write to %s: %m", NLM_END_GRACE_FILE);
fc3648
+
fc3648
+	close(fd);
fc3648
+	return;
fc3648
+}
fc3648
+
fc3648
 int
fc3648
 main(int argc, char **argv)
fc3648
 {
fc3648
@@ -474,6 +500,7 @@ main(int argc, char **argv)
fc3648
 	opt_max_retry = conf_get_num("sm-notify", "retry-time", opt_max_retry / 60) * 60;
fc3648
 	opt_srcport = conf_get_str("sm-notify", "outgoing-port");
fc3648
 	opt_srcaddr = conf_get_str("sm-notify", "outgoing-addr");
fc3648
+	lift_grace = conf_get_bool("sm-notify", "lift-grace", lift_grace);
fc3648
 	s = conf_get_str("statd", "state-directory-path");
fc3648
 	if (s && !nsm_setup_pathnames(argv[0], s))
fc3648
 		exit(1);
fc3648
@@ -550,6 +577,8 @@ usage:		fprintf(stderr,
fc3648
 	(void)nsm_retire_monitored_hosts();
fc3648
 	if (nsm_load_notify_list(smn_get_host) == 0) {
fc3648
 		xlog(D_GENERAL, "No hosts to notify; exiting");
fc3648
+		if (lift_grace)
fc3648
+			nsm_lift_grace_period();
fc3648
 		return 0;
fc3648
 	}
fc3648
 
fc3648
diff --git a/utils/statd/sm-notify.man b/utils/statd/sm-notify.man
fc3648
index 89627e5..4658d86 100644
fc3648
--- a/utils/statd/sm-notify.man
fc3648
+++ b/utils/statd/sm-notify.man
fc3648
@@ -241,6 +241,24 @@ These have the same effect as the command line options
fc3648
 .B v
fc3648
 respectively.
fc3648
 
fc3648
+An additional value recognized in the
fc3648
+.B [sm-notify]
fc3648
+section is
fc3648
+.BR lift-grace .
fc3648
+By default,
fc3648
+.B sm-notify
fc3648
+will lift lockd's grace period early if it has no hosts to notify.
fc3648
+Some high availability configurations will run one
fc3648
+.B sm-notify
fc3648
+per floating IP address.  In these configurations, lifting the
fc3648
+grace period early may prevent clients from reclaiming locks.
fc3648
+.RB "Setting " lift-grace " to " n
fc3648
+will prevent
fc3648
+.B sm-notify
fc3648
+from ending the grace period early.
fc3648
+.B lift-grace
fc3648
+has no corresponding command line option.
fc3648
+
fc3648
 The value recognized in the
fc3648
 .B [statd]
fc3648
 section is