kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
527 stars 239 forks source link

Unable to mount RAID 1 drive using v6.6 btrfs.box.static #704

Closed Oldlostcoder closed 8 months ago

Oldlostcoder commented 8 months ago

On Kernel 6.1.61; with RAID 1 drives there seems to be an issue with v6.6 btrfs.box.static device scan. The command registers the drives but they do not mount. Using v6.5.3 btrfs.box.static; mounting works. Not sure if this is a bug, or Kernel 6.1.61 is not compatible with v6.6.

kdave commented 8 months ago

I saw such problems in the github CI and it was related to loop devices, do you use them or are the block devices disk/ssd/nvme/...?

kdave commented 8 months ago

I've tried that on a few nvme devices, seems to work.

Oldlostcoder commented 8 months ago

I saw such problems in the github CI and it was related to loop devices, do you use them or are the block devices disk/ssd/nvme/...?

I do have loop devices; yet BTRFS is on ssd's and an external usb. Mounting failed for both RAID 1 (two ssd's) and RAID 1C3 (2 ssd's and 1 usb drive).

adam900710 commented 8 months ago

Any dmesg for the mount failure (and the device scan lines before that)?

Oldlostcoder commented 8 months ago

Any dmesg for the mount failure (and the device scan lines before that)?

Did some more testing today. Used two different kernels; 5.10.186 and 6.1.61. Everything works fine with btrfs.box.static v6.5.1; no errors.

1) With btrfs.box.static v6.6, executed the following command to create RAID1 on a usb stick: mkfs.btrfs -L TEST -d raid1 -m raid1 /dev/sdb2 /dev/sdb3

2) RAID 1 was created fine, but the output of the command had the following errors: ERROR: device scan failed on '/dev/sdb2': No such file or directory ERROR: device scan failed on '/dev/sdb3': No such file or directory

3) Could not mount the partitions; moved the usb stick to a machine with btrfs.box.static v6.5.1; as expected could mount the partitions.

4) Move the stick back to the machine with btrfs.box.static v6.6; rebooted. Ran the following commands: modprobe btrfs ; btrfs device scan ;

Output of btrfs device scan was as expected: Scanning for Btrfs filesystems registered: /dev/sdb2 registered: /dev/sdb3

5) Could not mount partition /dev/sdb2; dmesg had the following errors: BTRFS error (device sdb2): devid 2 uuid edd3cb75-a447-4ce7-999b-4a5c886ac991 is missing BTRFS error (device sdb2): failed to read the system array: -2 BTRFS error (device sdb2): open_ctree failed

But was able to mount /dev/sdb3. Then after unmounting /dev/sdb3; I could mount /dev/sdb2. Same behavior was observed on reboot if I tried to mount /dev/sdb3 first.
Mount would fail with dmesg errors; /dev/sdb2 would mount and all mounting and unmounting worked as expected.

6) So to summarize with btrfs.box.static v6.6 can create RAID1 but get device scan errors. After RAID1 is created the first mount of either partition fails; need to mount the other partition and then everything works as expected.

If no one else is seeing this issue; maybe my kernel version is too old. Or there is some other issue with my linux install.

adam900710 commented 8 months ago

Thanks, I believe your output from 2) is already showing something wrong with the device scan.

mkfs.btrfs would try to register the devices to make them work, the register part is shared between all btrfs-progs. If that devices registration doesn't work, no wonder later mount would fail.

Unfortunately I failed to reproduce using the same v6.6, although not static build, as my distro doesn't provide static libraries anymore.

Have you tried compiling btrfs-progs from scratch? Both static and dynamic linked version, to see how things would change?

Oldlostcoder commented 8 months ago

Yes, seems to be a problem with device scan. Was unable to compile, getting configure errors; nothing that cannot be fixed just takes time.

adam900710 commented 8 months ago

Just curious, can I get the precompiled statically linked btrfs-progs you're using?

thesamesam commented 8 months ago

This might be fixed by https://github.com/kdave/btrfs-progs/pull/706.

adam900710 commented 8 months ago

Oh, that's indeed a regression, the scan ioctl is bounded to forget instead...

kdave commented 8 months ago

Fixed in v6.6.1, thanks for the report.