kdumpctl: improve check_wdt_modified()
Use the logic of dracut 04watchdog/module-setup.sh to check, then we only need to compare the content of 00-watchdog.conf, so we can save one operation of lsinitrd. 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
c63c0a1084
commit
2a5f362521
66
kdumpctl
66
kdumpctl
@ -565,36 +565,58 @@ check_dump_fs_modified()
|
|||||||
|
|
||||||
check_wdt_modified()
|
check_wdt_modified()
|
||||||
{
|
{
|
||||||
|
local -A _drivers
|
||||||
|
local _alldrivers _active _wdtdrv _wdtppath _dir
|
||||||
|
local wd_old wd_new
|
||||||
|
|
||||||
is_wdt_mod_omitted
|
is_wdt_mod_omitted
|
||||||
[[ $? -eq 0 ]] && return 0
|
[[ $? -eq 0 ]] && return 0
|
||||||
[[ -d /sys/class/watchdog/ ]] || return 0
|
[[ -d /sys/class/watchdog/ ]] || return 0
|
||||||
|
|
||||||
for dir in /sys/class/watchdog/*; do
|
# Copied logic from dracut 04watchdog/module-setup.sh::installkernel()
|
||||||
[[ -d "$dir" ]] || continue
|
for _dir in /sys/class/watchdog/*; do
|
||||||
[[ -f "$dir/state" ]] || continue
|
[[ -d "$_dir" ]] || continue
|
||||||
wdtdrv=$(< "$dir/device/modalias")
|
[[ -f "$_dir/state" ]] || continue
|
||||||
wdtdrv=$(modinfo $wdtdrv | grep filename | awk -F"kernel/" '{print $2}')
|
_active=$(< "$_dir/state")
|
||||||
active=$(< "$dir/state")
|
[[ "$_active" = "active" ]] || continue
|
||||||
# rebuild when:
|
# device/modalias will return driver of this device
|
||||||
# module for this watchdog is not found and watchdog is active
|
_wdtdrv=$(< "$_dir/device/modalias")
|
||||||
# module for this watchdog is found and watchdog is inactive
|
# There can be more than one module represented by same
|
||||||
lsinitrd $TARGET_INITRD | grep $wdtdrv &> /dev/null
|
# modalias. Currently load all of them.
|
||||||
if [ $? -ne 0 ]; then
|
# TODO: Need to find a way to avoid any unwanted module
|
||||||
[[ "$active" = "active" ]] && return 1
|
# represented by modalias
|
||||||
else
|
_wdtdrv=$(modprobe --set-version "$kdump_kver" -R $_wdtdrv 2>/dev/null)
|
||||||
[[ "$active" = "inactive" ]] && return 1
|
if [[ $_wdtdrv ]]; then
|
||||||
|
for i in $_wdtdrv; do
|
||||||
|
_drivers[$i]=1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# however in some cases, we also need to check that if there is
|
||||||
|
# a specific driver for the parent bus/device. In such cases
|
||||||
|
# we also need to enable driver for parent bus/device.
|
||||||
|
_wdtppath=$(readlink -f "$_dir/device")
|
||||||
|
while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do
|
||||||
|
_wdtppath=$(readlink -f "$_wdtppath/..")
|
||||||
|
[[ -f "$_wdtppath/modalias" ]] || continue
|
||||||
|
|
||||||
|
_wdtdrv=$(< "$_wdtppath/modalias")
|
||||||
|
_wdtdrv=$(modprobe --set-version "$kdump_kver" -R $_wdtdrv 2>/dev/null)
|
||||||
|
if [[ $_wdtdrv ]]; then
|
||||||
|
for i in $_wdtdrv; do
|
||||||
|
_drivers[$i]=1
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# check if watchdog kernel module unloaded.
|
|
||||||
loaded_mods=$(lsinitrd $TARGET_INITRD -f etc/cmdline.d/00-watchdog.conf)
|
|
||||||
[[ -n $loaded_mods ]] && loaded_mods=$(echo $loaded_mods | awk -F"rd.driver.pre=" '{print $2}' | sed "s/,/ /g")
|
|
||||||
for mod in $loaded_mods ; do
|
|
||||||
lsmod | grep $mod &> /dev/null
|
|
||||||
[[ $? != 0 ]] && return 1
|
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
# ensure that watchdog module is loaded as early as possible
|
||||||
|
_alldrivers="${!_drivers[*]}"
|
||||||
|
[[ $_alldrivers ]] && wd_new="rd.driver.pre=${_alldrivers// /,}"
|
||||||
|
wd_old=$(lsinitrd $TARGET_INITRD -f etc/cmdline.d/00-watchdog.conf)
|
||||||
|
|
||||||
|
[[ "$wd_old" = "$wd_new" ]] && return 0
|
||||||
|
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# returns 0 if system is not modified
|
# returns 0 if system is not modified
|
||||||
|
Loading…
Reference in New Issue
Block a user