diff -Nru cryptsetup-1.6.6/debian/changelog cryptsetup-1.6.6/debian/changelog --- cryptsetup-1.6.6/debian/changelog 2015-08-21 00:59:11.000000000 -0700 +++ cryptsetup-1.6.6/debian/changelog 2015-12-02 21:59:45.000000000 -0800 @@ -1,3 +1,12 @@ +cryptsetup (2:1.6.6-5ubuntu3) UNRELEASED; urgency=medium + + * debian/initramfs/cryptroot-script: don't call vgchange, which udev rules + already handle for us. Instead we should be calling udevadm settle at + the right points to ensure devices are visible before we try to use + them. Thanks to Richard Hansen for the analysis. LP: #1481536. + + -- Steve Langasek Wed, 02 Dec 2015 21:20:13 -0800 + cryptsetup (2:1.6.6-5ubuntu2) wily; urgency=medium * Fix stupid typo in Recommends "busybox | busybox-static" inversion. diff -Nru cryptsetup-1.6.6/debian/initramfs/cryptroot-script cryptsetup-1.6.6/debian/initramfs/cryptroot-script --- cryptsetup-1.6.6/debian/initramfs/cryptroot-script 2015-03-28 13:38:34.000000000 -0700 +++ cryptsetup-1.6.6/debian/initramfs/cryptroot-script 2015-12-02 21:58:40.000000000 -0800 @@ -155,20 +155,6 @@ return 0 } -activate_vg() -{ - # Sanity checks - if [ ! -x /sbin/lvm ]; then - message "cryptsetup: lvm is not available" - return 1 - fi - - # Detect and activate available volume groups - /sbin/lvm vgscan - /sbin/lvm vgchange -a y --sysinit - return $? -} - setup_mapping() { local opts count cryptopen cryptremove NEWROOT @@ -199,9 +185,7 @@ modprobe -q dm_crypt # Make sure the cryptsource device is available - if [ ! -e $cryptsource ]; then - activate_vg - fi + udev_settle # If the encrypted source device hasn't shown up yet, give it a # little while to deal with removable devices @@ -213,18 +197,21 @@ log_begin_msg "Waiting for encrypted source device..." # Default delay is 180s - if [ -z "${ROOTDELAY}" ]; then - slumber=180 - else - slumber=${ROOTDELAY} - fi + slumber=${ROOTDELAY:-180} slumber=$(( ${slumber} * 10 )) while [ ! -e "$cryptsource" ]; do - # retry for LVM devices every 10 seconds - if [ ${slumber} -eq $(( ${slumber}/100*100 )) ]; then - activate_vg - fi + # Each call to udev_settle can block for up to 30 + # seconds, so the worst case scenario here is a boot + # delay of $ROOTDELAY*10*30 seconds = 15 hours. + # However, this could only ever happen if udev + # constantly had new events being queued *and* none of + # these events resulted in the root device becoming + # available. Still, a more correct solution would + # measure against wall time and call udevadm settle + # in a loop until the $ROOTDELAY timeout has been + # reached. + udev_settle /bin/sleep 0.1 slumber=$(( ${slumber} - 1 )) @@ -237,7 +224,6 @@ log_end_msg 1 || true fi fi - udev_settle # We've given up, but we'll let the user fix matters if they can if [ ! -e "${cryptsource}" ]; then @@ -319,11 +305,8 @@ if [ -z "$cryptlvm" ]; then message "cryptsetup: lvm fs found but no lvm configured" return 1 - elif ! activate_vg; then - # disable error message, LP: #151532 - #message "cryptsetup: failed to setup lvm device" - return 1 fi + udev_settle # Apparently ROOT is already set in /conf/param.conf for # flashed kernels at least. See bugreport #759720. @@ -343,7 +326,6 @@ #if [ -z "$FSTYPE" ] || [ "$FSTYPE" = "unknown" ]; then if [ -z "$FSTYPE" ]; then message "cryptsetup: unknown fstype, bad password or options?" - udev_settle $cryptremove continue fi