ZTS: Misc fixes for FreeBSD

* Set geom debug flags in corrupt_blocks_at_level
* Use the right time zone for history tests
* Add missing commands.cfg entry for diskinfo
* Rewrite get_last_txg_synced to use zdb
* Don't check ulimits for sparse files
* Suspend removal before removing a vdev, not after

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10054
This commit is contained in:
Ryan Moeller 2020-02-27 12:38:34 -05:00 committed by GitHub
parent ab9646166d
commit 3d5ba1cf29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 35 additions and 54 deletions

View File

@ -577,6 +577,11 @@ function corrupt_blocks_at_level # input_file corrupt_level
[[ -f $input_file ]] || log_fail "Couldn't find $input_file" [[ -f $input_file ]] || log_fail "Couldn't find $input_file"
if is_freebsd; then
# Temporarily allow corrupting an inuse device.
debugflags=$(sysctl -n kern.geom.debugflags)
sysctl kern.geom.debugflags=16
fi
log_must list_file_blocks $input_file | \ log_must list_file_blocks $input_file | \
while read level path offset length; do while read level path offset length; do
@ -586,6 +591,10 @@ function corrupt_blocks_at_level # input_file corrupt_level
fi fi
done done
if is_freebsd; then
sysctl kern.geom.debugflags=$debugflags
fi
# This is necessary for pools made of loop devices. # This is necessary for pools made of loop devices.
sync sync
} }

View File

@ -113,6 +113,7 @@ export SYSTEM_FILES_COMMON='arp
export SYSTEM_FILES_FREEBSD='chflags export SYSTEM_FILES_FREEBSD='chflags
compress compress
diskinfo
dumpon dumpon
env env
fsck fsck

View File

