Eventscripts: work around NFS restart failure under load.
authorMartin Schwenke <martin@meltin.net>
Tue, 11 Jan 2011 06:06:48 +0000 (17:06 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 11 Jan 2011 05:47:24 +0000 (16:47 +1100)
"service nfs restart" can fail.  To stop nfsd it sends a SIGINT and
nfsd might take a while to process it if the system is loaded.
Starting nfsd may then fail because resources are still in use.

This does some /proc magic to tell nfsd to do no more processing.  It
then runs service stop, kills nfsd with SIGKILL, and then runs service
start.  This is much less likely to fail.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/functions

index 4dc645b7985046b4dff1745446f5fc8dd1f0f2cb..599e46a5f3798e5ba048ac7cbc5a02deb9703c91 100755 (executable)
@@ -375,7 +375,10 @@ startstop_nfs() {
                        service nfsserver stop > /dev/null 2>&1
                        ;;
                restart)
-                       service nfsserver restart
+                       echo 0 >/proc/fs/nfsd/threads
+                       service nfsserver stop > /dev/null 2>&1
+                       pkill -9 nfsd
+                       service nfsserver start
                        ;;
                esac
                ;;
@@ -390,8 +393,12 @@ startstop_nfs() {
                        service nfslock stop > /dev/null 2>&1
                        ;;
                restart)
-                       service nfslock restart
-                       service nfs restart
+                       echo 0 >/proc/fs/nfsd/threads
+                       service nfs stop > /dev/null 2>&1
+                       service nfslock stop > /dev/null 2>&1
+                       pkill -9 nfsd
+                       service nfslock start
+                       service nfs start
                        ;;
                esac
                ;;