Make `dump_to_rootfs` wait for 90s for real

Previous commit da6b280 ('Cleanup dead systemd services before start sysroot.mount')
is not enough for fixing bz1972463. Coiby found a new issue that never
saw before, this patch fixes it.

Resolves: bz1972463
Conflict: None
Upstream: Fedora

commit 660cf4ac03
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Jul 20 13:41:08 2021 +0800

    Make `dump_to_rootfs` wait for 90s for real

    When `failure_action` is set to `dump_to_rootfs`, the message:
    "Waiting for rootfs mount, will timeout after 90 seconds"
    is actually wrong. Kdump will simply call `systemctl start sysroot.mount`,
    but the timeout value of sysroot.mount depends on the unit service and
    dracut parameters. And by default, dracut will set
    JobRunningTimeoutSec=0 and JobTimeoutSec=0 for the device units,
    which means it will wait forever. (see wait_for_dev function in dracut)

    For some devices, this can be fixed by setting rd.timeout=90. But when
    initqueue is set enabled during initramfs build, dracut will force set
    timeout for host devices to `0`. (see 99base/module-setup.sh).

    Depending on dracut / systemd can make things unpredictable and break as
    parameters or code change. To make things easy to understand and
    maintain, just call `systemctl` with `--no-block` params, and implement
    a standalone wait loop.  Now `dump_to_rootfs` will actually wait for
    90s then timeout.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kairui Song 2021-07-20 13:41:08 +08:00 committed by Tao Liu
parent d4de3e9dcc
commit 0cbec881dc
1 changed files with 12 additions and 2 deletions

View File

@ -230,10 +230,20 @@ dump_to_rootfs()
dinfo "Clean up dead systemd services" dinfo "Clean up dead systemd services"
systemctl cancel systemctl cancel
dinfo "Waiting for rootfs mount, will timeout after 90 seconds" dinfo "Waiting for rootfs mount, will timeout after 90 seconds"
systemctl start sysroot.mount systemctl start --no-block sysroot.mount
_loop=0
while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do
sleep 1
_loop=$((_loop + 1))
done
if ! is_mounted /sysroot; then
derror "Failed to mount rootfs"
return
fi
ddebug "NEWROOT=$NEWROOT" ddebug "NEWROOT=$NEWROOT"
dump_fs $NEWROOT dump_fs $NEWROOT
} }