Use GNOP to force ZFS pools to 4k.

Obtained from:	PC-BSD
This commit is contained in:
Josh Paetzel 2013-03-03 23:07:27 +00:00
parent 9090eb778e
commit 4a99f3fcc1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=247735
6 changed files with 66 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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`"

View File

@ -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

View File

@ -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

View File

@ -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"