From 2880746d53e1b2be73a50b4a967e16360cbd4e55 Mon Sep 17 00:00:00 2001 From: bizhiyuan Date: Tue, 5 Nov 2024 19:20:58 +0800 Subject: [PATCH] Filesystem: stop/get_pids to be signaled ocf-shellfuncs: systemd_drop_in only if needed --- ...esystem-stop-get_pids-to-be-signaled.patch | 56 +++++++++++++++++++ ...funcs-systemd_drop_in-only-if-needed.patch | 51 +++++++++++++++++ resource-agents.spec | 9 ++- 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 backport-Filesystem-stop-get_pids-to-be-signaled.patch create mode 100644 backport-ocf-shellfuncs-systemd_drop_in-only-if-needed.patch diff --git a/backport-Filesystem-stop-get_pids-to-be-signaled.patch b/backport-Filesystem-stop-get_pids-to-be-signaled.patch new file mode 100644 index 0000000..2ad9c35 --- /dev/null +++ b/backport-Filesystem-stop-get_pids-to-be-signaled.patch @@ -0,0 +1,56 @@ +From b42d698f12aaeb871f4cc6a3c0327a27862b4376 Mon Sep 17 00:00:00 2001 +From: Lars Ellenberg +Date: Wed, 18 Sep 2024 13:42:38 +0200 +Subject: [PATCH] Filesystem: stop/get_pids to be signaled + +The "safe" way to get process ids that may be using a particular filesystem +currently uses shell globs ("find /proc/[0-9]*"). +With a million processes (and/or a less capable shell), +that may result in "Argument list too long". + +Replace with find /proc -path "/proc/[0-9]*" instead. +While at it, also fix the non-posix -or to be -o, +and add explicit grouping parentheses \( \) and explicit -print. + +Add a comment to not include "interesting" characters in mount point names. +--- + heartbeat/Filesystem | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem +index 99bddaf6..3405e2c2 100755 +--- a/heartbeat/Filesystem ++++ b/heartbeat/Filesystem +@@ -669,9 +669,26 @@ get_pids() + $FUSER -Mm $dir 2>/dev/null + fi + elif [ "$FORCE_UNMOUNT" = "safe" ]; then +- procs=$(find /proc/[0-9]*/ -type l -lname "${dir}/*" -or -lname "${dir}" 2>/dev/null | awk -F/ '{print $3}') +- mmap_procs=$(grep " ${dir}/" /proc/[0-9]*/maps | awk -F/ '{print $3}') +- printf "${procs}\n${mmap_procs}" | sort | uniq ++ # Yes, in theory, ${dir} could contain "intersting" characters ++ # and would need to be quoted for glob (find) and regex (grep). ++ # Don't do that, then. ++ ++ # Avoid /proc/[0-9]*, it may cause "Argument list too long". ++ # There are several ways to filter for /proc/ ++ # -mindepth 1 -not -path "/proc/[0-9]*" -prune -o ... ++ # -path "/proc/[!0-9]*" -prune -o ... ++ # -path "/proc/[0-9]*" -a ... ++ # the latter seemd to be significantly faster for this one in my naive test. ++ procs=$(exec 2>/dev/null; ++ find /proc -path "/proc/[0-9]*" -type l \( -lname "${dir}/*" -o -lname "${dir}" \) -print | ++ awk -F/ '{print $3}' | uniq) ++ ++ # This finds both /proc//maps and /proc//task//maps; ++ # if you don't want the latter, add -maxdepth. ++ mmap_procs=$(exec 2>/dev/null; ++ find /proc -path "/proc/[0-9]*/maps" -print | ++ xargs -r grep -l " ${dir}/" | awk -F/ '{print $3}' | uniq) ++ printf "${procs}\n${mmap_procs}" | sort -u + fi + } + +-- +2.25.1 + diff --git a/backport-ocf-shellfuncs-systemd_drop_in-only-if-needed.patch b/backport-ocf-shellfuncs-systemd_drop_in-only-if-needed.patch new file mode 100644 index 0000000..158c4d4 --- /dev/null +++ b/backport-ocf-shellfuncs-systemd_drop_in-only-if-needed.patch @@ -0,0 +1,51 @@ +From 82958dc115c47232ae0468b1ddf64e728ec325e4 Mon Sep 17 00:00:00 2001 +From: Georg Pfuetzenreuter +Date: Wed, 9 Oct 2024 00:16:44 +0200 +Subject: [PATCH] ocf-shellfuncs: systemd_drop_in only if needed + +Avoid dbus overload upon many simultaneous "daemon-reload" invocations +(when a resource agent using systemd_drop_in() is called multiple times +as part of parallel resource operations in Pacemaker) by skipping the +file creation and reload if the expected data already exists. + +Whilst at it, align the indentation of the heredoc with the other parts +of the function. + +Signed-off-by: Georg Pfuetzenreuter +--- + heartbeat/ocf-shellfuncs.in | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in +index 9335cbf0..5c4bb326 100644 +--- a/heartbeat/ocf-shellfuncs.in ++++ b/heartbeat/ocf-shellfuncs.in +@@ -662,14 +662,17 @@ systemd_drop_in() + systemdrundir="/run/systemd/system/resource-agents-deps.target.d" + mkdir -p "$systemdrundir" + conf_file="$systemdrundir/$1.conf" +- cat >"$conf_file" < "$conf_file" <<-EOF ++ [Unit] ++ $conf_line ++ EOF ++ # The information is accessible through systemd API and systemd would ++ # complain about improper permissions. ++ chmod o+r "$conf_file" ++ systemctl daemon-reload ++ fi + } + + # usage: curl_retry RETRIES SLEEP ARGS URL +-- +2.25.1 + diff --git a/resource-agents.spec b/resource-agents.spec index c1088ee..9ce278e 100644 --- a/resource-agents.spec +++ b/resource-agents.spec @@ -1,7 +1,7 @@ Name: resource-agents Summary: Open Source HA Reusable Cluster Resource Scripts Version: 4.15.1 -Release: 10 +Release: 11 License: GPLv2+ and LGPLv2+ URL: https://github.com/ClusterLabs/resource-agents Source0: https://github.com/ClusterLabs/resource-agents/archive/v%{version}.tar.gz @@ -24,6 +24,9 @@ Patch14: backport-IPaddr2-improve-fail-logic-and-check-ip_status-aft Patch15: backport-findif.sh-remove-local-proto-to-use-global-proto-fro.patch Patch16: backport-Filesystem-only-use-umount_force-after-sending-kill_.patch Patch17: backport-Filesystem-on-stop-try-umount-directly-before-scanni.patch +Patch18: backport-Filesystem-stop-get_pids-to-be-signaled.patch +Patch19: backport-ocf-shellfuncs-systemd_drop_in-only-if-needed.patch + Obsoletes: heartbeat-resources <= %{version} Provides: heartbeat-resources = %{version} BuildRequires: automake autoconf pkgconfig gcc perl-interpreter perl-generators python3-devel @@ -121,6 +124,10 @@ export CFLAGS="$(echo '%{optflags}')" %{_mandir}/man8/{ocf-tester.8*,ldirectord.8*} %changelog +* Tue Nov 05 2024 bizhiyuan - 4.15.1-11 +- Filesystem: stop/get_pids to be signaled +- ocf-shellfuncs: systemd_drop_in only if needed + * Tue Oct 29 2024 bizhiyuan - 4.15.1-10 - Filesystem: only use $umount_force after sending kill_signals - Filesystem: on stop, try umount directly, before scanning for users -- Gitee