The problem has been highly inconsistent to reproduce. I apologize for the delay in sending out the fix. <snap>
$ ./check btrfs/14[6-9] btrfs/15[8-9] FSTYP -- btrfs PLATFORM -- Linux/x86_64 debian0 6.8.0-rc5-btrfs-next-151+ #1 SMP PREEMPT_DYNAMIC Mon Feb 19 13:38:37 WET 2024 MKFS_OPTIONS -- /dev/sdc MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1 btrfs/146 1s ... 2s btrfs/147 0s ... 1s btrfs/148 2s ... 2s btrfs/149 1s ... 1s btrfs/158 1s ... 0s btrfs/159 20s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/159.out.bad) --- tests/btrfs/159.out 2020-10-26 15:31:57.061207266 +0000 +++ /home/fdmanana/git/hub/xfstests/results//btrfs/159.out.bad 2024-02-20 13:51:25.707220763 +0000 @@ -1,8 +1,11 @@ QA output created by 159 +mount: /home/fdmanana/btrfs-tests/scratch_1: wrong fs type, bad option, bad superblock on /dev/mapper/flakey-test, missing codepage or helper program, or other error. + dmesg(1) may have more information after failed mount system call. File digest before power failure: -f049865ed45b1991dc9a299b47d51dbf SCRATCH_MNT/foobar +b2e8facfb4795185fadd85707fe78973 SCRATCH_MNT/foobar +umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted. ... (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/159.out /home/fdmanana/git/hub/xfstests/results//btrfs/159.out.bad' to see the entire diff) Ran: btrfs/146 btrfs/147 btrfs/148 btrfs/149 btrfs/158 btrfs/159
<snap> btrfs/159 does _scratch_mkfs -O no-holes -n $((64 * 1024)) >>$seqres.full 2>&1 _require_metadata_journaling $SCRATCH_DEV _init_flakey _mount_flakey
[79195.612719] BTRFS: device fsid 10184d7d-3ca9-43c1-a6f8-70b134cff828 devid 1 transid 6 /dev/sdc scanned by mkfs.btrfs (3413318) [79195.666279] BTRFS: device fsid 10184d7d-3ca9-43c1-a6f8-70b134cff828 devid 1 transid 6 /dev/dm-0 scanned by systemd-udevd (3410982)
Both /dev/sdc and /dev/dm-0 get scanned, and the tempfsid gets activated wrongly. The fix is to add another criterion to check if the device is already mounted; then only let the thread update the device path. However, I'm not sure if it will fix the original problem (update-grub). I have sent an RFC patch v3 for verification. Thanks, Anand
[79195.695774] BTRFS info (device dm-0): first mount of filesystem 10184d7d-3ca9-43c1-a6f8-70b134cff828 [79195.695786] BTRFS info (device dm-0): using crc32c (crc32c-intel) checksum algorithm [79195.695789] BTRFS error (device dm-0): superblock fsid doesn't match fsid of fs_devices: 10184d7d-3ca9-43c1-a6f8-70b134cff828 != 628aff33-4122-4d77-b2a9-2e9a90f27520 [79195.696098] BTRFS error (device dm-0): superblock metadata_uuid doesn't match metadata uuid of fs_devices: 10184d7d-3ca9-43c1-a6f8-70b134cff828 != 628aff33-4122-4d77-b2a9-2e9a90f27520 [79195.696419] BTRFS error (device dm-0): dev_item UUID does not match metadata fsid: 628aff33-4122-4d77-b2a9-2e9a90f27520 != 10184d7d-3ca9-43c1-a6f8-70b134cff828 [79195.696765] BTRFS error (device dm-0): superblock contains fatal errors [79195.697447] BTRFS error (device dm-0): open_ctree failed It always happens with this patch applied in for-next, and never happens with it reverted.