From ae6baa2ea7cb7d032d7f91d9ded31e73b6d1c759 Mon Sep 17 00:00:00 2001 From: Jonathan Kliegman Date: Fri, 25 Nov 2011 11:03:16 -0500 Subject: [PATCH] Add retry to update_bootloaders.sh cleanup function Race conditions could prevent /tmp/esp.* from being properly unmounted if it was quickly mounted then unmounted. If the umount fails, sleep briefly and then retry. BUG=chromium-os:23442,chromium-os:23443 TEST=Ran build_image --test, saw umount failure but after script finished saw that directory was unmounted on second attempt so no leakage Change-Id: I5b2260f5c99fcfa66027ebcfd69b6e3d5afe4b91 Reviewed-on: https://gerrit.chromium.org/gerrit/12115 Tested-by: Jon Kliegman Reviewed-by: Chris Sosa Commit-Ready: Jon Kliegman --- update_bootloaders.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/update_bootloaders.sh b/update_bootloaders.sh index 27a5a8e0be..67752215de 100755 --- a/update_bootloaders.sh +++ b/update_bootloaders.sh @@ -180,7 +180,14 @@ fi ESP_FS_DIR=$(mktemp -d /tmp/esp.XXXXXX) cleanup() { set +e - sudo umount "${ESP_FS_DIR}" + 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}" fi