ZFS: fix the redundancy tests

* Fix force_sync_path, which ensures that a file is fully flushed to disk.
  Apparently "zpool history"'s performance has improved, but exporting and
  importing the pool still works.
* Fix file_dva by using undocumented zdb syntax to clarify that we're
  interested in the pool's root file system, not the pool itself. This
  should also fix the zpool_clear_001_pos test.
* Remove a redundant cleanup step

MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision:	https://reviews.freebsd.org/D21901
This commit is contained in:
Alan Somers 2019-10-07 20:21:23 +00:00
parent bbacbaccf9
commit c43f30ee6b
3 changed files with 6 additions and 10 deletions

View File

@ -2676,8 +2676,7 @@ function gen_dataset_name
#
# Ensure that a given path has been synced, not just ZIL committed.
#
# XXX The implementation currently requires calling 'zpool history'. On
# FreeBSD, the sync(8) command (via $SYNC) calls zfs_sync() which just
# XXX On FreeBSD, the sync(8) command (via $SYNC) calls zfs_sync() which just
# does a zil_commit(), as opposed to a txg_wait_synced(). For things that
# require writing to their final destination (e.g. for intentional
# corruption purposes), zil_commit() is not good enough.
@ -2686,10 +2685,8 @@ function force_sync_path # path
{
typeset path="$1"
zfspath=$($DF $path 2>/dev/null | tail -1 | cut -d" " -f1 | cut -d/ -f1)
[ -z "$zfspath" ] && return false
log_note "Force syncing ${zfspath} for ${path} ..."
$ZPOOL history $zfspath >/dev/null 2>&1
log_must $ZPOOL export $TESTPOOL
log_must $ZPOOL import -d $path $TESTPOOL
}
#
@ -3326,7 +3323,7 @@ function file_dva # dataset filepath [level] [offset] [dva_num]
# The inner match is for 'DVA[0]=<0:1b412600:200>', in which the
# text surrounding the actual DVA is a fixed size with 8 characters
# before it and 1 after.
$ZDB -P -vvvvv $dataset $inode | \
$ZDB -P -vvvvv "$dataset/" $inode | \
$AWK -v level=${level} -v dva_num=${dva_num} '
BEGIN { stage = 0; }
(stage == 0) && ($1=="Object") { stage = 1; next; }

View File

@ -98,7 +98,7 @@ function setup_test_env
typeset file=$TESTDIR/file
log_must $FILE_WRITE -o create -f $file -b $BLOCKSZ -c $NUM_WRITES
log_must force_sync_path $TESTDIR
force_sync_path $BASEDIR
record_data $TESTPOOL $PRE_RECORD_FILE
}
@ -142,7 +142,7 @@ function sync_pool #pool
{
typeset pool=$1
log_must force_sync_path $pool
force_sync_path $BASEDIR
# If the OS has detected corruption on the pool, it will have
# automatically initiated a scrub. In that case, our "zpool scrub"

View File

@ -62,7 +62,6 @@
verify_runnable "global"
log_assert "Verify raidz pool can withstand one device is failing."
log_onexit cleanup
for cnt in 3 2; do
setup_test_env $TESTPOOL raidz $cnt