Nfs – Dual Linux NFS Server Failover – nfsv4leastime / nfsv4gracetime

failoverfailoverclusternfsnfs4

first time here posting, i hope i won't do many mistakes.

I've a setup with 2 NFS server. They're using corosync/pacemaker + drbd to offer active/passive nfs server. Distro used is Ubuntu latest LTS version.

Cluster is also offering a floating ip for clients to connect.
Volume replication works fine.

The problem is that during the failover the i/o operations wait for approx 90 seconds.
After failover (with the new machine already promoted as new master) tcpdump on the client shows packets like:

reply ok 52 getattr ERROR: unk 10013

Looking for Error 10013 and nfs on google leaded me to this usenet post

So my locks are retained to the nfs server and only after 90 sec they're freed. I need to lower that parameter (contained in /proc) but when i try

root@nfs-ha-1:/# ls -l /proc/fs/nfsd/nfsv4gracetime
-rw------- 1 root root 0 Jan 31 11:00 /proc/fs/nfsd/nfsv4gracetime
root@nfs-ha-1:/# cat /proc/fs/nfsd/nfsv4gracetime
90
root@nfs-ha-1:/# echo 1 > /proc/fs/nfsd/nfsv4gracetime
bash: echo: write error: Device or resource busy
root@nfs-ha-1:/#

So i'm need of further info about this issue, or a way to write on that file.
The files are created at run time with nfs-server. If i stop the nfsserver they directory is simply empty, and i cannot write to it.

root@nfs-ha-1:/proc/fs/nfsd# touch nfsv4gracetime
touch: cannot touch `nfsv4gracetime': No such file or directory

Best Answer

I want to make this follow up to explain what was the problem and how to solve it. The parameters can be modified only at certain moments.

If you try to write on /proc/fs/nfsd with the nfs-kernel stopped (module unloaded) the file are simply not existant. If you try after launching the nfs-kernel you'll get the device busy error.

The solution is to edit the init script for nfs-kernel-server and modify the parameters (through the usual echo on the needed files) after the modprobe of the module.

So you need to to write the parameters between the do_modprobe and do_mount directive.

Sample from /etc/init.d/nfs-kernel-server of ubuntu 12.04 LTS

# See how we were called.
case "$1" in
  start)
        if [ -f /etc/exports ]
        then
                do_modprobe nfsd
                echo 15 > /proc/fs/nfsd/nfsv4leasetime
                echo 25 > /proc/fs/nfsd/nfsv4gracetime

                # See if our running kernel supports the NFS kernel server
                if ! grep -E -qs "[[:space:]]nfsd\$" /proc/filesystems; then
                        log_warning_msg "Not starting $DESC: no support in current kernel."
                        exit 0
                fi
                do_mount nfsd $PROCNFSD_MOUNTPOINT || NEED_SVCGSSD=no
Related Topic