On 2021/3/2 下午3:09, Christian Völker wrote:
Hi Qu Wenro,
thanks for debugging this. What I am wondering- why did it work when
creating the initial device?
Fs creation (mkfs) doesn't canonicalize the path, and it all happens in
user space, so no problem.
Only device add is affected, and if the device to be added is not a
device mapped dev (aka /dev/dm-*) then even with the offending v5.10.1
you can still add the device, just like what you tried by using drbd
over luks.
For Debian it looks like there is no other version of btrfs-progs
available, so I used this version (5.10.1-1) to create the btrfs device.
And may I workaround this issue by manually creating a softlink
/dev/manualdevice to /dev/mappper/crypt_drbd3? The link will be gone
after reboot but btrfs should then find the device by it's UUID,
shouldn't it?
I just tried, that, it doesn't work.
The path canonicalization happens by following the softlink until it
reaches the final /dev/dm-* block file, and then cut the "/dev/" prefix
wrongly, leaving just "dm-*".
So even you added a softlink, it won't help.
I just tried that, and it failed:
$ sudo ln -sf /dev/test/scratch2 /dev/whatever
$ sudo btrfs dev add /dev/whatever /mnt/btrfs/ -f
ERROR: error adding device 'dm-5': No such file or directory
But, if you manually create a block device file, with the same device
major/minor number, then you can add it using the newly created block
device file, just like this:
$ ls -alh /dev/dm-5
brw-rw---- 1 root disk 253, 5 Mar 2 15:24 /dev/dm-5
$ sudo mknod ~/whatever b 253 5
$ sudo btrfs dev add ~/whatever /mnt/btrfs/ -f
$ sudo btrfs fi show /mnt/btrfs/
Label: none uuid: 82631967-0b16-40f2-b545-0039fe9b9653
Total devices 2 FS bytes used 192.00KiB
devid 1 size 10.00GiB used 536.00MiB path dm-4
devid 2 size 10.00GiB used 0.00B path /home/adam/whatever
Thanks,
Qu
Greetings
/KNEBB
Am 02.03.2021 um 02:18 schrieb Qu Wenruo:
On 2021/3/2 上午1:24, Christian Völker wrote:
Hi,
just a little update on the issue.
As soon as I omit the encryption part I can easily add the device to the
btrfs filesystem. It does not matter if the crypted device is on top of
DRBD or directly on the /dev/sdc. In both cases btrs refuses to add the
device when a luks-encrypted device is on top.
In case I am swapping my setup (drbd on top of encryption) and add the
drbd device to btrfs it works without any issues.
However, I prefer the other way round- and as the other two btrfs
devices are both encryption on top of drbd it should work...
It appears it does not like to add a third device-mapper device...
Let me know how I can help in debugging. If i have some time I will
setup a machine trying to reproduce this.
Got the problem reproduced here.
And surprisingly, it's something related to btrfs-progs, not the kernel.
I just added one debug info in btrfs-progs, it shows:
$ sudo ./btrfs dev add /dev/test/scratch2 /mnt/btrfs
cmd_device_add: path=dm-5
ERROR: error adding device 'dm-5': No such file or directory
See the problem?
The path which should be passed to kernel lacks the "/dev/test/" prefix,
thus it's not pointing to correct path and cause the ENOENT error, since
there is no "dm-5" in current path.
Thankfully it's already fixed in devel branch with commit 2347b34af4d8
("btrfs-progs: fix device mapper path canonicalization").
The offending patch is 922eaa7b5472 ("btrfs-progs: build: fix linking
with static libmount"), which is in v5.10.1.
You can revert back to v5.10 to workaroud it.
TO David,
Would you consider to add a new v5.10.2 to fix the problem? As it seems
to affect the end user quite badly.
Thanks,
Qu
any ideas otherwise? Let me know!
Thanks!
/KNEBB