2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle. All Rights Reserved.
5 # FS QA Test No. btrfs/100
7 # Test device replace works when the source device has EIO
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
30 . ./common/filter.btrfs
34 _require_scratch_dev_pool 3
35 _require_dm_target error
39 dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
40 dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
43 _mkfs_dev "-f -d raid1 -m raid1 $dev1 $DMERROR_DEV"
46 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
47 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
49 error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
50 egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
52 snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
53 snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
54 run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \
57 # now load the error into the DMERROR_DEV
58 _dmerror_load_error_table
60 _run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
62 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
63 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
65 echo "=== device replace completed"