From owner-svn-src-head@FreeBSD.ORG Mon Mar 30 08:33:20 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C427E913; Mon, 30 Mar 2015 08:33:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9512C97E; Mon, 30 Mar 2015 08:33:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2U8XKfC056490; Mon, 30 Mar 2015 08:33:20 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2U8XKfe056489; Mon, 30 Mar 2015 08:33:20 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201503300833.t2U8XKfe056489@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Mon, 30 Mar 2015 08:33:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280840 - head/release/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2015 08:33:20 -0000 Author: cperciva Date: Mon Mar 30 08:33:19 2015 New Revision: 280840 URL: https://svnweb.freebsd.org/changeset/base/280840 Log: Clean up filesystem unmounting in vmimage builds: * Remove vm_umount_base function which is currently unused. * Add umount_loop function which loops attempting to unmount one filesystem. * Replace calls to umount with calls to umount_loop. * Don't attempt to unmount ${DESTDIR}/dev if it isn't mounted. The looping is necessary because sometimes umount fails due to filesystems being busy. The most common cause of such busyness is periodic(8) jobs running `find / ...`. Reviewed by: gjb Modified: head/release/tools/vmimage.subr Modified: head/release/tools/vmimage.subr ============================================================================== --- head/release/tools/vmimage.subr Mon Mar 30 07:11:49 2015 (r280839) +++ head/release/tools/vmimage.subr Mon Mar 30 08:33:19 2015 (r280840) @@ -45,8 +45,10 @@ err() { } cleanup() { - umount ${DESTDIR}/dev 2>/dev/null - umount ${DESTDIR} + if mount | grep -qE "devfs on ${DESTDIR}/dev"; then + umount_loop ${DESTDIR}/dev 2>/dev/null + fi + umount_loop ${DESTDIR} if [ ! -z "${mddev}" ]; then mdconfig -d -u ${mddev} fi @@ -86,11 +88,11 @@ vm_copy_base() { tar -cf- -C ${DESTDIR}/old . | tar -xf- -C ${DESTDIR}/new - umount /dev/${mdold} + umount_loop /dev/${mdold} rmdir ${DESTDIR}/old mdconfig -d -u ${mdold} - umount /dev/${mdnew} + umount_loop /dev/${mdnew} rmdir ${DESTDIR}/new mdconfig -d -u ${mdnew} mv ${VMBASE}.tmp ${VMBASE} @@ -117,7 +119,7 @@ vm_install_base() { mount -t devfs devfs ${DESTDIR}/dev chroot ${DESTDIR} /usr/bin/newaliases chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart - umount ${DESTDIR}/dev + umount_loop ${DESTDIR}/dev cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf @@ -152,7 +154,7 @@ vm_extra_install_packages() { /usr/sbin/pkg bootstrap -y chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} - umount ${DESTDIR}/dev + umount_loop ${DESTDIR}/dev return 0 } @@ -181,16 +183,17 @@ vm_extra_pkg_rmcache() { return 0 } -vm_umount_base() { +umount_loop() { + DIR=$1 i=0 sync - while ! umount ${DESTDIR}/dev ${DESTDIR}; do + while ! umount ${DIR}; do i=$(( $i + 1 )) if [ $i -ge 10 ]; then # This should never happen. But, it has happened. - msg="Cannot umount(8) ${DESTDIR}\n" - msg="${msg}Something has gone horribly wrong." - err "${msg}" + echo "Cannot umount(8) ${DIR}" + echo "Something has gone horribly wrong." + return 1 fi sleep 1 done