new file mode 100755
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+
+source "$TEST_TOP/common"
+
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+setup_root_helper
+
+setup_loopdevs 2
+prepare_loopdevs
+
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -draid1 -mraid1 "${loopdevs[@]}"
+run_check $SUDO_HELPER mount -o space_cache=v2 "${loopdevs[1]}" "$TEST_MNT"
+run_check $SUDO_HELPER umount "$TEST_MNT"
+run_check $SUDO_HELPER losetup -d "${loopdevs[2]}"
+run_check $SUDO_HELPER mount -o degraded "${loopdevs[1]}" "$TEST_MNT"
+run_check $SUDO_HELPER touch "$TEST_MNT/file1.txt"
+run_check $SUDO_HELPER umount "$TEST_MNT"
+run_check $SUDO_HELPER losetup "${loopdevs[2]}" "$loopdev_prefix"2
+run_check $SUDO_HELPER mount "${loopdevs[1]}" "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" scrub start "$TEST_MNT"
+sleep 3
+run_check_stdout $SUDO_HELPER "$TOP/btrfs" scrub status "$TEST_MNT" | grep -q "finished" || _fail "scrub for raid1 and one dev is no update to data failed."
+run_check $SUDO_HELPER umount "$TEST_MNT"
+
+cleanup_loopdevs
reference to: https://lore.kernel.org/linux-btrfs/5679da1e-2422-69c5-b4f8-326802363f7c@suse.com/ https://github.com/kdave/btrfs-progs/issues/389 It tests in raid1 mode, if one of device is gone away and come back, whether btrfs scrub could finish the job Signed-off-by: Li Zhang <zhanglikernel@gmail.com> --- tests/misc-tests/050-device-state-missing/test.sh | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 tests/misc-tests/050-device-state-missing/test.sh