Fedora dracut-044-75 release has all the component needed to support initrd rebuild in case of watchdog state change. Therefore sending these patches for inclusion in kexec-tools.
Please note that these patches should only be added in those fedora versions which has dracut version dracut-044-75 or latter. Anyway, we already have dependency specified in spec file as well.
Testing: Most of the rebuild test cases have been mentioned in the commit log of 2/5. Other than that, I have also tested effect of adding either "-o watchdog" or "-a watchdog" or none of them. They have been found to behave as expected. So, when we pass -o watchdog in dracut_args, it does not include kernel watchdog module whether state is active or inactive. In all other cases, it adds kernel module only when state is active.
Changes since V3: - Now we only look for "-o watchdog" in dracut_args. If it is not passed then we add "-a watchdog" in dracut_args by default. - Notes in howto modified accordingly
Changes since V2: - Removed NOWDT argument. Using dracut_args instead. - Removed man page update. Included notes in howto - Reorganized mkdumprd code for watchdog dracut argument addition
Changes since V1: - Removed patch 4/5 which was updating kdumpctl man page. - Added all necessary information in kdump.conf man page (patch 2/4).
Pratyush Anand (5): mkdumprd: Add dracut watchdog module as default option kdumpctl: force rebuild in case of watchdog state change howto: Notes on watchdog module handling watchdog: do not add watchdog module in rd.driver.pre now spec: Update to add dependency on dracut version >= 044-75
dracut-module-setup.sh | 9 --------- kdump-lib.sh | 24 ++++++++++++++++++++++++ kdumpctl | 32 ++++++++++++++++++++++++++++++++ kexec-kdump-howto.txt | 14 ++++++++++++++ kexec-tools.spec | 3 ++- mkdumprd | 5 ++++- 6 files changed, 76 insertions(+), 11 deletions(-)
If dracut watchdog module is enabled then, it includes kernel watchdog module of active watchdog device in initramfs.
kdump.conf has an option to modify dracut_args. So, if an user passes "-a watchdog" in dracut_args then dracut will add kernel watchdog module of active watchdog device in initramfs.
Since, kexec-tools always requires to add kernel watchdog module of active watchdog device in initramfs, therefore even when an user does not pass any watchdog option then also kexec-tools adds "-a watchdog" in dracut args.
Therefore, if an user does not want to add kernel watchdog module in initramfs then he/she must pass "-o watchdog" in dracut_args.
Signed-off-by: Pratyush Anand panand@redhat.com --- kdump-lib.sh | 24 ++++++++++++++++++++++++ mkdumprd | 5 ++++- 2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 141a5614f1d5..4567a05edbbe 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -382,3 +382,27 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}" } + +# returns 0 when omission of watchdog module is desired in dracut_args +# returns 1 otherwise +is_wdt_mod_omitted() { + local dracut_args + local ret=1 + + dracut_args=$(grep "^dracut_args" /etc/kdump.conf) + [[ -z $dracut_args ]] && return $ret + + eval set -- $dracut_args + while :; do + [[ -z $1 ]] && break + case $1 in + -o|--omit) + echo $2 | grep -qw "watchdog" + [[ $? == 0 ]] && ret=0 + break + esac + shift + done + + return $ret +} diff --git a/mkdumprd b/mkdumprd index eb0d5e06fac9..77b52b744653 100644 --- a/mkdumprd +++ b/mkdumprd @@ -16,8 +16,11 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
+is_wdt_mod_omitted +[[ $? -eq 1 ]] && WDTCFG="-a watchdog" + extra_modules="" -dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg") +dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg" $WDTCFG) OVERRIDE_RESETTABLE=0
add_dracut_arg() {
Hi, Pratyush
On 07/14/16 at 02:05pm, Pratyush Anand wrote:
If dracut watchdog module is enabled then, it includes kernel watchdog module of active watchdog device in initramfs.
kdump.conf has an option to modify dracut_args. So, if an user passes "-a watchdog" in dracut_args then dracut will add kernel watchdog module of active watchdog device in initramfs.
Since, kexec-tools always requires to add kernel watchdog module of active watchdog device in initramfs, therefore even when an user does not pass any watchdog option then also kexec-tools adds "-a watchdog" in dracut args.
Therefore, if an user does not want to add kernel watchdog module in initramfs then he/she must pass "-o watchdog" in dracut_args.
Signed-off-by: Pratyush Anand panand@redhat.com
kdump-lib.sh | 24 ++++++++++++++++++++++++ mkdumprd | 5 ++++- 2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 141a5614f1d5..4567a05edbbe 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -382,3 +382,27 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}"
}
+# returns 0 when omission of watchdog module is desired in dracut_args +# returns 1 otherwise +is_wdt_mod_omitted() {
- local dracut_args
- local ret=1
- dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
- [[ -z $dracut_args ]] && return $ret
- eval set -- $dracut_args
- while :; do
[[ -z $1 ]] && break
case $1 in
-o|--omit)
echo $2 | grep -qw "watchdog"
[[ $? == 0 ]] && ret=0
break
esac
shift
- done
- return $ret
+} diff --git a/mkdumprd b/mkdumprd index eb0d5e06fac9..77b52b744653 100644 --- a/mkdumprd +++ b/mkdumprd @@ -16,8 +16,11 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
+is_wdt_mod_omitted +[[ $? -eq 1 ]] && WDTCFG="-a watchdog"
extra_modules="" -dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg") +dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg" $WDTCFG)
The new version overall looks good, but before ack the series I still would like to know something about the dracut module:
In the install() function:
if ! dracut_module_included "systemd"; then [snip..] fi inst_hook emergency 02 "$moddir/watchdog-stop.sh" inst_multiple -o wdctl
All the hooks are installed only for !systemd case, but why leave the emergency hook and the wdctl tool out of the if ... fi?
Do we have some special concern?
I'm asking this because watchdog is added as long as there's no omiting in dracut_args without checking if wdt is active or not, so we will always add the wdctl and watchdog-stop.sh.
OVERRIDE_RESETTABLE=0
add_dracut_arg() {
2.5.5 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
Hi Dave,
On 14/07/2016:04:56:20 PM, Dave Young wrote:
Hi, Pratyush
On 07/14/16 at 02:05pm, Pratyush Anand wrote:
If dracut watchdog module is enabled then, it includes kernel watchdog module of active watchdog device in initramfs.
kdump.conf has an option to modify dracut_args. So, if an user passes "-a watchdog" in dracut_args then dracut will add kernel watchdog module of active watchdog device in initramfs.
Since, kexec-tools always requires to add kernel watchdog module of active watchdog device in initramfs, therefore even when an user does not pass any watchdog option then also kexec-tools adds "-a watchdog" in dracut args.
Therefore, if an user does not want to add kernel watchdog module in initramfs then he/she must pass "-o watchdog" in dracut_args.
Signed-off-by: Pratyush Anand panand@redhat.com
kdump-lib.sh | 24 ++++++++++++++++++++++++ mkdumprd | 5 ++++- 2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 141a5614f1d5..4567a05edbbe 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -382,3 +382,27 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}"
}
+# returns 0 when omission of watchdog module is desired in dracut_args +# returns 1 otherwise +is_wdt_mod_omitted() {
- local dracut_args
- local ret=1
- dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
- [[ -z $dracut_args ]] && return $ret
- eval set -- $dracut_args
- while :; do
[[ -z $1 ]] && break
case $1 in
-o|--omit)
echo $2 | grep -qw "watchdog"
[[ $? == 0 ]] && ret=0
break
esac
shift
- done
- return $ret
+} diff --git a/mkdumprd b/mkdumprd index eb0d5e06fac9..77b52b744653 100644 --- a/mkdumprd +++ b/mkdumprd @@ -16,8 +16,11 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
+is_wdt_mod_omitted +[[ $? -eq 1 ]] && WDTCFG="-a watchdog"
extra_modules="" -dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg") +dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg" $WDTCFG)
The new version overall looks good, but before ack the series I still would like to know something about the dracut module:
In the install() function:
if ! dracut_module_included "systemd"; then
[snip..] fi inst_hook emergency 02 "$moddir/watchdog-stop.sh" inst_multiple -o wdctl
All the hooks are installed only for !systemd case, but why leave the emergency hook and the wdctl tool out of the if ... fi?
Do we have some special concern?
I'm asking this because watchdog is added as long as there's no omiting in dracut_args without checking if wdt is active or not, so we will always add the wdctl and watchdog-stop.sh.
Yep, they should not be. It was not in my patch which got merged, see:
http://git.kernel.org/cgit/boot/dracut/dracut.git/commit/?id=89da227de991ef3...
But, then Harald changed it in his rewrite patch and I could not notice this change. http://git.kernel.org/cgit/boot/dracut/dracut.git/commit/?id=74e2d1e69f5527a...
@Harald, Is there any special concern for having wdctl and watchdog-stop.sh even when we have systemd. My understanding is that systemd watchdog daemon and wdctl are mutually exclusive. Please correct if I am wrong.
~Pratyush
OVERRIDE_RESETTABLE=0
add_dracut_arg() {
2.5.5 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
On 14.07.2016 12:15, Pratyush Anand wrote:
Hi Dave,
On 14/07/2016:04:56:20 PM, Dave Young wrote:
Hi, Pratyush
On 07/14/16 at 02:05pm, Pratyush Anand wrote:
If dracut watchdog module is enabled then, it includes kernel watchdog module of active watchdog device in initramfs.
kdump.conf has an option to modify dracut_args. So, if an user passes "-a watchdog" in dracut_args then dracut will add kernel watchdog module of active watchdog device in initramfs.
Since, kexec-tools always requires to add kernel watchdog module of active watchdog device in initramfs, therefore even when an user does not pass any watchdog option then also kexec-tools adds "-a watchdog" in dracut args.
Therefore, if an user does not want to add kernel watchdog module in initramfs then he/she must pass "-o watchdog" in dracut_args.
Signed-off-by: Pratyush Anand panand@redhat.com
kdump-lib.sh | 24 ++++++++++++++++++++++++ mkdumprd | 5 ++++- 2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 141a5614f1d5..4567a05edbbe 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -382,3 +382,27 @@ get_ifcfg_filename() {
echo -n "${ifcfg_file}"
}
+# returns 0 when omission of watchdog module is desired in dracut_args +# returns 1 otherwise +is_wdt_mod_omitted() {
- local dracut_args
- local ret=1
- dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
- [[ -z $dracut_args ]] && return $ret
- eval set -- $dracut_args
- while :; do
[[ -z $1 ]] && break
case $1 in
-o|--omit)
echo $2 | grep -qw "watchdog"
[[ $? == 0 ]] && ret=0
break
esac
shift
- done
- return $ret
+} diff --git a/mkdumprd b/mkdumprd index eb0d5e06fac9..77b52b744653 100644 --- a/mkdumprd +++ b/mkdumprd @@ -16,8 +16,11 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
+is_wdt_mod_omitted +[[ $? -eq 1 ]] && WDTCFG="-a watchdog"
extra_modules="" -dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg") +dracut_args=("--hostonly" "-o" "plymouth dash resume ifcfg" $WDTCFG)
The new version overall looks good, but before ack the series I still would like to know something about the dracut module:
In the install() function:
if ! dracut_module_included "systemd"; then
[snip..] fi inst_hook emergency 02 "$moddir/watchdog-stop.sh" inst_multiple -o wdctl
All the hooks are installed only for !systemd case, but why leave the emergency hook and the wdctl tool out of the if ... fi?
Do we have some special concern?
I'm asking this because watchdog is added as long as there's no omiting in dracut_args without checking if wdt is active or not, so we will always add the wdctl and watchdog-stop.sh.
Yep, they should not be. It was not in my patch which got merged, see:
http://git.kernel.org/cgit/boot/dracut/dracut.git/commit/?id=89da227de991ef3...
But, then Harald changed it in his rewrite patch and I could not notice this change. http://git.kernel.org/cgit/boot/dracut/dracut.git/commit/?id=74e2d1e69f5527a...
@Harald, Is there any special concern for having wdctl and watchdog-stop.sh even when we have systemd. My understanding is that systemd watchdog daemon and wdctl are mutually exclusive. Please correct if I am wrong.
~Pratyush
In the emergency case, we want the watchdog to be stopped. wdctl might want to be used here and there, so I didn't exclude it.
OVERRIDE_RESETTABLE=0
add_dracut_arg() {
2.5.5 _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
Thanks Dave
If state of a watchdog device is changed by an user after kdumpctl restart then initramfs must be rebuilt on the basis of new watchdog status.
Testing: ------------------------------------------------------- Initramfs wdt state Prev Current Result ------------------------------------------------------- Not Exist NA X Rebuild Exist Inact Inact No Rebuild Exist Inact Act Force Rebuild Exist Act Inact Force Rebuild Exist Act Act(Same wdt) No Rebuild Exist Act Act(Diff wdt) Force Rebuild
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kdumpctl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdumpctl b/kdumpctl index c8fc54fc7677..1f1d8c52d52d 100755 --- a/kdumpctl +++ b/kdumpctl @@ -427,6 +427,32 @@ check_dump_fs_modified() return 1 }
+check_wdt_modified() +{ + is_wdt_mod_omitted + [[ $? -eq 0 ]] && return 0 + [[ -d /sys/class/watchdog/ ]] || return 0 + + for dir in /sys/class/watchdog/*; do + [[ -d "$dir" ]] || continue + [[ -f "$dir/state" ]] || continue + wdtdrv=$(< "$dir/device/modalias") + wdtdrv=$(modinfo $wdtdrv | grep filename | awk -F"kernel/" '{print $2}') + active=$(< "$dir/state") + # rebuild when: + # module for this watchdog is not found and watchdog is active + # module for this watchdog is found and watchdog is inactive + lsinitrd $TARGET_INITRD | grep $wdtdrv &> /dev/null + if [ $? -ne 0 ]; then + [[ "$active" = "active" ]] && return 1 + else + [[ "$active" = "inactive" ]] && return 1 + fi + done + + return 0 +} + # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -448,6 +474,12 @@ check_system_modified() return $ret fi
+ check_wdt_modified + if [ $? -ne 0 ]; then + echo "Detected change in watchdog state" + return 1 + fi + return 0 }
Update howto with notes on dracut and kernel watchdog module handling.
Signed-off-by: Pratyush Anand panand@redhat.com --- kexec-kdump-howto.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index b4cdc2227f1d..83b3e0a0645f 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -616,6 +616,20 @@ options are copied from /proc/cmdline. In general it is best to append command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing the original command line completely.
+Notes on watchdog module handling: + +If a watchdog is active in first kernel then, we must have it's module +loaded in crash kernel, so that either watchdog is deactivated or started +being kicked in second kernel. Otherwise, we might face watchdog reboot +when vmcore was being saved. When dracut watchdog module is enabled, it +installs kernel watchdog module of active watchdog device in initrd. +kexec-tools always add "-a watchdog" to the dracut_args until user +specifically adds "-o watchdog" in dracut_args of kdump.conf. If a +watchdog module (such as hp_wdt) has not been written in watchdog-core +framework then this option will not have any effect and module will not be +added. Please note that only systemd watchdog daemon is supported as +watchdog kick application. + Parallel Dumping Operation ========================== Kexec allows kdump using multiple cpus. So parallel feature can accelerate
Now dracut takes care to add module for active watchdog. Therefore we do not need to pass iTCO_wdt and lpc_ich module in rd.driver.pre specifically here.
Signed-off-by: Pratyush Anand panand@redhat.com Acked-by: Dave Young dyoung@redhat.com --- dracut-module-setup.sh | 9 --------- 1 file changed, 9 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index aa204f871e25..f5c0218b36ed 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -729,12 +729,3 @@ install() { # at some point of time. kdump_check_iscsi_targets } - -installkernel() { - wdt=$(lsmod|cut -f1 -d' '|grep "wdt$") - if [ -n "$wdt" ]; then - [ "$wdt" = "iTCO_wdt" ] && instmods lpc_ich && - echo "rd.driver.pre=lpc_ich,iTCO_wdt " >> ${initdir}/etc/cmdline.d/00-wdt.conf - instmods $wdt - fi -}
Fedora dracut version >= 044-75 must be installed to work with this set of kexec-tools patches. Therefore adding dependency for them.
Signed-off-by: Pratyush Anand panand@redhat.com --- kexec-tools.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec index 312965039ffc..b171e8c77d19 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -45,7 +45,8 @@ Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units Requires(pre): coreutils sed zlib -Requires: dracut, dracut-network, ethtool +Requires: dracut >= 044-75 +Requires: dracut-network, ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units
Hi Pratyush
On 07/14/16 at 02:05pm, Pratyush Anand wrote:
Fedora dracut-044-75 release has all the component needed to support initrd rebuild in case of watchdog state change. Therefore sending these patches for inclusion in kexec-tools.
Please note that these patches should only be added in those fedora versions which has dracut version dracut-044-75 or latter. Anyway, we already have dependency specified in spec file as well.
Testing: Most of the rebuild test cases have been mentioned in the commit log of 2/5. Other than that, I have also tested effect of adding either "-o watchdog" or "-a watchdog" or none of them. They have been found to behave as expected. So, when we pass -o watchdog in dracut_args, it does not include kernel watchdog module whether state is active or inactive. In all other cases, it adds kernel module only when state is active.
Changes since V3:
- Now we only look for "-o watchdog" in dracut_args. If it is not passed then we add "-a watchdog" in dracut_args by default.
- Notes in howto modified accordingly
Changes since V2:
- Removed NOWDT argument. Using dracut_args instead.
- Removed man page update. Included notes in howto
- Reorganized mkdumprd code for watchdog dracut argument addition
Changes since V1:
- Removed patch 4/5 which was updating kdumpctl man page.
- Added all necessary information in kdump.conf man page (patch 2/4).
Pratyush Anand (5): mkdumprd: Add dracut watchdog module as default option kdumpctl: force rebuild in case of watchdog state change howto: Notes on watchdog module handling watchdog: do not add watchdog module in rd.driver.pre now spec: Update to add dependency on dracut version >= 044-75
dracut-module-setup.sh | 9 --------- kdump-lib.sh | 24 ++++++++++++++++++++++++ kdumpctl | 32 ++++++++++++++++++++++++++++++++ kexec-kdump-howto.txt | 14 ++++++++++++++ kexec-tools.spec | 3 ++- mkdumprd | 5 ++++- 6 files changed, 76 insertions(+), 11 deletions(-)
watchdog is always added, it addes extra wdctl and maybe some libraries but consider the size is small, we can leave with it.
For the series. Acked-by: Dave Young dyoung@redhat.com
Thanks Dave