public inbox for initramfs@vger.kernel.org
 help / color / mirror / Atom feed
* Buglets in shutdown module in HEAD
@ 2017-01-18 18:34 Philippe Troin
  0 siblings, 0 replies; only message in thread
From: Philippe Troin @ 2017-01-18 18:34 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-18 18:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-18 18:34 Buglets in shutdown module in HEAD Philippe Troin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox