4 # Test case to verify that a seed device can be replaced
6 # Create a sprout device
8 # Run device replace on the seed device
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2018 Oracle. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
45 . ./common/filter.btrfs
47 # remove previous $seqres.full before test
50 # real QA test starts here
52 # Modify as appropriate.
55 _require_command "$BTRFS_TUNE_PROG" btrfstune
56 _require_scratch_dev_pool 3
58 _scratch_dev_pool_get 3
60 dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
61 dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
62 dev_replace_tgt=$(echo $SCRATCH_DEV_POOL | awk '{print $3}')
67 run_check _mount $dev_seed $SCRATCH_MNT
68 $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 256K" $SCRATCH_MNT/foobar >\
71 od -x $SCRATCH_MNT/foobar
72 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
74 $BTRFS_TUNE_PROG -S 1 $dev_seed
75 run_check _mount $dev_seed $SCRATCH_MNT
80 _run_btrfs_util_prog device add -f $dev_sprout $SCRATCH_MNT
81 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
86 _run_btrfs_util_prog replace start -fB $dev_seed $dev_replace_tgt $SCRATCH_MNT
87 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
89 run_check _mount $dev_replace_tgt $SCRATCH_MNT
91 od -x $SCRATCH_MNT/foobar
98 run_check _mount $dev_seed $SCRATCH_MNT
99 _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT
109 _scratch_dev_pool_put