[kexec-tools] kdumpctl: Run multiple kdumpctl instances one by one in serial order
Baoquan He
baoquan at fedoraproject.org
Fri Sep 27 02:45:14 UTC 2013
commit a6f03150e9869ee0d00a6b8cd606ac46af0df83e
Author: WANG Chao <chaowang at redhat.com>
Date: Fri Aug 30 17:21:56 2013 +0800
kdumpctl: Run multiple kdumpctl instances one by one in serial order
There will be a race condition if multiple kdumpctl instances are
running at the same time.
By introducing a global mutex lock, only one instance can acquire this
lock and run, others will be waiting for the lock in queue. Now each
kdump instance will be run in serial order and there won't any race
condition.
This is a patch backported from RHEL6.
Signed-off-by: WANG Chao <chaowang at redhat.com>
Acked-by: Vivek Goyal <vgoyal at redhat.com>
Acked-by: Dave Young <dyoung at redhat.com>
kdumpctl | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/kdumpctl b/kdumpctl
index aba1e3c..d62b4b4 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -16,6 +16,12 @@ if [ -f /etc/sysconfig/kdump ]; then
. /etc/sysconfig/kdump
fi
+single_instance_lock()
+{
+ exec 9>/var/lock/kdump
+ flock 9
+}
+
# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>]
# Remove a list of kernel parameters from a given kernel cmdline and print the result.
# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists.
@@ -531,6 +537,9 @@ if [ ! -f "$KDUMP_CONFIG_FILE" ]; then
exit 1
fi
+# Other kdumpctl instances will block in queue, until this one exits
+single_instance_lock
+
case "$1" in
start)
if [ -s /proc/vmcore ]; then
More information about the scm-commits
mailing list