summaryrefslogtreecommitdiff
path: root/tests/btrfs/100
blob: 410e83ba176194f8409ef2f1416f76866f81559d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /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.*
}

# Import common functions.
. ./common/filter
. ./common/filter.btrfs
. ./common/dmerror

_supported_fs btrfs
_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

_run_btrfs_util_prog 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

_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT

_run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show

echo "=== device replace completed"

status=0; exit