Skip to content

Commit

Permalink
ZTS: Fix EBUSY volume destroy failures
Browse files Browse the repository at this point in the history
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
  • Loading branch information
behlendorf committed Aug 31, 2018
1 parent e927fc8 commit bb91178
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 52 deletions.
2 changes: 0 additions & 2 deletions tests/test-runner/bin/zts-report.py
Expand Up @@ -216,8 +216,6 @@
'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_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_009_neg': ['FAIL', '5648'],
'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', '6415'],
Expand Down
Expand Up @@ -22,7 +22,7 @@ fs=$TESTPOOL/$TESTFS/testchild

function cleanup
{
datasetexists $fs && log_must zfs destroy $fs
destroy_dataset $fs
}

log_onexit cleanup
Expand Down
Expand Up @@ -22,7 +22,7 @@ snap=$TESTPOOL/$TESTFS@$TESTSNAP

function cleanup
{
datasetexists $snap && log_must zfs destroy $snap
destroy_dataset $snap
}

log_onexit cleanup
Expand Down
Expand Up @@ -29,7 +29,7 @@ snap=$fs@$TESTSNAP

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/bar
}
Expand Down
Expand Up @@ -27,7 +27,7 @@ fs=$TESTPOOL/$TESTFS/testchild
snap=$fs@$TESTSNAP
function cleanup
{
datasetexists $fs && log_must zfs destroy -R $fs
destroy_dataset $fs "-R"
}

log_onexit cleanup
Expand Down
Expand Up @@ -31,8 +31,8 @@ mnt2=/$fs/mnt2

function cleanup
{
datasetexists $clone && log_must zfs destroy $clone
datasetexists $fs && log_must zfs destroy -R $fs
destroy_dataset $clone
destroy_dataset $fs "-R"
log_must rm -rf $mnt1
log_must rm -rf $mnt2
}
Expand Down
Expand Up @@ -25,7 +25,7 @@ verify_runnable "global"
fs=$TESTPOOL/$TESTFS/testchild
function cleanup
{
datasetexists $fs && log_must zfs destroy $fs
destroy_dataset $fs
}

log_onexit cleanup
Expand Down
Expand Up @@ -30,8 +30,8 @@ vol=$TESTPOOL/$TESTVOL

function cleanup
{
datasetexists $fs && log_must zfs destroy -R $fs
datasetexists $vol && log_must zfs destroy $vol
destroy_dataset $fs "-R"
destroy_dataset $vol
}

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

log_onexit cleanup
Expand Down
Expand Up @@ -31,8 +31,8 @@ groupid='456'

function cleanup
{
datasetexists $fs && log_must zfs destroy $fs
datasetexists $fs1 && log_must zfs destroy $fs1
destroy_dataset $fs
destroy_dataset $fs1
}

log_onexit cleanup
Expand Down
Expand Up @@ -30,7 +30,7 @@ dir=/$fs/dir

function cleanup
{
datasetexists $fs && log_must zfs destroy -R $fs
destroy_dataset $fs "-R"
log_must rm -rf $dir
}

Expand Down
Expand Up @@ -32,10 +32,10 @@ TESTCHILD3=$TESTCHILD-3

function cleanup
{
datasetexists $TESTCHILD && log_must zfs destroy $TESTCHILD
datasetexists $TESTCHILD1 && log_must zfs destroy $TESTCHILD1
datasetexists $TESTCHILD2 && log_must zfs destroy $TESTCHILD2
datasetexists $TESTCHILD3 && log_must zfs destroy $TESTCHILD3
destroy_dataset $TESTCHILD
destroy_dataset $TESTCHILD1
destroy_dataset $TESTCHILD2
destroy_dataset $TESTCHILD3
}

log_onexit cleanup
Expand Down
Expand Up @@ -27,8 +27,7 @@ log_assert "Listing zfs clones should work correctly."

function cleanup
{
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \
log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP "-R"
}

log_onexit cleanup
Expand Down
Expand Up @@ -27,14 +27,10 @@ log_assert "Listing zfs snapshots should work correctly."

function cleanup
{
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP1 && \
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP1
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP2 && \
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP2
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP3 && \
log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP3
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP1
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP2
destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP3
}

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

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

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

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

Expand Down
Expand Up @@ -24,8 +24,7 @@ file=$TESTDIR/$TESTFILE0

function cleanup
{
datasetexists $snap1 && log_must zfs destroy $snap1 && \
log_must rm $file
destroy_dataset $snap1 && log_must rm $file
}

log_onexit cleanup
Expand Down
Expand Up @@ -23,9 +23,7 @@ file=$TESTDIR/$TESTFILE0

function cleanup
{
datasetexists $snap && log_must zfs destroy $snap && \
log_must rm $file

destroy_dataset $snap && log_must rm $file
}

log_onexit cleanup
Expand Down
Expand Up @@ -26,7 +26,7 @@ fs=$TESTPOOL/$TESTFS/testchild

function cleanup
{
datasetexists $fs && log_must zfs destroy -R $fs
destroy_dataset $fs "-R"
}

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

Expand Down
Expand Up @@ -28,7 +28,7 @@ snapname=snap

function cleanup
{
datasetexists $rootfs && log_must zfs destroy -R $rootfs
destroy_dataset $rootfs "-R"
}

log_onexit cleanup
Expand Down
Expand Up @@ -27,7 +27,7 @@ snapname=testsnap

function cleanup
{
datasetexists $fs && log_must zfs destroy -R $fs
destroy_dataset $fs "-R"
}

log_onexit cleanup
Expand Down
Expand Up @@ -47,9 +47,7 @@ function cleanup
{
typeset -i j=0
while [[ $j -lt ${#size[*]} ]]; do
if datasetexists $TESTPOOL/${TESTVOL}${size[j]}; then
log_must zfs destroy $TESTPOOL/${TESTVOL}${size[j]}
fi
destroy_dataset $TESTPOOL/${TESTVOL}${size[j]}
((j = j + 1))
done
}
Expand Down
Expand Up @@ -268,7 +268,7 @@ log_must zfs snapshot $orig@snap1
log_must eval "zfs send $orig@snap1 > $streamfile_full"
log_mustnot eval "zfs receive -x atime $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 -V 128K -s $origsub
log_must zfs snapshot -r $orig@snap1
Expand All @@ -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 atime - -"
# Cleanup
log_must zfs destroy -r -f $orig
log_must zfs destroy -r -f $dest
block_device_wait
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
Expand Down

0 comments on commit bb91178

Please sign in to comment.