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@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
WANG Chao 2013-08-30 17:21:56 +08:00 committed by Baoquan He
parent 2ce047b9ed
commit a6f03150e9

View File

@ -16,6 +16,12 @@ if [ -f /etc/sysconfig/kdump ]; then
. /etc/sysconfig/kdump . /etc/sysconfig/kdump
fi fi
single_instance_lock()
{
exec 9>/var/lock/kdump
flock 9
}
# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>] # remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>]
# Remove a list of kernel parameters from a given kernel cmdline and print the result. # 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. # 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 exit 1
fi fi
# Other kdumpctl instances will block in queue, until this one exits
single_instance_lock
case "$1" in case "$1" in
start) start)
if [ -s /proc/vmcore ]; then if [ -s /proc/vmcore ]; then