60.nfs and 60.ganesha touch $statd_update_trigger every time they're
run. This stops the statd-callout updates from ever being called.
Make this logic self-contained and move it to new function
nfs_statd_update() in the functions file. Call this in 60.nfs and
60.ganesha with the appropriate update period as the only argument.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reported-by: Poornima Gupte <poornima.gupte@in.ibm.com>
(This used to be ctdb commit
1b5968f6be084590667f4f15ff3bef13ed9a2973)
ctdb_setup_service_state_dir
-statd_update_trigger="$service_state_dir/update-trigger"
-# We want this file to always exist. The corner case is when
-# auto-start/stop is switched off, NFS is added as a managed service
-# some time after ctdbd is started and someone else starts the NFS
-# service for us. In this case this file might not otherwise exist
-# when we get to a monitor event.
-touch "$statd_update_trigger"
-
ctdb_start_stop_service
is_ctdb_managed_service || exit 0
# once every 60 seconds, update the statd state database for which
# clients need notifications
- LAST_UPDATE=`stat --printf="%Y" "$statd_update_trigger" 2>/dev/null`
- CURRENT_TIME=`date +"%s"`
- [ $CURRENT_TIME -ge $(($LAST_UPDATE + 60)) ] && {
- touch "$statd_update_trigger"
- $CTDB_BASE/statd-callout updatelocal &
- $CTDB_BASE/statd-callout updateremote &
- }
+ nfs_statd_update 60
;;
*)
ctdb_setup_service_state_dir
-statd_update_trigger="$service_state_dir/update-trigger"
-# We want this file to always exist. The corner case is when
-# auto-start/stop is switched off, NFS is added as a managed service
-# some time after ctdbd is started and someone else starts the NFS
-# service for us. In this case this file might not otherwise exist
-# when we get to a monitor event.
-touch "$statd_update_trigger"
-
ctdb_start_stop_service
is_ctdb_managed_service || exit 0
nfs_check_rpc_services
- # once every 600 seconds, update the statd state database for which
+ # Every 10 minutes, update the statd state database for which
# clients need notifications
- LAST_UPDATE=`stat --printf="%Y" "$statd_update_trigger"`
- CURRENT_TIME=`date +"%s"`
- [ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
- touch "$statd_update_trigger"
- $CTDB_BASE/statd-callout updatelocal &
- $CTDB_BASE/statd-callout updateremote &
- }
+ nfs_statd_update 600
;;
*)
esac
}
+# Periodically update the statd database
+nfs_statd_update ()
+{
+ _update_period="$1"
+
+ _statd_update_trigger="$service_state_dir/update-trigger"
+ [ -f "$_statd_update_trigger" ] || touch "$_statd_update_trigger"
+
+ _last_update=$(stat --printf="%Y" "$_statd_update_trigger")
+ _current_time=$(date +"%s")
+ if [ $(( $_current_time - $_last_update)) -ge $_update_period ] ; then
+ touch "$_statd_update_trigger"
+ $CTDB_BASE/statd-callout updatelocal &
+ $CTDB_BASE/statd-callout updateremote &
+ fi
+}
+
add_ip_to_iface()
{
_iface=$1