svn commit: r247735 - in head/usr.sbin/pc-sysinstall: backend conf

Josh Paetzel jpaetzel at FreeBSD.org
Sun Mar 3 23:07:29 UTC 2013


Author: jpaetzel
Date: Sun Mar  3 23:07:27 2013
New Revision: 247735
URL: http://svnweb.freebsd.org/changeset/base/247735

Log:
  Use GNOP to force ZFS pools to 4k.
  
  Obtained from:	PC-BSD

Modified:
  head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
  head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
  head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
  head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
  head/usr.sbin/pc-sysinstall/backend/functions.sh
  head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf

Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Sun Mar  3 23:01:46 2013	(r247734)
+++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Sun Mar  3 23:07:27 2013	(r247735)
@@ -62,7 +62,18 @@ get_fs_line_xvars()
     echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null
     if [ $? -eq 0 ] ; then
        ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
-       ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
+       tmpVars=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
+       ZFSVARS=""
+       # make sure we have a '/dev' in front of the extra devices
+       for i in $tmpVars
+       do
+          echo $i | grep -q '/dev/'
+          if [ $? -ne 0 ] ; then
+             ZFSVARS="$ZFSVARS /dev/${i}"
+          else
+             ZFSVARS="$ZFSVARS $i"
+          fi
+       done
     fi
 
     # Return the ZFS options

Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh	Sun Mar  3 23:01:46 2013	(r247734)
+++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh	Sun Mar  3 23:07:27 2013	(r247735)
@@ -33,6 +33,7 @@ is_disk()
   for _dsk in `sysctl -n kern.disks`
   do
     [ "$_dsk" = "${1}" ] && return 0
+    [ "/dev/$_dsk" = "${1}" ] && return 0
   done
 
   return 1

Modified: head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh	Sun Mar  3 23:01:46 2013	(r247734)
+++ head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh	Sun Mar  3 23:07:27 2013	(r247735)
@@ -149,12 +149,12 @@ mount_all_filesystems()
   for PART in `ls ${PARTDIR}`
   do
     PARTDEV=`echo $PART | sed 's|-|/|g'` 
-    if [ ! -e "${PARTDEV}" ]
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ]
     then
       exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
     fi 
 
-    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
     PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
     PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
 
@@ -186,12 +186,12 @@ mount_all_filesystems()
   for PART in `ls ${PARTDIR}`
   do
     PARTDEV=`echo $PART | sed 's|-|/|g'`
-    if [ ! -e "${PARTDEV}" ]
+    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+    if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ]
     then
       exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
     fi 
      
-    PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
     PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
     PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
 

Modified: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh	Sun Mar  3 23:01:46 2013	(r247734)
+++ head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh	Sun Mar  3 23:07:27 2013	(r247735)
@@ -60,18 +60,56 @@ setup_zfs_filesystem()
     fi
   done 
 
-
   # Check if we have some custom zpool arguments and use them if so
   if [ ! -z "${ZPOOLOPTS}" ] ; then
-    rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}"
+    # Sort through devices and run gnop on them
+    local gnopDev=""
+    local newOpts=""
+    for i in $ZPOOLOPTS
+    do
+       echo "$i" | grep -q '/dev/'
+       if [ $? -eq 0 ] ; then
+          rc_halt "gnop create -S 4096 ${i}"
+          gnopDev="$gnopDev $i"
+          newOpts="$newOpts ${i}.nop"
+       else
+          newOpts="$newOpts $i"
+       fi
+    done
+    
+    echo_log "Creating zpool ${ZPOOLNAME} with $newOpts"
+    rc_halt "zpool create -m none -f ${ZPOOLNAME} ${newOpts}"
+
+    # Export the pool
+    rc_halt "zpool export ${ZPOOLNAME}"
+
+    # Destroy the gnop devices
+    for i in $gnopDev
+    do
+       rc_halt "gnop destroy ${i}.nop"
+    done
+
+    # And lastly re-import the pool
+    rc_halt "zpool import ${ZPOOLNAME}"
   else
+    # Lets do our pseudo-4k drive
+    rc_halt "gnop create -S 4096 ${PART}${EXT}"
+
     # No zpool options, create pool on single device
-    rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}"
+    echo_log "Creating zpool ${ZPOOLNAME} on ${PART}${EXT}"
+    rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}.nop"
+
+    # Finish up the gnop 4k trickery
+    rc_halt "zpool export ${ZPOOLNAME}"
+    rc_halt "gnop destroy ${PART}${EXT}.nop"
+    rc_halt "zpool import ${ZPOOLNAME}"
   fi
 
   # Disable atime for this zfs partition, speed increase
   rc_nohalt "zfs set atime=off ${ZPOOLNAME}"
 
+
+
 };
 
 # Runs newfs on all the partiions which we've setup with bsdlabel

Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions.sh	Sun Mar  3 23:01:46 2013	(r247734)
+++ head/usr.sbin/pc-sysinstall/backend/functions.sh	Sun Mar  3 23:07:27 2013	(r247735)
@@ -277,7 +277,11 @@ get_zpool_name()
     while :
     do
       NEWNAME="${BASENAME}${NUM}"
-      zpool import | grep -qw "${NEWNAME}" || break
+      zpool list | grep -qw "${NEWNAME}"
+      local chk1=$?
+      zpool import | grep -qw "${NEWNAME}"
+      local chk2=$?
+      if [ $chk1 -eq 1 -a $chk2 -eq 1 ] ; then break ; fi 
       NUM=$((NUM+1))
     done
 

Modified: head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
==============================================================================
--- head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf	Sun Mar  3 23:01:46 2013	(r247734)
+++ head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf	Sun Mar  3 23:07:27 2013	(r247735)
@@ -5,11 +5,9 @@
 TMPDIR="/tmp/.pc-sysinstall"
 export TMPDIR
 
-if [ ! -d "${TMPDIR}" ]
-then
-  mkdir -p ${TMPDIR}
-  chmod 777 ${TMPDIR}
-fi
+# Create a fresh TMPDIR
+if [ -d "${TMPDIR}" -a "$TMPDIR" != '/' ]; then rm -rf ${TMPDIR}; fi
+mkdir -p ${TMPDIR}
 
 # Set our temp directory for storing partition information
 PARTDIR="${TMPDIR}/part-info"


More information about the svn-src-all mailing list