Skip to contentSkip to conversation

btrfs-progs: tests: add misc test for enqueue parameter

PATCH In review An Long 2 participants 3 messages Apr 14, 2021 – Apr 18, 2021 Btrfs file system

lore
Share & tools
lore

An Long

author
#0 lore raw

PATCH 1/1 btrfs-progs: tests: add misc test for enqueue parameter

The exclusive ops will not start if there's one already running. The enqueue parameter allows operations to be queued.

---
 .../misc-tests/048-enqueue-parameter/test.sh  | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 tests/misc-tests/048-enqueue-parameter/test.sh
tests/misc-tests/048-enqueue-parameter/test.sh new file +52 -0
new file mode 100755
index 00000000..4be7d466
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Check if --enqueue can enqueueing of the operations correctly
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+check_global_prereq fallocate
+
+setup_loopdevs 3
+prepare_loopdevs
+dev1=${loopdevs[1]}
+dev2=${loopdevs[2]}
+dev3=${loopdevs[3]}
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev1"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev2"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev3"
+run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" device add -f "$dev2" "$TEST_MNT"
+
+test_run_commands() {
+        run_check $SUDO_HELPER "$TOP/btrfs" balance start --enqueue --full-balance "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" filesystem resize --enqueue -100M "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" device add --enqueue -f "$dev3" "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" device delete --enqueue "$dev2" "$TEST_MNT" &
+}
+
+get_fs_uuid() {
+        run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$1" | \
+                grep '^fsid' | awk '{print $2}'
+}
+
+fsid=$(get_fs_uuid "$dev1")
+if ! [ -f "/sys/fs/btrfs/$fsid/exclusive_operation" ]; then
+        run_check_umount_test_dev "$TEST_MNT"
+        cleanup_loopdevs
+        _not_run "kernel does not support exclusive_operation"
+        exit
+fi
+
+# Generate 1G data, for enough balance time for exclusive_operation
+for i in $(seq 1 5); do
+        run_check $SUDO_HELPER fallocate -l 200M "$TEST_MNT/file$i"
+done
+
+# Do btrfs balance in background, then try commands with enqueue parameter
+run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT" &
+test_run_commands
+wait
+
+run_check_umount_test_dev "$TEST_MNT"
+cleanup_loopdevs
Signature · 1 line
2.26.2
#1 lore raw
Quoted 70 lines · An Long

The exclusive ops will not start if there's one already running. The enqueue parameter allows operations to be queued.

---
 .../misc-tests/048-enqueue-parameter/test.sh  | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 tests/misc-tests/048-enqueue-parameter/test.sh
tests/misc-tests/048-enqueue-parameter/test.sh new file +52 -0
new file mode 100755
index 00000000..4be7d466
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Check if --enqueue can enqueueing of the operations correctly
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+check_global_prereq fallocate
+
+setup_loopdevs 3
+prepare_loopdevs
+dev1=${loopdevs[1]}
+dev2=${loopdevs[2]}
+dev3=${loopdevs[3]}
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev1"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev2"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev3"
+run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" device add -f "$dev2" "$TEST_MNT"
+
+test_run_commands() {
+        run_check $SUDO_HELPER "$TOP/btrfs" balance start --enqueue --full-balance "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" filesystem resize --enqueue -100M "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" device add --enqueue -f "$dev3" "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" device delete --enqueue "$dev2" "$TEST_MNT" &
+}
+
+get_fs_uuid() {
+        run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$1" | \
+                grep '^fsid' | awk '{print $2}'
+}
+
+fsid=$(get_fs_uuid "$dev1")
+if ! [ -f "/sys/fs/btrfs/$fsid/exclusive_operation" ]; then
+        run_check_umount_test_dev "$TEST_MNT"
+        cleanup_loopdevs
+        _not_run "kernel does not support exclusive_operation"
+        exit
+fi
+
+# Generate 1G data, for enough balance time for exclusive_operation
+for i in $(seq 1 5); do
+        run_check $SUDO_HELPER fallocate -l 200M "$TEST_MNT/file$i"
+done
+
+# Do btrfs balance in background, then try commands with enqueue parameter
+run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT" &
+test_run_commands
+wait
+
+run_check_umount_test_dev "$TEST_MNT"
+cleanup_loopdevs
Signature · 1 line
2.26.2

