Skip to contentSkip to conversation

btrfs-progs: tests: misc: fix failure on misc/034

PATCH In review Qu Wenruo 2 participants 2 messages Feb 13, 2023 – Mar 21, 2023 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs-progs: tests: misc: fix failure on misc/034

[BUG]
Test case misc/034 can fail like this:

====== RUN CHECK mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt
mount: /home/adam/btrfs-progs/tests/mnt: wrong fs type, bad option, bad superblock on /dev/loop16, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
failed: mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt

And the dmesg looks like this:

loop16: detected capacity change from 0 to 1024000
loop17: detected capacity change from 0 to 1024000
BTRFS: device fsid 593e23af-a7e6-4360-b16a-229f415de697 devid 1 transid 6 /dev/loop16 scanned by mount (79348) BTRFS info (device loop16): using crc32c (crc32c-intel) checksum algorithm
BTRFS info (device loop16): found metadata UUID change in progress flag, clearing
BTRFS info (device loop16): disk space caching is enabled
BTRFS error (device loop16): devid 2 uuid cde07de6-db7e-4b34-909e-d3db6e7c0b06 is missing BTRFS error (device loop16): failed to read the system array: -2
BTRFS error (device loop16): open_ctree failed

[CAUSE]
From the dmesg, it shows that although both loopback devices are properly registered, only one is properly scanned by mount.

Thus the other device is missing, and without "-o degraded" the filesystem failed to be mounted.

[FIX]
Before we mount the filesystem, also scan them in their passed in order to properly assemble the device list for mount.

---
 tests/misc-tests/034-metadata-uuid/test.sh | 4 ++++
 1 file changed, 4 insertions(+)
tests/misc-tests/034-metadata-uuid/test.sh +4 -0
index b7cb546b..b62cdc10 100755
@@ -191,6 +191,10 @@ failure_recovery() {
 
 	run_check $SUDO_HELPER udevadm settle
 
+	# Scan to make sure btrfs detects both devices before trying to mount
+	run_check $SUDO_HELPER "$TOP/btrfs" device scan $loop1
+	run_check $SUDO_HELPER "$TOP/btrfs" device scan $loop2
+
 	# Mount and unmount, on trans commit all disks should be consistent
 	run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT"
 	run_check $SUDO_HELPER umount "$TEST_MNT"
Signature · 1 line
2.39.0
#1 lore raw
Quoted 24 lines · Qu Wenruo

[BUG]
Test case misc/034 can fail like this:

====== RUN CHECK mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt
mount: /home/adam/btrfs-progs/tests/mnt: wrong fs type, bad option, bad superblock on /dev/loop16, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
failed: mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt

And the dmesg looks like this:

loop16: detected capacity change from 0 to 1024000
loop17: detected capacity change from 0 to 1024000
BTRFS: device fsid 593e23af-a7e6-4360-b16a-229f415de697 devid 1 transid 6 /dev/loop16 scanned by mount (79348) BTRFS info (device loop16): using crc32c (crc32c-intel) checksum algorithm
BTRFS info (device loop16): found metadata UUID change in progress flag, clearing
BTRFS info (device loop16): disk space caching is enabled
BTRFS error (device loop16): devid 2 uuid cde07de6-db7e-4b34-909e-d3db6e7c0b06 is missing BTRFS error (device loop16): failed to read the system array: -2
BTRFS error (device loop16): open_ctree failed

[CAUSE]

Quoted 1 line

From the dmesg, it shows that although both loopback devices are

properly registered, only one is properly scanned by mount.

Quoted 8 lines

Thus the other device is missing, and without "-o degraded" the filesystem failed to be mounted.

[FIX]
Before we mount the filesystem, also scan them in their passed in order to properly assemble the device list for mount.

Added to devel, thanks.