summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-01-04 09:53:54 +1100
committerMartin Schwenke <martins@samba.org>2018-03-01 19:39:15 +0100
commit2ad1604c2baa547ad881dc75cbb47722d0af651b (patch)
treefb2ae15a6021b42aecbc8e78bec1b3ccd8e8b8f3 /ctdb
parent9a12d6af0553207809ad1e882df25fbcb00c22a2 (diff)
downloadsamba-2ad1604c2baa547ad881dc75cbb47722d0af651b.tar.gz
ctdb-scripts: Avoid no-op "ctdb ptrans" call
This causes unnecessary g_lock activity and overhead. This could be optimised in ctdb.c:control_ptrans(). However, that makes the code more complex. Let's only do that if we get more potentially no-op uses. Note no optimisation is needed in the "notify" case because there is already an early exit if there are no items. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/config/statd-callout10
1 files changed, 7 insertions, 3 deletions
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index 38f847b1d9b..e2bac639e4b 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -91,10 +91,14 @@ case "$1" in
printf "/statd-state@%s@/p\n", ip }')
# Intentional multi-word expansion for multiple files
# shellcheck disable=SC2086
- if sed -n "$sed_expr" $files | $CTDB ptrans "ctdb.tdb" ; then
- rm $files
+ items=$(sed -n "$sed_expr" $files)
+ if [ -n "$items" ] ; then
+ if echo "$items" | $CTDB ptrans "ctdb.tdb" ; then
+ # shellcheck disable=SC2086
+ rm $files
+ fi
fi
- ;;
+ ;;
notify)
# we must restart the lockmanager (on all nodes) so that we get