I applied this patch to progs v5.11.1 and ran it on a vm running a kernel built from e5ff2239e143 (kdave/misc-next rebased today) and each of the enqueued commands fails without any useful diagnostic information, nor anything interesting in dmesg as far as I can tell. e.g.:
"failed: /home/vmuser/btrfs-progs/btrfs filesystem resize --enqueue -100M /home/vmuser/btrfs-progs/tests/mnt"

I am able to pass other misc tests on this setup.

Is there anything else I need to do to be able to run this test?

Thanks,
Boris

author
#2 lore raw

Fail is the correct result for now. It should pass with patch "btrfs-
progs: Correct check_running_fs_exclop() return value"
https://patchwork.kernel.org/project/linux-btrfs/patch/20210409155644.qkk6puelfjvtjwqs@fiona/

Thanks,
An Long

Quoted 101 lines · Boris Burkov
Quoted 83 lines · An Long

The exclusive ops will not start if there's one already running. The
enqueue parameter allows operations to be queued.

---
 .../misc-tests/048-enqueue-parameter/test.sh  | 52
+++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100755 tests/misc-tests/048-enqueue-parameter/test.sh
tests/misc-tests/048-enqueue-parameter/test.sh new file +19 -0
new file mode 100755
index 00000000..4be7d466
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Check if --enqueue can enqueueing of the operations correctly
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+check_global_prereq fallocate
+
+setup_loopdevs 3
+prepare_loopdevs
+dev1=${loopdevs[1]}
+dev2=${loopdevs[2]}
+dev3=${loopdevs[3]}
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev1"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev2"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$dev3"
+run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" device add -f "$dev2"

"$TEST_MNT"

tests/misc-tests/048-enqueue-parameter/test.sh new file +3 -0
+
+test_run_commands() {
+        run_check $SUDO_HELPER "$TOP/btrfs" balance start --

enqueue --full-balance "$TEST_MNT" &
+ run_check $SUDO_HELPER "$TOP/btrfs" filesystem resize --
enqueue -100M "$TEST_MNT" &

tests/misc-tests/048-enqueue-parameter/test.sh new file +2 -1
+        run_check $SUDO_HELPER "$TOP/btrfs" device add --enqueue
-f "$dev3" "$TEST_MNT" &
+        run_check $SUDO_HELPER "$TOP/btrfs" device delete --

enqueue "$dev2" "$TEST_MNT" &

tests/misc-tests/048-enqueue-parameter/test.sh new file +4 -0
+}
+
+get_fs_uuid() {
+        run_check_stdout "$TOP/btrfs" inspect-internal dump-super

"$1" | \

tests/misc-tests/048-enqueue-parameter/test.sh new file +12 -0
+                grep '^fsid' | awk '{print $2}'
+}
+
+fsid=$(get_fs_uuid "$dev1")
+if ! [ -f "/sys/fs/btrfs/$fsid/exclusive_operation" ]; then
+        run_check_umount_test_dev "$TEST_MNT"
+        cleanup_loopdevs
+        _not_run "kernel does not support exclusive_operation"
+        exit
+fi
+
+# Generate 1G data, for enough balance time for

exclusive_operation

tests/misc-tests/048-enqueue-parameter/test.sh new file +2 -0
+for i in $(seq 1 5); do
+        run_check $SUDO_HELPER fallocate -l 200M

"$TEST_MNT/file$i"

tests/misc-tests/048-enqueue-parameter/test.sh new file +3 -0
+done
+
+# Do btrfs balance in background, then try commands with enqueue

parameter
+run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT" &

tests/misc-tests/048-enqueue-parameter/test.sh new file +5 -0
+test_run_commands
+wait
+
+run_check_umount_test_dev "$TEST_MNT"
+cleanup_loopdevs
Signature · 1 line
2.26.2

I applied this patch to progs v5.11.1 and ran it on a vm running a kernel built from e5ff2239e143 (kdave/misc-next rebased today) and each
of the enqueued commands fails without any useful diagnostic information, nor anything interesting in dmesg as far as I can tell. e.g.:
"failed: /home/vmuser/btrfs-progs/btrfs filesystem resize --enqueue -100M /home/vmuser/btrfs-progs/tests/mnt"

I am able to pass other misc tests on this setup.

Is there anything else I need to do to be able to run this test?

Thanks,
Boris

Signature · 2 lines
An Long <[email protected]>
SUSE QE LSG, QE Integration 2, Beijing