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
35 _require_scratch_dev_pool 3
36 _require_dm_target error
40 dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
41 dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
44 _mkfs_dev "-f -d raid1 -m raid1 $dev1 $DMERROR_DEV"
47 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
48 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
50 error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
51 egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
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 \
58 # now load the error into the DMERROR_DEV
59 _dmerror_load_error_table
61 _run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
63 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
64 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
66 echo "=== device replace completed"