@ -54,9 +54,7 @@ verify_runnable "both"
function cleanup function cleanup
{ {
echo cleanup rm -fr $TESTDIR/*
[[ -e $TESTDIR ]] && \
log_must rm -rf $TESTDIR/* > /dev/null 2>&1
} }
log_assert "Create and read back files with using different checksum algorithms" log_assert "Create and read back files with using different checksum algorithms"

View File

@ -60,7 +60,7 @@ ZFS_TXG_TIMEOUT=""
function custom_cleanup function custom_cleanup
{ {
# Revert zfs_txg_timeout to defaults # Revert zfs_txg_timeout to defaults
[[ -n ZFS_TXG_TIMEOUT ]] && [[ -n $ZFS_TXG_TIMEOUT ]] &&
log_must set_zfs_txg_timeout $ZFS_TXG_TIMEOUT log_must set_zfs_txg_timeout $ZFS_TXG_TIMEOUT
log_must rm -rf $BACKUP_DEVICE_DIR log_must rm -rf $BACKUP_DEVICE_DIR
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0

View File

@ -346,42 +346,11 @@ function set_zfs_max_missing_tvds
} }
# #
# Use mdb to find the last txg that was synced in an active pool. # Use zdb to find the last txg that was synced in an active pool.
# #
function get_last_txg_synced function get_last_txg_synced
{ {
typeset pool=$1 typeset pool=$1
if is_linux; then zdb -u $pool | awk '$1 == "txg" { print $3 }' | sort -n | tail -n 1
txg=$(tail "/proc/spl/kstat/zfs/$pool/txgs" |
awk '$3=="C" {print $1}' | tail -1)
[[ "$txg" ]] || txg=0
echo $txg
return 0
fi
typeset spas
spas=$(mdb -k -e "::spa")
[[ $? -ne 0 ]] && return 1
typeset spa=""
print "$spas\n" | while read line; do
typeset poolname=$(echo "$line" | awk '{print $3}')
typeset addr=$(echo "$line" | awk '{print $1}')
if [[ $poolname == $pool ]]; then
spa=$addr
break
fi
done
if [[ -z $spa ]]; then
log_fail "Couldn't find pool '$pool'"
return 1
fi
typeset mdbcmd="$spa::print spa_t spa_ubsync.ub_txg | ::eval '.=E'"
typeset -i txg
txg=$(mdb -k -e "$mdbcmd")
[[ $? -ne 0 ]] && return 1
echo $txg
return 0
} }

View File

@ -37,7 +37,11 @@ export TMP_HISTORY=$TEST_BASE_DIR/tmp_history.$$
export NEW_HISTORY=$TEST_BASE_DIR/new_history.$$ export NEW_HISTORY=$TEST_BASE_DIR/new_history.$$
export MIGRATEDPOOLNAME=${MIGRATEDPOOLNAME:-history_pool} export MIGRATEDPOOLNAME=${MIGRATEDPOOLNAME:-history_pool}
if is_freebsd; then
export TIMEZONE=${TIMEZONE:-America/Denver}
else
export TIMEZONE=${TIMEZONE:-US/Mountain} export TIMEZONE=${TIMEZONE:-US/Mountain}
fi
export HIST_USER="huser" export HIST_USER="huser"
export HIST_GROUP="hgroup" export HIST_GROUP="hgroup"

View File

@ -49,7 +49,11 @@ log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file
# Verify 'ulimit -f <size>' works # Verify 'ulimit -f <size>' works
log_must ulimit -f 1024 log_must ulimit -f 1024
log_mustnot sh -c 'dd if=/dev/zero of=$TESTDIR/ulimit_write_file bs=1M count=2' log_mustnot sh -c 'dd if=/dev/zero of=$TESTDIR/ulimit_write_file bs=1M count=2'
log_must rm $TESTDIR/ulimit_write_file
# FreeBSD allows the sparse file because space has not been allocated.
if !is_freebsd; then
log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file' log_mustnot sh -c 'truncate -s2M $TESTDIR/ulimit_trunc_file'
log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file log_must rm $TESTDIR/ulimit_trunc_file
fi
log_pass "Successfully enforced 'ulimit -f' maximum file size" log_pass "Successfully enforced 'ulimit -f' maximum file size"

View File

@ -66,21 +66,16 @@ log_must randwritecomp $SAMPLEFILE 25000
# #
log_must zpool add -f $TESTPOOL $NOTREMOVEDISK log_must zpool add -f $TESTPOOL $NOTREMOVEDISK
#
# Start removal.
#
log_must zpool remove $TESTPOOL $REMOVEDISK
#
# Sleep a bit and hopefully allow removal to copy some data.
#
log_must sleep 1
# #
# Block removal. # Block removal.
# #
log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1 log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1
#
# Start removal.
#
log_must zpool remove $TESTPOOL $REMOVEDISK
# #
# Only for debugging purposes in test logs. # Only for debugging purposes in test logs.
# #

View File

@ -70,9 +70,10 @@ function verify_restarts # <msg> <cnt> <defer>
[[ -z "$defer" ]] && return [[ -z "$defer" ]] && return
# use zdb to find which vdevs have the resilver defer flag # use zdb to find which vdevs have the resilver defer flag
VDEV_DEFERS=$(zdb -C $TESTPOOL | \ VDEV_DEFERS=$(zdb -C $TESTPOOL | awk '
sed -n -e '/^ *children\[[0-9]\].*$/{h}' \ /children/ { gsub(/[^0-9]/, ""); child = $0 }
-e '/ *com.datto:resilver_defer$/{g;p}') /com\.datto:resilver_defer$/ { print child }
')
if [[ "$defer" == "-" ]] if [[ "$defer" == "-" ]]
then then
@ -81,7 +82,7 @@ function verify_restarts # <msg> <cnt> <defer>
return return
fi fi
[[ "x${VDEV_DEFERS}x" =~ "x +children[$defer]:x" ]] || [[ $VDEV_DEFERS -eq $defer ]] ||
log_fail "resilver deferred set on unexpected vdev: $VDEV_DEFERS" log_fail "resilver deferred set on unexpected vdev: $VDEV_DEFERS"
} }