2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Oracle. All Rights Reserved.
7 # Test stale and alien btrfs-device in the fs devices list.
8 # Bug fixed in the kernel patch:
9 # btrfs: include non-missing as a qualifier for the latest_bdev
10 # btrfs: remove identified alien btrfs device in open_fs_devices
13 _begin_fstest auto quick volume
15 # Override the default cleanup function.
18 $UMOUNT_PROG $TEST_DIR/$seq.mnt >/dev/null 2>&1
19 rm -rf $TEST_DIR/$seq.mnt
24 # Import common functions.
26 . ./common/filter.btrfs
28 # real QA test starts here
32 _require_scratch_dev_pool 5
40 _scratch_dev_pool_get $device_nr
44 mkdir -p $TEST_DIR/$seq.mnt
45 _mount $SPARE_DEV $TEST_DIR/$seq.mnt
47 _scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
50 # Make device_1 an alien btrfs device for the raid created above by
51 # adding it to the $TEST_DIR/$seq.mnt
53 # don't test with the first device as auto fs check (_check_scratch_fs)
54 # picks the first device
55 device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
56 $BTRFS_UTIL_PROG device add -f "$device_1" "$TEST_DIR/$seq.mnt"
58 device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
59 _mount -o degraded $device_2 $SCRATCH_MNT
60 # Check if missing device is reported as in the .out
61 $BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
62 _filter_btrfs_filesystem_show
64 $BTRFS_UTIL_PROG device remove "$device_1" "$TEST_DIR/$seq.mnt"
65 $UMOUNT_PROG $TEST_DIR/$seq.mnt