btrfs/079: fix failure to umount scratch fs due to running filefrag process
[xfstests-dev.git] / tests / btrfs / 161
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test 161
6 #
7 # seed sprout functionality test
8 #  Create a seed device, mount it and, add a new device to create a
9 #  sprout filesystem.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 # Modify as appropriate.
36 _supported_fs btrfs
37 _supported_os Linux
38 _require_command "$BTRFS_TUNE_PROG" btrfstune
39 _require_scratch_dev_pool 2
40
41 _scratch_dev_pool_get 2
42
43 dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
44 dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
45
46 create_seed()
47 {
48         _mkfs_dev $dev_seed
49         run_check _mount $dev_seed $SCRATCH_MNT
50         $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 256K" $SCRATCH_MNT/foobar >\
51                 /dev/null
52         echo -- golden --
53         od -x $SCRATCH_MNT/foobar
54         _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
55         _scratch_unmount
56         $BTRFS_TUNE_PROG -S 1 $dev_seed
57         run_check _mount $dev_seed $SCRATCH_MNT
58 }
59
60 create_sprout()
61 {
62         _run_btrfs_util_prog device add -f $dev_sprout $SCRATCH_MNT
63         _scratch_unmount
64         run_check _mount $dev_sprout $SCRATCH_MNT
65         echo -- sprout --
66         od -x $SCRATCH_MNT/foobar
67         _scratch_unmount
68 }
69
70 create_seed
71 create_sprout
72
73 _scratch_dev_pool_put
74
75 status=0
76 exit