From 54015223804a514bb5cc76312c70325704a11459 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 16 Jun 2023 11:09:02 +1000 Subject: [PATCH] ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn" Best reviewed with "git show -w". Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke --- ctdb/config/statd-callout | 106 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 38c155e4793..32642a73653 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -16,16 +16,16 @@ # name = myhostname # ha-callout = /etc/ctdb/statd-callout -[ -n "$CTDB_BASE" ] || \ +[ -n "$CTDB_BASE" ] || CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && echo "$PWD") . "${CTDB_BASE}/functions" # Overwrite this so we get some logging -die () +die() { - script_log "statd-callout" "$@" - exit 1 + script_log "statd-callout" "$@" + exit 1 } # Try different variables to find config file for NFS_HOSTNAME @@ -41,8 +41,8 @@ if [ -z "$NFS_HOSTNAME" ]; then fi fi -[ -n "$NFS_HOSTNAME" ] || \ - die "NFS_HOSTNAME is not configured. statd-callout failed" +[ -n "$NFS_HOSTNAME" ] || + die "NFS_HOSTNAME is not configured. statd-callout failed" ############################################################ @@ -59,7 +59,7 @@ pnn=$(ctdb_get_pnn) ############################################################ -send_notifies () +send_notifies() { _smnotify="${CTDB_HELPER_BINDIR}/smnotify" @@ -70,36 +70,36 @@ send_notifies () # Intentionally round to an even number # shellcheck disable=SC2017 - _state_even=$(( $(date '+%s') / 2 * 2)) + _state_even=$(($(date '+%s') / 2 * 2)) _prev="" - while read _sip _cip ; do + while read _sip _cip; do # NOTE: Consider optimising smnotify to read all the # data from stdin and then run it in the background. # Reset stateval for each serverip - if [ "$_sip" != "$_prev" ] ; then + if [ "$_sip" != "$_prev" ]; then _stateval="$_state_even" fi # Send notifies for server shutdown "$_smnotify" --client="$_cip" --ip="$_sip" \ - --server="$_sip" --stateval="$_stateval" + --server="$_sip" --stateval="$_stateval" "$_smnotify" --client="$_cip" --ip="$_sip" \ - --server="$NFS_HOSTNAME" --stateval="$_stateval" + --server="$NFS_HOSTNAME" --stateval="$_stateval" # Send notifies for server startup _stateval=$((_stateval + 1)) "$_smnotify" --client="$_cip" --ip="$_sip" \ - --server="$_sip" --stateval="$_stateval" + --server="$_sip" --stateval="$_stateval" "$_smnotify" --client="$_cip" --ip="$_sip" \ - --server="$NFS_HOSTNAME" --stateval="$_stateval" + --server="$NFS_HOSTNAME" --stateval="$_stateval" done } -delete_records () +delete_records() { - while read _sip _cip ; do + while read _sip _cip; do _key="statd-state@${_sip}@${_cip}" echo "\"${_key}\" \"\"" done | $CTDB ptrans "ctdb.tdb" @@ -108,14 +108,14 @@ delete_records () ############################################################ case "$1" in - # Keep a single file to keep track of the last "add-client" or - # "del-client'. These get pushed to ctdb.tdb during "update", - # which will generally be run once each "monitor" cycle. In this - # way we avoid scalability problems with flood of persistent - # transactions after a "notify" when all the clients re-take their - # locks. - - add-client) +# Keep a single file to keep track of the last "add-client" or +# "del-client'. These get pushed to ctdb.tdb during "update", +# which will generally be run once each "monitor" cycle. In this +# way we avoid scalability problems with flood of persistent +# transactions after a "notify" when all the clients re-take their +# locks. + +add-client) # statd does not tell us to which IP the client connected so # we must add it to all the IPs that we serve cip="$2" @@ -123,54 +123,54 @@ case "$1" in # x is intentionally ignored # shellcheck disable=SC2034 $CTDB ip -X | - tail -n +2 | - while IFS="|" read x sip node x ; do - [ "$node" = "$pnn" ] || continue # not us - key="statd-state@${sip}@${cip}" - echo "\"${key}\" \"${date}\"" >"$key" - done + tail -n +2 | + while IFS="|" read x sip node x; do + [ "$node" = "$pnn" ] || continue # not us + key="statd-state@${sip}@${cip}" + echo "\"${key}\" \"${date}\"" >"$key" + done ;; - del-client) +del-client) # statd does not tell us from which IP the client disconnected # so we must add it to all the IPs that we serve cip="$2" # x is intentionally ignored # shellcheck disable=SC2034 $CTDB ip -X | - tail -n +2 | - while IFS="|" read x sip node x ; do - [ "$node" = "$pnn" ] || continue # not us - key="statd-state@${sip}@${cip}" - echo "\"${key}\" \"\"" >"$key" - done + tail -n +2 | + while IFS="|" read x sip node x; do + [ "$node" = "$pnn" ] || continue # not us + key="statd-state@${sip}@${cip}" + echo "\"${key}\" \"\"" >"$key" + done ;; - update) - files=$(echo statd-state@*) - if [ "$files" = "statd-state@*" ] ; then - # No files! - exit 0 +update) + files=$(echo statd-state@*) + if [ "$files" = "statd-state@*" ]; then + # No files! + exit 0 fi # Filter out lines for any IP addresses that are not currently # hosted public IP addresses. ctdb_ips=$($CTDB ip | tail -n +2) sed_expr=$(echo "$ctdb_ips" | - awk -v pnn="$pnn" 'pnn == $2 { + awk -v pnn="$pnn" 'pnn == $2 { ip = $1; gsub(/\./, "\\.", ip); printf "/statd-state@%s@/p\n", ip }') # Intentional multi-word expansion for multiple files # shellcheck disable=SC2086 items=$(sed -n "$sed_expr" $files) - if [ -n "$items" ] ; then - if echo "$items" | $CTDB ptrans "ctdb.tdb" ; then + if [ -n "$items" ]; then + if echo "$items" | $CTDB ptrans "ctdb.tdb"; then # shellcheck disable=SC2086 rm $files fi fi ;; - notify) +notify) # we must restart the lockmanager (on all nodes) so that we get # a clusterwide grace period (so other clients don't take out # conflicting locks through other nodes before all locks have been @@ -182,7 +182,7 @@ case "$1" in #echo 0 > /proc/sys/net/ipv4/tcp_max_tw_buckets #echo 0 > /proc/sys/net/ipv4/tcp_max_orphans - # Delete the notification list for statd, we don't want it to + # Delete the notification list for statd, we don't want it to # ping any clients rm -f /var/lib/nfs/statd/sm/* rm -f /var/lib/nfs/statd/sm.bak/* @@ -194,7 +194,7 @@ case "$1" in # their locks. nfs_callout_init "$CTDB_NFS_CALLOUT" "stop" "nlockmgr" >/dev/null 2>&1 - sleep 2 + sleep 2 "$CTDB_NFS_CALLOUT" "start" "nlockmgr" >/dev/null 2>&1 # we now need to send out additional statd notifications to ensure @@ -232,7 +232,7 @@ case "$1" in # but only for the server-IPs that are hosted on this node. ctdb_all_ips=$($CTDB ip all | tail -n +2) sed_expr=$(echo "$ctdb_all_ips" | - awk -v pnn="$pnn" 'pnn == $2 { + awk -v pnn="$pnn" 'pnn == $2 { ip = $1; gsub(/\./, "\\.", ip); printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }') @@ -246,9 +246,9 @@ case "$1" in # hosted on this node and created since the last "update"). # There's nothing else we can do with them at this stage. echo "$ctdb_all_ips" | - awk -v pnn="$pnn" 'pnn != $2 { print $1 }' | - while read sip ; do - rm -f "statd-state@${sip}@"* - done + awk -v pnn="$pnn" 'pnn != $2 { print $1 }' | + while read sip; do + rm -f "statd-state@${sip}@"* + done ;; esac -- 2.47.3