Skip to contentSkip to conversation

Buglets in shutdown module in HEAD

DISCUSSION Philippe Troin 1 participant 1 message Jan 18, 2017

lore
Share & tools
lore
#0 lore raw

Hi Dracut maintainers,

Note that I'm not subscribed to the mailing list, a CC is appreciated.

I've spotted a couple of issues in the latest shutdown module, specifically this file: http://git.kernel.org/cgit/boot/dracut/dracut.g
it/tree/modules.d/99shutdown/shutdown.sh 918a8a4f123578e39f38404670d5cbe3e3436bb3

The unmount loop seems to be doing the opposite of what it intends to.

    _cnt=0
    while [ $_cnt -le 40 ]; do
        umount_a 2>/dev/null || break
        _cnt=$(($_cnt+1))
    done

doesn't do what's it's supposed to do as umount_a returns 0 in case of success and 1 in case of failure.
The || should be changed into &&:

    _cnt=0
    while [ $_cnt -le 40 ]; do
        umount_a 2>/dev/null && break
        _cnt=$(($_cnt+1))
    done

[2] A little sleeping in between attempts helps too in my experience I'd suggest changing that code to:

    _cnt=0
    while [ $_cnt -le 40 ]; do
        umount_a 2>/dev/null && break
        sleep 0.25
        _cnt=$(($_cnt+1))
    done

[3] The check_shutdown loop running all the hooks can be very verbose and needlessly scary when luks+lvm is involved. It generally scrolls lots of messages about being unable to disable dm mappings before finally succeeding.

I'd suggest using the same logic as the unmount loop: loop quietly, and if it fails 40 times in a row, run one last time verbosely.

So changing:

    _cnt=0
    while [ $_cnt -le 40 ]; do
        _check_shutdown && break
        _cnt=$(($_cnt+1))
    done
    [ $_cnt -ge 40 ] && _check_shutdown final

to

    _cnt=0
    while [ $_cnt -le 40 ]; do
        _check_shutdown 2> /dev/null && break
        _cnt=$(($_cnt+1))
        sleep 0.25
    done
    [ $_cnt -ge 40 ] && _check_shutdown final

Again, the chances of a clean(er) shutdown may be improved by sleeping in between attempts.

I believe [1] is a true bug, while [2] and [3] will be the maintainers' call.

Phil.