summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2015-07-14 12:11:39 +1000
committerAmitay Isaacs <amitay@samba.org>2015-07-14 09:57:18 +0200
commitfa6f22d7ae4bbec9449572f312bd89dce815e561 (patch)
tree39984e7c669509bf8f9399f6ce600d20df0d9706 /ctdb
parent3b32c641894c3f5a86c93b613110be6edbfe98d2 (diff)
downloadsamba-fa6f22d7ae4bbec9449572f312bd89dce815e561.tar.gz
ctdb-scripts: Add registration for CTDB_NFS_CALLOUT operations
This is an optimisation to avoid forking the callout for operations that are not implemented. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/config/events.d/60.nfs45
-rwxr-xr-xctdb/config/nfs-ganesha-callout2
-rwxr-xr-xctdb/config/nfs-linux-kernel-callout4
3 files changed, 45 insertions, 6 deletions
diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs
index 957d8eaab75..fce6beb9118 100755
--- a/ctdb/config/events.d/60.nfs
+++ b/ctdb/config/events.d/60.nfs
@@ -7,6 +7,10 @@
. $CTDB_BASE/functions
service_name="nfs"
+loadconfig
+ctdb_setup_service_state_dir
+
+######################################################################
if [ -z "$CTDB_NFS_CALLOUT" ] ; then
CTDB_NFS_CALLOUT="${CTDB_BASE}/nfs-linux-kernel-callout"
@@ -14,9 +18,44 @@ fi
# Always export, for statd callout
export CTDB_NFS_CALLOUT
+nfs_callout_cache="${service_state_dir}/nfs_callout_cache"
+nfs_callout_cache_callout="${nfs_callout_cache}/CTDB_NFS_CALLOUT"
+nfs_callout_cache_ops="${nfs_callout_cache}/ops"
+
+nfs_callout_register ()
+{
+ mkdir -p "$nfs_callout_cache_ops"
+ rm -f "$nfs_callout_cache_ops"/*
+
+ echo "$CTDB_NFS_CALLOUT" >"$nfs_callout_cache_callout"
+
+ _t=$(eval "$CTDB_NFS_CALLOUT" "register")
+ if [ -n "$_t" ] ; then
+ echo "$_t" |
+ while IFS="" read _op ; do
+ touch "${nfs_callout_cache_ops}/${_op}"
+ done
+ else
+ touch "${nfs_callout_cache_ops}/ALL"
+ fi
+}
+
nfs_callout ()
{
- eval "$CTDB_NFS_CALLOUT" "$@"
+ # Re-run registration if $CTDB_NFS_CALLOUT has changed
+ _prev=""
+ if [ -r "$nfs_callout_cache_callout" ] ; then
+ read _prev <"$nfs_callout_cache_callout"
+ fi
+ if [ "$CTDB_NFS_CALLOUT" != "$_prev" ] ; then
+ nfs_callout_register
+ fi
+
+ # Run the operation if it is registered...
+ if [ -e "${nfs_callout_cache_ops}/${1}" ] || \
+ [ -e "${nfs_callout_cache_ops}/ALL" ]; then
+ eval "$CTDB_NFS_CALLOUT" "$@"
+ fi
}
service_reconfigure ()
@@ -234,10 +273,6 @@ nfs_update_lock_info ()
######################################################################
-loadconfig
-
-ctdb_setup_service_state_dir
-
ctdb_start_stop_service
is_ctdb_managed_service || exit 0
diff --git a/ctdb/config/nfs-ganesha-callout b/ctdb/config/nfs-ganesha-callout
index 0d510e779ea..b66611c84f9 100755
--- a/ctdb/config/nfs-ganesha-callout
+++ b/ctdb/config/nfs-ganesha-callout
@@ -290,7 +290,7 @@ case "$action" in
releaseip) nfs_releaseip "$@" ;;
takeip) nfs_takeip "$@" ;;
monitor-list-shares) nfs_monitor_list_shares ;;
- monitor-pre|monitor-post)
+ register|monitor-pre|monitor-post)
# Not required/implemented
:
;;
diff --git a/ctdb/config/nfs-linux-kernel-callout b/ctdb/config/nfs-linux-kernel-callout
index 59618d79dfb..31810d0f7d4 100755
--- a/ctdb/config/nfs-linux-kernel-callout
+++ b/ctdb/config/nfs-linux-kernel-callout
@@ -32,6 +32,7 @@ usage ()
usage: $_c { shutdown | startup }
$_c { stop | start } { nfs | nlockmgr }
$_c { monitor-list-shares | monitor-post }
+ $_c { register }
EOF
exit 1
}
@@ -196,6 +197,9 @@ case "$1" in
monitor-post)
nfs_check_thread_count
;;
+ register)
+ : # Nothing yet
+ ;;
monitor-pre|releaseip|takeip)
# Not required/implemented
: