From c9ca3dbb0ece998ec13516b4aa38201ec2266980 Mon Sep 17 00:00:00 2001 From: David James Date: Mon, 9 Jul 2012 08:12:26 -0700 Subject: [PATCH] Revert gvfs hacks to known-good state. Originally, I patched enter_chroot.sh to stop the gvfs daemons to work around an issue where these daemons would prevent loop devices from being unmounted. See https://bugzilla.gnome.org/show_bug.cgi?id=677648 Unfortunately, temporarily stopping gvfs daemons has a bad side effects: other GUI applications that rely on these daemons responding start hanging. This can be reproduced, for example, by starting 'gedit'. To fix these hangs, I'm just reverting my patches to enter_chroot.sh and restoring the scripts to where they were before. This reverts the following patches: 1. Stop gvfs daemons earlier during enter_chroot. This reverts commit 0079158f737167d2a97b7899e6f58133f7602c17. 2. Revert "Stop the gvfsd-trash daemon during enter_chroot." This reverts commit 654a00bd6154476bc7d9d1138576c5452b2da978. 3. Revert "Stop the automounting daemon whenever we're inside the chroot." This reverts commit fae0a59e8b0e60b91b3b9bfee915edc57514ee1b. 4. Revert "Clean up update_bootloaders.sh to avoid sleeping." This reverts commit 0103b5913816544c4ed9b75369a1fc2fe5e1d6ac. BUG=chromium-os:23443 TEST=Trybot run. Change-Id: Ie9ff222fe5fc7232fd1fc39af129cc18531118c6 Reviewed-on: https://gerrit.chromium.org/gerrit/26922 Reviewed-by: Chris Wolfe Reviewed-by: Jon Kliegman Reviewed-by: Brian Harring Commit-Ready: David James Tested-by: David James --- sdk_lib/enter_chroot.sh | 33 ++++++++++++++++++++++----------- update_bootloaders.sh | 21 ++++++++++++--------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index 6683004832..86c7f6116d 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -261,13 +261,6 @@ setup_env() { disown $! fi - # Turn off automounting of external media when we enter the chroot by - # stopping the gvfs-gdu-volume-monitor and gvfsd-trash daemons. This is - # currently the most reliable way to disable automounting. - # See https://bugzilla.gnome.org/show_bug.cgi?id=677648 - sudo killall -STOP -r '^gvfs-gdu-volume.*$|^gvfsd-trash$' 2>/dev/null \ - || true - debug "Mounting chroot environment." MOUNT_CACHE=$(echo $(awk '{print $2}' /proc/mounts)) mount_queue_init @@ -394,6 +387,22 @@ setup_env() { warn "-- Note: modprobe fuse failed. gmergefs will not work" fi + # Turn off automounting of external media when we enter the + # chroot; thus we don't have to worry about being able to unmount + # from inside. + if SAVED_PREF=$(gconftool-2 -g ${AUTOMOUNT_PREF} 2>/dev/null); then + if [ "${SAVED_PREF}" != "false" ]; then + if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then + warn "-- Note: USB sticks may be automounted by your host OS." + warn "-- Note: If you plan to burn bootable media, you may need to" + warn "-- Note: unmount these devices manually, or run image_to_usb.sh" + warn "-- Note: outside the chroot." + fi + fi + fi + # Always write the temp file so we can read it when exiting + echo "${SAVED_PREF:-false}" > "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}" + # Fix permissions on ccache tree. If this is a fresh chroot, then they # might not be set up yet. Or if the user manually `rm -rf`-ed things, # we need to reset it. Otherwise, gcc itself takes care of fixing things @@ -505,6 +514,12 @@ teardown_env() { # Remove any dups from lock file while installing new one sort -u -n "$TMP_LOCKFILE" > "$LOCKFILE" + SAVED_PREF=$(<"${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}") + if [ "${SAVED_PREF}" != "false" ]; then + gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} ${SAVED_PREF} || \ + warn "could not re-set your automount preference." + fi + if [ -s "$LOCKFILE" ]; then debug "At least one other pid is running in the chroot, so not" debug "tearing down env." @@ -531,10 +546,6 @@ teardown_env() { debug "Unmounting chroot environment." safe_umount_tree "${MOUNTED_PATH}/" - - # Now that we've exited the chroot, allow automounting again. - sudo killall -CONT -r '^gvfs-gdu-volume.*$|^gvfsd-trash$' 2>/dev/null \ - || true fi ) 200>>"$LOCKFILE" || die "teardown_env failed" } diff --git a/update_bootloaders.sh b/update_bootloaders.sh index 5aa9b9326b..681f4935eb 100755 --- a/update_bootloaders.sh +++ b/update_bootloaders.sh @@ -161,16 +161,19 @@ fi ESP_FS_DIR=$(mktemp -d /tmp/esp.XXXXXX) cleanup() { - local failed=() - if [[ -n "${ESP_FS_DIR}" ]]; then - sudo umount "${ESP_FS_DIR}" && rm -rf "${ESP_FS_DIR}" || failed+=( umount ) + set +e + if ! sudo umount "${ESP_FS_DIR}"; then + # There is a race condition possible on some ubuntu setups + # with mounting and unmounting a device very quickly + # Doing a quick sleep/retry as a temporary workaround + warn "Initial unmount failed. Possibly crosbug.com/23443. Retrying" + sleep 5 + sudo umount "${ESP_FS_DIR}" fi if [[ -n "${ESP_DEV}" && -z "${ESP_DEV//\/dev\/loop*}" ]]; then - sudo losetup -d "${ESP_DEV}" || failed+=( losetup ) - fi - if [[ -n "${failed[*]}" ]]; then - die "Cleanup failed in ${failed[*]}" + sudo losetup -d "${ESP_DEV}" fi + rm -rf "${ESP_FS_DIR}" } trap cleanup EXIT sudo mount "${ESP_DEV}" "${ESP_FS_DIR}" @@ -212,9 +215,9 @@ if [[ "${FLAGS_arch}" = "x86" || "${FLAGS_arch}" = "amd64" ]]; then # we cut over from rootfs booting (extlinux). if [[ ${FLAGS_install_syslinux} -eq ${FLAGS_TRUE} ]]; then sudo umount "${ESP_FS_DIR}" - rm -rf "${ESP_FS_DIR}" - ESP_FS_DIR= sudo syslinux -d /syslinux "${ESP_DEV}" + # mount again for cleanup to free resource gracefully + sudo mount -o ro "${ESP_DEV}" "${ESP_FS_DIR}" fi elif [[ "${FLAGS_arch}" = "arm" ]]; then # Copy u-boot script to ESP partition