fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / btrfs / 101
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/101
6 #
7 # Test device delete when the source device has EIO
8 #
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20
21 _cleanup()
22 {
23         _dmerror_cleanup
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/filter.btrfs
31 . ./common/dmerror
32
33 _supported_fs btrfs
34 _require_scratch_dev_pool 3
35 _require_btrfs_dev_del_by_devid
36 _require_dm_target error
37
38 rm -f $seqres.full
39
40 dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
41 dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
42
43 _dmerror_init
44 _mkfs_dev -f -d raid1 -m raid1 $dev1 $dev2 $DMERROR_DEV
45 _dmerror_mount
46
47 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
48 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
49
50 error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
51                         egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
52
53 snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
54 snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
55 run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \
56                                                         "$snapshot_cmd" -X 50
57
58 # now load the error into the DMERROR_DEV
59 _dmerror_load_error_table
60
61 _run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
62
63 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
64 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
65
66 echo "=== device delete completed"
67
68 status=0; exit