From: Martin Schwenke Date: Tue, 3 Jan 2017 22:53:54 +0000 (+1100) Subject: ctdb-scripts: Avoid no-op "ctdb ptrans" call X-Git-Tag: talloc-2.1.12~312 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ad1604c2baa547ad881dc75cbb47722d0af651b;p=thirdparty%2Fsamba.git 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 Reviewed-by: Amitay Isaacs --- 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