ZTS: Fix EBUSY volume destroy failures

It's possible for an unrelated process, like blkid, to have the
volume open when 'zfs destroy' is run.  Switch the cleanup functions
to the destroy_dataset() helper which handles this case by retrying
the destroy when the dataset is busy.  This was done not only for
volumes but also for file systems for consistency.

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7854
This commit is contained in:
Brian Behlendorf 2018-08-31 15:30:44 -07:00 committed by GitHub
parent e927fc8a52
commit bb91178e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 41 additions and 52 deletions

View File

@ -216,8 +216,6 @@ maybe = {
'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason], 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason], 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason],
'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'], 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'],
'cli_root/zfs_receive/receive-o-x_props_override':
['FAIL', known_reason],
'cli_root/zfs_rename/zfs_rename_006_pos': ['FAIL', '5647'], 'cli_root/zfs_rename/zfs_rename_006_pos': ['FAIL', '5647'],
'cli_root/zfs_rename/zfs_rename_009_neg': ['FAIL', '5648'], 'cli_root/zfs_rename/zfs_rename_009_neg': ['FAIL', '5648'],
'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', '6415'], 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', '6415'],

View File

@ -22,7 +22,7 @@ fs=$TESTPOOL/$TESTFS/testchild
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy $fs destroy_dataset $fs
} }
log_onexit cleanup log_onexit cleanup

View File

@ -22,7 +22,7 @@ snap=$TESTPOOL/$TESTFS@$TESTSNAP
function cleanup function cleanup
{ {
datasetexists $snap && log_must zfs destroy $snap destroy_dataset $snap
} }
log_onexit cleanup log_onexit cleanup

View File

@ -29,7 +29,7 @@ snap=$fs@$TESTSNAP
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
log_must rm -rf $fs/foo log_must rm -rf $fs/foo
log_must rm -rf $fs/bar log_must rm -rf $fs/bar
} }

View File

@ -27,7 +27,7 @@ fs=$TESTPOOL/$TESTFS/testchild
snap=$fs@$TESTSNAP snap=$fs@$TESTSNAP
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
} }
log_onexit cleanup log_onexit cleanup

View File

@ -31,8 +31,8 @@ mnt2=/$fs/mnt2
function cleanup function cleanup
{ {
datasetexists $clone && log_must zfs destroy $clone destroy_dataset $clone
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
log_must rm -rf $mnt1 log_must rm -rf $mnt1
log_must rm -rf $mnt2 log_must rm -rf $mnt2
} }

View File

@ -25,7 +25,7 @@ verify_runnable "global"
fs=$TESTPOOL/$TESTFS/testchild fs=$TESTPOOL/$TESTFS/testchild
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy $fs destroy_dataset $fs
} }
log_onexit cleanup log_onexit cleanup

View File

@ -30,8 +30,8 @@ vol=$TESTPOOL/$TESTVOL
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
datasetexists $vol && log_must zfs destroy $vol destroy_dataset $vol
} }
log_onexit cleanup log_onexit cleanup

View File

@ -28,9 +28,9 @@ snap=$fs@$TESTSNAP
vol=$TESTPOOL/$TESTVOL vol=$TESTPOOL/$TESTVOL
function cleanup function cleanup
{ {
datasetexists $snap && log_must zfs destroy $snap destroy_dataset $snap
datasetexists $fs && log_must zfs destroy $fs destroy_dataset $fs
datasetexists $vol && log_must zfs destroy $vol destroy_dataset $vol
} }
log_onexit cleanup log_onexit cleanup

View File

@ -31,8 +31,8 @@ groupid='456'
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy $fs destroy_dataset $fs
datasetexists $fs1 && log_must zfs destroy $fs1 destroy_dataset $fs1
} }
log_onexit cleanup log_onexit cleanup

View File

@ -30,7 +30,7 @@ dir=/$fs/dir
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
log_must rm -rf $dir log_must rm -rf $dir
} }

View File

@ -32,10 +32,10 @@ TESTCHILD3=$TESTCHILD-3
function cleanup function cleanup
{ {
datasetexists $TESTCHILD && log_must zfs destroy $TESTCHILD destroy_dataset $TESTCHILD
datasetexists $TESTCHILD1 && log_must zfs destroy $TESTCHILD1 destroy_dataset $TESTCHILD1
datasetexists $TESTCHILD2 && log_must zfs destroy $TESTCHILD2 destroy_dataset $TESTCHILD2
datasetexists $TESTCHILD3 && log_must zfs destroy $TESTCHILD3 destroy_dataset $TESTCHILD3
} }
log_onexit cleanup log_onexit cleanup

View File

@ -27,8 +27,7 @@ log_assert "Listing zfs clones should work correctly."
function cleanup function cleanup
{ {
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP "-R"
log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
} }
log_onexit cleanup log_onexit cleanup

View File

@ -27,14 +27,10 @@ log_assert "Listing zfs snapshots should work correctly."
function cleanup function cleanup
{ {
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP1
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP1 && \ destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP2
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP1 destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP3
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP2 && \
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP2
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP3 && \
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP3
} }
log_onexit cleanup log_onexit cleanup

View File

