btrfs/079: fix failure to umount scratch fs due to running filefrag process
[xfstests-dev.git] / tests / btrfs / 079
index e848a26159b32884eb5da0201f2bfec18bd23131..1e9411be79ed7c32d92e83c4a046cecd0177d3c3 100755 (executable)
@@ -77,6 +77,12 @@ _filter_error() {
 }
 
 fiemap_work() {
 }
 
 fiemap_work() {
+       # Wait for any running 'filefrag' subcommand before exitting so that
+       # after the test kills the subshell running this function, it does not
+       # fail with EBUSY when unmounting the scratch device because the filefrag
+       # subcommand is still running with an open file on the scratch fs.
+       trap "wait; exit" SIGTERM
+
        filename=$1
        while true; do
                $FILEFRAG_PROG $filename 2> $tmp.output 1> /dev/null
        filename=$1
        while true; do
                $FILEFRAG_PROG $filename 2> $tmp.output 1> /dev/null