From b01cc8d2d344e507abaae6f6a35608207cb3a923 Mon Sep 17 00:00:00 2001 From: David James Date: Sat, 13 Aug 2011 23:16:49 -0700 Subject: [PATCH] Remove unnecessary sync calls from build_image and image_to_vm.sh. Calling sync in build scripts pauses the build unnecessarily, particularly when other steps are running in parallel. BUG=chromium-os:19150 TEST=Run cbuildbot release build and watch faster performance. Change-Id: Ia2469e3be68fdd38474ab4e6f67b06339c04822f Reviewed-on: http://gerrit.chromium.org/gerrit/5966 Reviewed-by: Thieu Le Reviewed-by: Richard Barnette Reviewed-by: Tested-by: David James --- build_image | 12 ++++++++---- image_to_vm.sh | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build_image b/build_image index a1d7a0a716..75f791bfe2 100755 --- a/build_image +++ b/build_image @@ -458,10 +458,7 @@ zero_free_space() { # dd is a silly thing and will produce a "No space left on device" message # that cannot be turned off and is confusing to unsuspecting victims. ( sudo dd if=/dev/zero of="${fs_mount_point}/filler" bs=4096 \ - || true ) 2>&1 |grep -v "No space left on device" - sudo sync - sudo rm -f "${fs_mount_point}/filler" - sudo sync + || true ) 2>&1 | grep -v "No space left on device" } create_base_image() { @@ -627,6 +624,13 @@ create_base_image() { trap delete_prompt EXIT + # Now that the filler file has been sync'd to disk and has filled up all free + # space with zeros, re-mount the rootfs to delete the filler file. + LOOP_DEV=$(sudo losetup --show -f "${ROOT_FS_IMG}") + sudo mount -t ext2 "${LOOP_DEV}" "${ROOT_FS_DIR}" + sudo rm -f "${ROOT_FS_DIR}/filler" + sudo umount -d "${ROOT_FS_DIR}" + # Create the GPT-formatted image. build_gpt "${OUTPUT_DIR}/${image_name}" \ "${ROOT_FS_IMG}" \ diff --git a/image_to_vm.sh b/image_to_vm.sh index 89af92f6f1..c0f67fdd47 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -166,7 +166,6 @@ else fi sudo e2fsck -pf "${STATEFUL_LOOP_DEV}" sudo resize2fs "${STATEFUL_LOOP_DEV}" - sync sudo losetup -d "${STATEFUL_LOOP_DEV}" fi fi @@ -194,7 +193,6 @@ sudo python "${SCRIPTS_DIR}/fixup_image_for_qemu.py" \ sudo sed -i -e 's/sdb3/sda3/g' "${TEMP_MNT}/boot/syslinux/usb.A.cfg" # Unmount everything prior to building a final image -sync trap - INT TERM EXIT cleanup