]> granicus.if.org Git - zfs/commitdiff
ZTS: Fix EBUSY volume destroy failures
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 31 Aug 2018 22:30:44 +0000 (15:30 -0700)
committerGitHub <noreply@github.com>
Fri, 31 Aug 2018 22:30:44 +0000 (15:30 -0700)
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

26 files changed:
tests/test-runner/bin/zts-report.py
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.destroy_fs.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.destroy_snap.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_count_and_limit.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_index_props.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_mountpoint.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_neg.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_number_props.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_type.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_userquota.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_written.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_children.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_clones.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_snapshots.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_system_props.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.promote_conflict.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.promote_multiple.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.promote_simple.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.rollback_mult.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.rollback_one.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_destroy.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_neg.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_recursive.ksh
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.snapshot_simple.ksh
tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh
tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh

index e1a9011d321be245c50c9cea53d00d3120bd8a77..5747f1422a30c841dec840182f594c1f512bc026 100755 (executable)
@@ -216,8 +216,6 @@ maybe = {
     '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'],
index b2e0e600eac58693abb0ab5df07bece0833a1321..18f246889994602a273887613fcb3bd6a2f2e4cf 100755 (executable)
@@ -22,7 +22,7 @@ fs=$TESTPOOL/$TESTFS/testchild
 
 function cleanup
 {
-       datasetexists $fs && log_must zfs destroy $fs
+       destroy_dataset $fs
 }
 
 log_onexit cleanup
index 0205e6c11ef95b868fbdc5f8d690678840df39b6..8650322ad06504477d66435dbb61b99282f17daa 100755 (executable)
@@ -22,7 +22,7 @@ snap=$TESTPOOL/$TESTFS@$TESTSNAP
 
 function cleanup
 {
-       datasetexists $snap && log_must zfs destroy $snap
+       destroy_dataset $snap
 }
 
 log_onexit cleanup
index eb559103beb7b72d934a3926a9fe859a13ec9d4f..70330c91a0e72be38a2dc6fba4657fb79f9b773d 100755 (executable)
@@ -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
 }
index 5fbe18e48b2c36143f02db7983ef1dff221555ba..6478fa654c1515d71bcd7a9e445129e2b925b3b4 100755 (executable)
@@ -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
index 77555a7e03b7e3cf0c9378e6a67930a214a7c438..f3cf396aa1f257c0f99ab588cd48bc865712827d 100755 (executable)
@@ -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
 }
index b1a7b8ac82333d5cb37aa0cc1f7eb823ea8e3c1a..17f7a8fd9749cf5ab2717c2325672c07a325c1e7 100755 (executable)
@@ -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
index a78873114e95e37e4895ba57bd159c375613ee18..942930fa6923ba03d1fc7d079fa43c42c64b1d44 100755 (executable)
@@ -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
index f52eda75a0b49eb584e6d1b2e8b9cf94c3fc7780..d040e8962e06d217abbc940fe91bfac81b55195e 100755 (executable)
@@ -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
index a1015442038f6da2671d50cf4f2ea8fc2b34191b..80cc4ad418ccba8beb54c869c8f57b8d9f8e679f 100755 (executable)
@@ -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
index 7f94aea246d1b7dfb7a5477ae387059cb77f2d69..9755e6f82e584234977d37f808b12808185c0e39 100755 (executable)
@@ -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
 }
 
index 2afd2e47d9626fd3b9ac52188db4cbc246506913..06b82cab4f34f518375d0efdfcbd9f7be1adb1c6 100755 (executable)
@@ -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
index ef2bd5ac0f61d8f8a2dd14fcfd2c0f34f5986ccd..68d053283d314c61db32df6504826c4918283f2f 100755 (executable)
@@ -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
index 8cd78c513a2534042c3557017fcda22f44a5f5f3..7bc36606c957d623e3112b6c705d06757a734e7d 100755 (executable)
@@ -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
index cc0be6d90896bb2a57f4385832905dfb8fe8b15d..24ab65a195b95e75e7a4c6e5192b2e26842ad3eb 100755 (executable)
@@ -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
index 0739940da8e68bfe22659bb510e3de6b907a7f35..b2840377b55965eebc2613ddeb8d708730fa3c4a 100755 (executable)
@@ -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
 }
 
index a3c05fabd55ab4467449786c41771b3e513f9dc7..7618a34bc8e1194d9f1e1bdbb9406ab254bf6fbd 100755 (executable)
@@ -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
 }
 
index 83685c4dc709de408cdeead8b03a5fc896bd428e..541c6840e0c0ab1ca2cf834214c4469ae9d73c3d 100755 (executable)
@@ -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
 }
 
index e0b917a32b4da5a3778b2b862c5343231c4c0922..2fbbc73d5fe8a3056b50ccf1a25e2f419127e6a1 100755 (executable)
@@ -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
index d6396f488bd0d1ffee8bc4a20d5e3cc9cb58969b..12834430163c64f241d45b7114154e4c822419b4 100755 (executable)
@@ -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
index 3691492bfa0c7381356db1dada2afc0075247292..b0cdfb84f4ea81bcf6c6608f3412af3838cafbbc 100755 (executable)
@@ -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
index c20ed8a61dc13a1302ec7638036b946d1e2741ea..8d6cd38310e64809308b4eca37195fc6a982b5ff 100755 (executable)
@@ -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
 }
 
index f112bf0d28132912b3668444bda48cb08b676d8c..e3bf10b69168fddfb5771ce25ae0103e162a6d20 100755 (executable)
@@ -28,7 +28,7 @@ snapname=snap
 
 function cleanup
 {
-       datasetexists $rootfs && log_must zfs destroy -R $rootfs
+       destroy_dataset $rootfs "-R"
 }
 
 log_onexit cleanup
index a26234278a9158053879968a5590c471b9b2639a..4a7acaddaf8ff3f1a3aab545c81975f64e6390f6 100755 (executable)
@@ -27,7 +27,7 @@ snapname=testsnap
 
 function cleanup
 {
-       datasetexists $fs && log_must zfs destroy -R $fs
+       destroy_dataset $fs "-R"
 }
 
 log_onexit cleanup
index 2498e4a4c9f42bf8b6a5564041cb4b2bdf0085de..6f36b40bfd594dd188f74171001fe3495a832e91 100755 (executable)
@@ -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
 }
index 6a0152e81783ff0a94d747a9e81b45d630a07e99..6f897a96f3e8de7329bb7fe9f6fa76ea4d04ec5b 100755 (executable)
@@ -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
@@ -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