Author: jpaetzel
Date: Mon Mar 12 21:28:54 2012
New Revision: 232898
URL: http://svn.freebsd.org/changeset/base/232898

Log:
  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: kris
  Obtained from:        PC-BSD

Modified:
  head/usr.sbin/pc-sysinstall/backend/functions-disk.sh

Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh       Mon Mar 12 
21:26:09 2012        (r232897)
+++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh       Mon Mar 12 
21:28:54 2012        (r232898)
@@ -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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to