2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
5 # FS QA Test No. btrfs/020
7 # btrfs device replace test on RO fs
9 # Regression test for commit:
10 # bbb651e Btrfs: don't allow the replace procedure on read only filesystems
13 _begin_fstest auto quick replace volume
15 # Override the default cleanup function.
20 $UMOUNT_PROG $loop_mnt
21 _destroy_loop_device $loop_dev1
22 losetup -d $loop_dev2 >/dev/null 2>&1
23 _destroy_loop_device $loop_dev3
25 rm -f $fs_img1 $fs_img2 $fs_img3
28 # Import common functions.
31 # real QA test starts here
36 echo "Silence is golden"
38 loop_mnt=$TEST_DIR/$seq.$$.mnt
39 fs_img1=$TEST_DIR/$seq.$$.img1
40 fs_img2=$TEST_DIR/$seq.$$.img2
41 fs_img3=$TEST_DIR/$seq.$$.img3
43 $XFS_IO_PROG -f -c "truncate 256m" $fs_img1 >>$seqres.full 2>&1
44 $XFS_IO_PROG -f -c "truncate 256m" $fs_img2 >>$seqres.full 2>&1
45 $XFS_IO_PROG -f -c "truncate 256m" $fs_img3 >>$seqres.full 2>&1
47 loop_dev1=`_create_loop_device $fs_img1`
48 loop_dev2=`_create_loop_device $fs_img2`
49 loop_dev3=`_create_loop_device $fs_img3`
51 _mkfs_dev -m raid1 -d raid1 $loop_dev1 $loop_dev2 >>$seqres.full 2>&1
52 _mount -o ro $loop_dev1 $loop_mnt
54 $BTRFS_UTIL_PROG replace start -B 2 $loop_dev3 $loop_mnt >>$seqres.full 2>&1 && \
55 _fail "FAIL: Device replaced on RO btrfs"