btrfs-progs/tests/misc-tests/011-delete-missing-device/test.sh
Misono, Tomohiro fa5b3a7fe2 btrfs-progs: misc-test: use raid1 for data to enable mount with -o degraded
kernel 4.14 introduces new function for checking if all chunks is ok for
mount with -o degraded option.

  commit 21634a19f646 ("btrfs: Introduce a function to check if all
  chunks a OK for degraded rw mount")

As a result, raid0 profile cannot be mounted with -o degraded on 4.14.
This causes failure of the misc-test 011 "delete missing device".

Fix this by using raid1 profile for both data and metadata.
This also should work for kernel before 4.13.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:34 +02:00

58 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# make sure that 'missing' is accepted for device deletion
source $TOP/tests/common
check_prereq mkfs.btrfs
check_prereq btrfs
setup_root_helper
test_do_mkfs()
{
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $@ ${loopdevs[@]}
run_check $SUDO_HELPER $TOP/btrfs inspect-internal dump-super $dev1
run_check $SUDO_HELPER $TOP/btrfs check $dev1
run_check $SUDO_HELPER $TOP/btrfs filesystem show
}
test_wipefs()
{
run_check $SUDO_HELPER wipefs -a $devtodel
run_check $SUDO_HELPER losetup -d $devtodel
unset loopdevs[3]
run_check $SUDO_HELPER losetup --all
run_check $TOP/btrfs filesystem show
}
test_delete_missing()
{
run_check_mount_test_dev -o degraded
run_check $SUDO_HELPER $TOP/btrfs filesystem show $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs device delete missing $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs filesystem show $TEST_MNT
run_check_umount_test_dev
run_check_mount_test_dev
local out
out="$(run_check_stdout $SUDO_HELPER $TOP/btrfs filesystem show $TEST_MNT)"
if echo "$out" | grep -q -- "$devtodel"; then
_fail "device $devtodel not deleted"
fi
if echo "$out" | grep -q missing; then
_fail "missing device still present"
fi
run_check_umount_test_dev
}
setup_loopdevs 4
prepare_loopdevs
dev1=${loopdevs[1]}
devtodel=${loopdevs[3]}
TEST_DEV=$dev1
test_do_mkfs -m raid1 -d raid1
test_wipefs
test_delete_missing
cleanup_loopdevs