2 # script to manage nfs in a clustered environment
5 /bin/mkdir -p $CTDB_VARDIR/state/nfs
6 /bin/mkdir -p $CTDB_VARDIR/state/statd/ip
9 echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
12 . $CTDB_BASE/functions
16 [ "$NFS_SERVER_MODE" == "GANESHA" ] || exit 0
18 service_name="nfs-ganesha-gpfs"
20 ctdb_start_stop_service
22 is_ctdb_managed_service || exit 0
26 # read statd from persistent database
30 mkdir -p $CTDB_VARDIR/state/statd
31 touch $CTDB_VARDIR/state/statd/update-trigger
39 ctdb_service_set_reconfigure
43 ctdb_service_set_reconfigure
47 if ctdb_service_needs_reconfigure ; then
48 ctdb_service_reconfigure
54 # check that statd responds to rpc requests
55 # if statd is not running we try to restart it
56 if ctdb_check_rpc "STATD" status 1 >/dev/null ; then
57 (service_name="nfs_statd"; ctdb_counter_init)
59 p="rpc.statd" ; cmd="$p"
60 cmd="${cmd}${STATD_HOSTNAME:+ -n }${STATD_HOSTNAME}"
61 cmd="${cmd}${STATD_PORT:+ -p }${STATD_PORT}"
62 cmd="${cmd}${STATD_OUTGOING_PORT:+ -o }${STATD_OUTGOING_PORT}"
64 service_name="nfs_statd"
66 ctdb_check_counter_limit 10 quiet >/dev/null
68 echo "$ctdb_check_rpc_out"
69 echo "Trying to restart STATD [$cmd]"
74 # check that NFS responds to rpc requests
75 [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
76 if ctdb_check_rpc "NFS" nfs 3 >/dev/null ; then
77 (service_name="nfs_knfsd"; ctdb_counter_init)
80 service_name="nfs_knfsd"
83 ctdb_check_counter_equal 10 || {
84 echo "Trying to restart NFS service"
90 ctdb_check_counter_limit 15 quiet >/dev/null
92 echo "$ctdb_check_rpc_out"
93 echo "Trying to restart NFS service"
101 # and that its directories are available
102 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
103 grep Path /etc/ganesha/gpfs.ganesha.exports.conf |
104 cut -f2 -d\" | ctdb_check_directories
107 # check that lockd responds to rpc requests
108 ctdb_check_rpc "LOCKD" nlockmgr 4 || {
109 echo "Trying to restart lock manager service"
115 # check mounts responds to rpc requests
116 ctdb_check_rpc "MOUNTD" mountd 1 >/dev/null || {
117 echo "Trying to restart mountd service"
123 # rquotad needs special handling since it is sometimes not started
125 # this is not a critical service so we dont flag the node as unhealthy
126 ctdb_check_rpc "RQUOTAD" rquotad 1 || {
128 cmd="${p}${RQUOTAD_PORT:+ -p }${RQUOTAD_PORT}"
129 echo "Trying to restart RQUOTAD [${cmd}]"
134 # once every 60 seconds, update the statd state database for which
135 # clients need notifications
136 LAST_UPDATE=`stat --printf="%Y" $CTDB_VARDIR/state/statd/update-trigger 2>/dev/null`
137 CURRENT_TIME=`date +"%s"`
138 [ $CURRENT_TIME -ge $(($LAST_UPDATE + 60)) ] && {
139 mkdir -p $CTDB_VARDIR/state/statd
140 touch $CTDB_VARDIR/state/statd/update-trigger
141 $CTDB_BASE/statd-callout updatelocal &
142 $CTDB_BASE/statd-callout updateremote &
147 # if the ips have been reallocated, we must restart the lockmanager
148 # across all nodes and ping all statd listeners
149 [ -x $CTDB_BASE/statd-callout ] && {
150 $CTDB_BASE/statd-callout notify &
154 ctdb_standard_event_handler "$@"