| #! /bin/bash | 
 | # SPDX-License-Identifier: GPL-2.0 | 
 | # Copyright (c) 2015 Oracle.  All Rights Reserved. | 
 | # | 
 | # FS QA Test No. btrfs/100 | 
 | # | 
 | # Test device replace works when the source device has EIO | 
 | # | 
 | # | 
 | . ./common/preamble | 
 | _begin_fstest auto replace volume eio | 
 |  | 
 | # Override the default cleanup function. | 
 | _cleanup() | 
 | { | 
 | 	_dmerror_cleanup | 
 | 	rm -f $tmp.* | 
 | } | 
 |  | 
 | . ./common/filter | 
 | . ./common/filter.btrfs | 
 | . ./common/dmerror | 
 |  | 
 | _require_scratch_dev_pool 3 | 
 | _require_dm_target error | 
 |  | 
 | dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`" | 
 | dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`" | 
 |  | 
 | _dmerror_init | 
 | _mkfs_dev "-f -d raid1 -m raid1 $dev1 $DMERROR_DEV" | 
 | _dmerror_mount | 
 |  | 
 | _btrfs filesystem show -m $SCRATCH_MNT | 
 | $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show | 
 |  | 
 | error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\ | 
 | 			grep -E $DMERROR_DEV | $AWK_PROG '{print $2}'` | 
 |  | 
 | snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT" | 
 | snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`" | 
 | run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \ | 
 | 							"$snapshot_cmd" -X 50 | 
 |  | 
 | # now load the error into the DMERROR_DEV | 
 | _dmerror_load_error_table | 
 |  | 
 | _btrfs replace start -B $error_devid $dev2 $SCRATCH_MNT | 
 |  | 
 | _btrfs filesystem show -m $SCRATCH_MNT | 
 | $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show | 
 |  | 
 | echo "=== device replace completed" | 
 |  | 
 | status=0; exit |