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

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