btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / btrfs / 216
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test 216
6 #
7 # Test if the show_devname() returns sprout device instead of seed device.
8 #
9 # Fixed in kernel patch:
10 #   btrfs: btrfs_show_devname don't traverse into the seed fsid
11
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs btrfs
36 _require_scratch_dev_pool 2
37
38 _scratch_dev_pool_get 2
39
40 seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
41 sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
42
43 _mkfs_dev $seed
44 $BTRFS_TUNE_PROG -S 1 $seed
45 _mount $seed $SCRATCH_MNT >> $seqres.full 2>&1
46 cat /proc/self/mounts | grep $seed >> $seqres.full
47 $BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
48 cat /proc/self/mounts | grep $sprout >> $seqres.full
49
50 # check if the show_devname() returns the sprout device instead of seed device.
51 dev=$(grep $SCRATCH_MNT /proc/self/mounts | $AWK_PROG '{print $1}')
52
53 if [ "$sprout" != "$dev" ]; then
54         echo "Unexpected device: $dev, expected $sprout"
55 fi
56 echo "Silence is golden"
57
58 _scratch_dev_pool_put
59
60 # success, all done
61 status=0
62 exit