Skip to content

Commit

Permalink
ZTS: Misc fixes for FreeBSD
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Ryan Moeller committed Feb 27, 2020
1 parent ab96461 commit 3d5ba1c
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 53 deletions.
9 changes: 9 additions & 0 deletions tests/zfs-tests/include/blkdev.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@ function corrupt_blocks_at_level # input_file corrupt_level

[[ -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 | \
while read level path offset length; do
Expand All @@ -586,6 +591,10 @@ function corrupt_blocks_at_level # input_file corrupt_level
fi
done

if is_freebsd; then
sysctl kern.geom.debugflags=$debugflags
fi

# This is necessary for pools made of loop devices.
sync
}
1 change: 1 addition & 0 deletions tests/zfs-tests/include/commands.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export SYSTEM_FILES_COMMON='arp

export SYSTEM_FILES_FREEBSD='chflags
compress
diskinfo
dumpon
env
fsck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ verify_runnable "both"

function cleanup
{
echo cleanup
[[ -e $TESTDIR ]] && \
log_must rm -rf $TESTDIR/* > /dev/null 2>&1
rm -fr $TESTDIR/*
}

log_assert "Create and read back files with using different checksum algorithms"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ZFS_TXG_TIMEOUT=""
function custom_cleanup
{
# 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 rm -rf $BACKUP_DEVICE_DIR
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
typeset pool=$1

if is_linux; then
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
zdb -u $pool | awk '$1 == "txg" { print $3 }' | sort -n | tail -n 1
}
6 changes: 5 additions & 1 deletion tests/zfs-tests/tests/functional/history/history.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export TMP_HISTORY=$TEST_BASE_DIR/tmp_history.$$
export NEW_HISTORY=$TEST_BASE_DIR/new_history.$$

export MIGRATEDPOOLNAME=${MIGRATEDPOOLNAME:-history_pool}
export TIMEZONE=${TIMEZONE:-US/Mountain}
if is_freebsd; then
export TIMEZONE=${TIMEZONE:-America/Denver}
else
export TIMEZONE=${TIMEZONE:-US/Mountain}
fi

export HIST_USER="huser"
export HIST_GROUP="hgroup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file
# Verify 'ulimit -f <size>' works
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 'truncate -s2M $TESTDIR/ulimit_trunc_file'
log_must rm $TESTDIR/ulimit_write_file $TESTDIR/ulimit_trunc_file
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_must rm $TESTDIR/ulimit_trunc_file
fi

log_pass "Successfully enforced 'ulimit -f' maximum file size"
13 changes: 4 additions & 9 deletions tests/zfs-tests/tests/functional/removal/removal_cancel.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,14 @@ log_must randwritecomp $SAMPLEFILE 25000
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.
# Block removal.
#
log_must sleep 1
log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1

#
# Block removal.
# Start removal.
#
log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1
log_must zpool remove $TESTPOOL $REMOVEDISK

#
# Only for debugging purposes in test logs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ function verify_restarts # <msg> <cnt> <defer>
[[ -z "$defer" ]] && return

# use zdb to find which vdevs have the resilver defer flag
VDEV_DEFERS=$(zdb -C $TESTPOOL | \
sed -n -e '/^ *children\[[0-9]\].*$/{h}' \
-e '/ *com.datto:resilver_defer$/{g;p}')
VDEV_DEFERS=$(zdb -C $TESTPOOL | awk '
/children/ { gsub(/[^0-9]/, ""); child = $0 }
/com\.datto:resilver_defer$/ { print child }
')

if [[ "$defer" == "-" ]]
then
Expand All @@ -81,7 +82,7 @@ function verify_restarts # <msg> <cnt> <defer>
return
fi

[[ "x${VDEV_DEFERS}x" =~ "x +children[$defer]:x" ]] ||
[[ $VDEV_DEFERS -eq $defer ]] ||
log_fail "resilver deferred set on unexpected vdev: $VDEV_DEFERS"
}

Expand Down

0 comments on commit 3d5ba1c

Please sign in to comment.