common.sh: backport loopback_partscan retry to 77 BUG=chromium:1009559 TEST=tryjob Change-Id: Ia5ed20e823f769332a419eaddf8b5932d8c13d64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/1833061 Reviewed-by: Jason Clinton <jclinton@chromium.org> Commit-Queue: George Engelbrecht <engeg@google.com> Tested-by: George Engelbrecht <engeg@google.com>
diff --git a/common.sh b/common.sh index b57a215..2cd0520 100644 --- a/common.sh +++ b/common.sh
@@ -774,10 +774,26 @@ local lb_dev image="$1" shift lb_dev=$(au_generator_sudo losetup --show -f "$@" "${image}") + # Ignore problems deleting existing partitions. There shouldn't be any # which will upset partx, but that's actually ok. au_generator_sudo partx -d "${lb_dev}" 2>/dev/null || true - au_generator_sudo partx -a "${lb_dev}" + + # Initial sync to hopefully reduce chances of read failure. + sync + + # First try to add missing partitions. + if ! au_generator_sudo partx -a "${lb_dev}"; then + warn "Adding partitions with 'partx -a ${lb_dev}' failed." + warn "Dumping full kernel buffer" + dmesg >&2 || true + sync + sleep 1 + + # Try a partition update to recover. + # https://crbug.com/999596 + au_generator_sudo partx -u "${lb_dev}" + fi echo "${lb_dev}" }