@ -28,9 +28,9 @@ snap=$fs@$TESTSNAP
vol=$TESTPOOL/$TESTVOL vol=$TESTPOOL/$TESTVOL
function cleanup function cleanup
{ {
datasetexists $snap && log_must zfs destroy $snap destroy_dataset $snap
datasetexists $fs && log_must zfs destroy $fs destroy_dataset $fs
datasetexists $vol && log_must zfs destroy $vol destroy_dataset $vol
} }
log_onexit cleanup log_onexit cleanup

View File

@ -32,7 +32,7 @@ snap=promote_conflict_snap
function cleanup function cleanup
{ {
for to_destroy in $fs $clone; do for to_destroy in $fs $clone; do
datasetexists $to_destroy && log_must zfs destroy -R $to_destroy destroy_dataset $to_destroy "-R"
done done
} }

View File

@ -32,7 +32,7 @@ snap2=$clone1@testchild_snap2
function cleanup function cleanup
{ {
for to_destroy in $fs $clone1 $clone2; do for to_destroy in $fs $clone1 $clone2; do
datasetexists $to_destroy && log_must zfs destroy -R $to_destroy destroy_dataset $to_destroy "-R"
done done
} }

View File

@ -30,7 +30,7 @@ snap=$fs@$TESTSNAP
function cleanup function cleanup
{ {
for to_destroy in $fs $clone; do for to_destroy in $fs $clone; do
datasetexists $to_destroy && log_must zfs destroy -R $to_destroy destroy_dataset $to_destroy "-R"
done done
} }

View File

@ -24,8 +24,7 @@ file=$TESTDIR/$TESTFILE0
function cleanup function cleanup
{ {
datasetexists $snap1 && log_must zfs destroy $snap1 && \ destroy_dataset $snap1 && log_must rm $file
log_must rm $file
} }
log_onexit cleanup log_onexit cleanup

View File

@ -23,9 +23,7 @@ file=$TESTDIR/$TESTFILE0
function cleanup function cleanup
{ {
datasetexists $snap && log_must zfs destroy $snap && \ destroy_dataset $snap && log_must rm $file
log_must rm $file
} }
log_onexit cleanup log_onexit cleanup

View File

@ -26,7 +26,7 @@ fs=$TESTPOOL/$TESTFS/testchild
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
} }
log_onexit cleanup log_onexit cleanup

View File

@ -28,7 +28,7 @@ fs2=$TESTPOOL/$TESTFS/testchild2
function cleanup function cleanup
{ {
for fs in $fs1 $fs2; do for fs in $fs1 $fs2; do
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
done done
} }

View File

@ -28,7 +28,7 @@ snapname=snap
function cleanup function cleanup
{ {
datasetexists $rootfs && log_must zfs destroy -R $rootfs destroy_dataset $rootfs "-R"
} }
log_onexit cleanup log_onexit cleanup

View File

@ -27,7 +27,7 @@ snapname=testsnap
function cleanup function cleanup
{ {
datasetexists $fs && log_must zfs destroy -R $fs destroy_dataset $fs "-R"
} }
log_onexit cleanup log_onexit cleanup

View File

@ -47,9 +47,7 @@ function cleanup
{ {
typeset -i j=0 typeset -i j=0
while [[ $j -lt ${#size[*]} ]]; do while [[ $j -lt ${#size[*]} ]]; do
if datasetexists $TESTPOOL/${TESTVOL}${size[j]}; then destroy_dataset $TESTPOOL/${TESTVOL}${size[j]}
log_must zfs destroy $TESTPOOL/${TESTVOL}${size[j]}
fi
((j = j + 1)) ((j = j + 1))
done done
} }

View File

@ -268,7 +268,7 @@ log_must zfs snapshot $orig@snap1
log_must eval "zfs send $orig@snap1 > $streamfile_full" log_must eval "zfs send $orig@snap1 > $streamfile_full"
log_mustnot eval "zfs receive -x atime $dest < $streamfile_full" log_mustnot eval "zfs receive -x atime $dest < $streamfile_full"
log_mustnot eval "zfs receive -o atime=off $dest < $streamfile_full" log_mustnot eval "zfs receive -o atime=off $dest < $streamfile_full"
log_must zfs destroy -r -f $orig log_must_busy zfs destroy -r -f $orig
log_must zfs create $orig log_must zfs create $orig
log_must zfs create -V 128K -s $origsub log_must zfs create -V 128K -s $origsub
log_must zfs snapshot -r $orig@snap1 log_must zfs snapshot -r $orig@snap1
@ -279,8 +279,9 @@ log_must eval "check_prop_source $dest atime off local"
log_must eval "check_prop_source $destsub type volume -" log_must eval "check_prop_source $destsub type volume -"
log_must eval "check_prop_source $destsub atime - -" log_must eval "check_prop_source $destsub atime - -"
# Cleanup # Cleanup
log_must zfs destroy -r -f $orig block_device_wait
log_must zfs destroy -r -f $dest log_must_busy zfs destroy -r -f $orig
log_must_busy zfs destroy -r -f $dest
# #
# 3.8 Verify 'zfs recv -x|-o' works correctly when used in conjunction with -d # 3.8 Verify 'zfs recv -x|-o' works correctly when used in conjunction with -d