From owner-svn-src-stable@FreeBSD.ORG Mon Mar 19 23:17:27 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DC21106564A; Mon, 19 Mar 2012 23:17:27 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0EA518FC12; Mon, 19 Mar 2012 23:17:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2JNHQOi091405; Mon, 19 Mar 2012 23:17:26 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2JNHQgl091402; Mon, 19 Mar 2012 23:17:26 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201203192317.q2JNHQgl091402@svn.freebsd.org> From: Josh Paetzel Date: Mon, 19 Mar 2012 23:17:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233223 - stable/9/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2012 23:17:27 -0000 Author: jpaetzel Date: Mon Mar 19 23:17:26 2012 New Revision: 233223 URL: http://svn.freebsd.org/changeset/base/233223 Log: MFC: 232898 Improve ZFS exporting functionality, only export pools which are on a specific device we happen to be writing to. This fixes an issue when running pc-sysinstall on a running system which needs ZFS and the main disk gets exported. Submitted by: kmoore Obtained from: PC-BSD Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh Directory Properties: stable/9/usr.sbin/pc-sysinstall/ (props changed) Modified: stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh Mon Mar 19 23:14:47 2012 (r233222) +++ stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh Mon Mar 19 23:17:26 2012 (r233223) @@ -224,16 +224,6 @@ get_disk_mediasize() export VAL="${mediasize}" }; -# Function which exports all zpools, making them safe to overwrite potentially -export_all_zpools() -{ - # Export any zpools - for i in `zpool list -H -o name` - do - zpool export -f ${i} - done -}; - # Function to delete all gparts before starting an install delete_all_gpart() { @@ -268,10 +258,15 @@ delete_all_gpart() # Function to export all zpools before starting an install stop_all_zfs() { - # Export all zpools again, so that we can overwrite these partitions potentially + local DISK="`echo ${1} | sed 's|/dev/||g'`" + + # Export any zpools using this device so we can overwrite for i in `zpool list -H -o name` do - zpool export -f ${i} + ztst=`zpool status ${i} | grep "ONLINE" | awk '{print $1}' | grep -q ${DISK}` + if [ "$ztst" = "$DISK" ] ; then + zpool export -f ${i} + fi done }; @@ -324,9 +319,6 @@ setup_disk_slice() disknum="0" gmnum="0" - # Make sure all zpools are exported - export_all_zpools - # We are ready to start setting up the disks, lets read the config and do the actions while read line do @@ -354,7 +346,7 @@ setup_disk_slice() stop_all_geli ${DISK} # Make sure we don't have any zpools loaded - stop_all_zfs + stop_all_zfs ${DISK} fi @@ -375,6 +367,16 @@ setup_disk_slice() then exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!" fi + + # Make sure we stop any gmirrors on this mirror disk + stop_all_gmirror ${MIRRORDISK} + + # Make sure we stop any geli stuff on this mirror disk + stop_all_geli ${MIRRORDISK} + + # Make sure we don't have any zpools mirror loaded + stop_all_zfs ${MIRRORDISK} + fi # Lets see if we have been given a mirror balance choice