[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Make NFSv4 lease time configurable



Add a new parameter, "NFSV4LEASETIME" to the defaults file. In the
init script, echo this value into /proc/fs/nfsd/nfsv4leasetime
immediately after nfsd is mounted.

Rationale:

When an NFSv4 client has no chance to give up a lease (for example,
when the IP address that it connects through simply goes away on the
server), then the server retains that lease for n seconds, where n is
the value specified in nfsv4leasetime. During that time, it continues
to hold an open file handle in the underlying local file system,
preventing it from being unmounted.

This is a relatively common scenario for highly-available NFS
services: a high availability cluster mounts a file system located on
shared or replicated storage, then exports it via NFS, using a virtual
IP address that floats between nodes. When the cluster administrator
initiates a migration of the NFS service to a different node, the
cluster management performs the following actions:

1. take down the IP address,
2. un-export the directory,
3. unmount the filesystem,
4. transition to another cluster node,
5. mount the filesystem,
6. export the directory,
7. bring up the IP address.

During this transition, between steps 2 and 3, it has to ride out the
nfsv4leasetime, so that the NFS server gives up all file handles on
the underlying filesystem, and subsequently allows the filesystem to
be unmounted.

The nfsv4leasetime is a whopping 90 seconds by default, which greatly
prolongs such a resource migration. Make it configurable so that high
availability cluster administrators have a chance to speed up that
process.
---
 debian/nfs-kernel-server.default |    3 +++
 debian/nfs-kernel-server.init    |    5 +++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/debian/nfs-kernel-server.default b/debian/nfs-kernel-server.default
index d3ff49f..cb3da0e 100644
--- a/debian/nfs-kernel-server.default
+++ b/debian/nfs-kernel-server.default
@@ -16,3 +16,6 @@ NEED_SVCGSSD=
 
 # Options for rpc.svcgssd.
 RPCSVCGSSDOPTS=
+
+# NFSv4 lease time, in seconds. If unset, the default is 90.
+NFSV4LEASETIME=
diff --git a/debian/nfs-kernel-server.init b/debian/nfs-kernel-server.init
index bec2d02..bf51704 100644
--- a/debian/nfs-kernel-server.init
+++ b/debian/nfs-kernel-server.init
@@ -30,6 +30,7 @@ RPCMOUNTDOPTS=
 NEED_SVCGSSD=no
 RPCSVCGSSDOPTS=
 PROCNFSD_MOUNTPOINT=/proc/fs/nfsd
+NFSV4LEASETIME=90
 if [ -f $DEFAULTFILE ]; then
     . $DEFAULTFILE
 fi
@@ -70,6 +71,10 @@ case "$1" in
 		fi
 		
 		do_mount nfsd $PROCNFSD_MOUNTPOINT || NEED_SVCGSSD=no
+		# Set the NFSv4 lease time. This must be done before
+		# the NFS server starts
+		echo $NFSV4LEASETIME > /proc/fs/nfsd/nfsv4leasetime
+
 		log_begin_msg "Exporting directories for $DESC..."
 		$PREFIX/sbin/exportfs -r
 		RET=$?
-- 
1.7.0.4


Reply to: