kdumpctl: remove is_mode_switched()
handle_mode_switch() can ensure the correct logic, so remove the needless is_mode_switched(). This helps to save one slow lsinitrd operation for each boot. Improved backup_default_initrd() to judge DEFAULT_INITRD. Signed-off-by: Xunlei Pang <xlpang@redhat.com> Acked-by: Pratyush Anand <panand@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
parent
071ea2a277
commit
c63c0a1084
37
kdumpctl
37
kdumpctl
@ -311,6 +311,10 @@ check_executable()
|
|||||||
|
|
||||||
backup_default_initrd()
|
backup_default_initrd()
|
||||||
{
|
{
|
||||||
|
if [ ! -f "$DEFAULT_INITRD" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -e $DEFAULT_INITRD_BAK ]; then
|
if [ ! -e $DEFAULT_INITRD_BAK ]; then
|
||||||
echo "Backing up $DEFAULT_INITRD before rebuild."
|
echo "Backing up $DEFAULT_INITRD before rebuild."
|
||||||
# save checksum to verify before restoring
|
# save checksum to verify before restoring
|
||||||
@ -690,10 +694,9 @@ check_rebuild()
|
|||||||
system_modified="1"
|
system_modified="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_mode_switched; then
|
handle_mode_switch
|
||||||
echo -n "Dump mode changed from last boot."; echo
|
|
||||||
handle_mode_switch
|
if [ $image_time -eq 0 ]; then
|
||||||
elif [ $image_time -eq 0 ]; then
|
|
||||||
echo -n "No kdump initial ramdisk found."; echo
|
echo -n "No kdump initial ramdisk found."; echo
|
||||||
elif [ "$force_rebuild" != "0" ]; then
|
elif [ "$force_rebuild" != "0" ]; then
|
||||||
echo -n "Force rebuild $TARGET_INITRD"; echo
|
echo -n "Force rebuild $TARGET_INITRD"; echo
|
||||||
@ -853,32 +856,6 @@ propagate_ssh_key()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
is_mode_switched()
|
|
||||||
{
|
|
||||||
local _mod_included
|
|
||||||
|
|
||||||
if [ ! -f $DEFAULT_INITRD ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# find if default initrd has kdumpbase module included.
|
|
||||||
_mod_included=`lsinitrd -m $DEFAULT_INITRD | grep ^kdumpbase$ | wc -l`
|
|
||||||
|
|
||||||
if [ "$DEFAULT_DUMP_MODE" != "fadump" ]; then
|
|
||||||
# If kdumpbase module is included in default initrd,
|
|
||||||
# we must have just switched from fadump mode.
|
|
||||||
if [ "$_mod_included" -eq "1" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
elif [ "$_mod_included" -eq "0" ]; then
|
|
||||||
# If kdumpbase module is missing in default initrd,
|
|
||||||
# we must have just switched from kdump mode.
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_mode_switch()
|
handle_mode_switch()
|
||||||
{
|
{
|
||||||
if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
|
if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user