kdave / btrfs-progs

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

btrfs filesystem show --all-devices doesn't work when btrfs is over lvm #732

Closed AdallomRoy closed 5 months ago

AdallomRoy commented 5 months ago

Without --all-devices

yyy@xxx ~ $ sudo btrfs filesystem show /dev/dm-0
Label: none  uuid: a7fbb8d6-ec5d-4e88-bd8b-c686553e0dc7
        Total devices 1 FS bytes used 144.00KiB
        devid    1 size 256.00MiB used 88.00MiB path /dev/mapper/da0972636816-LogVol00

With --all-devices

yyy@xxx ~ $ sudo btrfs filesystem show --all-devices /dev/dm-0
ERROR: not a valid btrfs filesystem: /dev/dm-0

lsblk:

loop0                     488.3M        loop                                                                                                     
├─loop0p3                    31M        part ext4                    1080eb38-a011-480b-a5a7-4a4c7fb7887a   2bb3c26c-8a98-4265-9ecd-9b0ebbe34307 
├─loop0p4                   177M        part LVM2_member             kNvImq-C04X-Yfjc-Cp2u-Wmgv-meYs-xcQnOd 753ddf34-d62c-4a77-a9eb-f23b27624abf 
└─loop0p5                   279M        part LVM2_member             tAVVjy-yaiG-pl0c-WyQf-tacd-10ge-L9BfcY d90c00a2-6ee8-48a8-94e2-bdf2b9467a4b 
  └─da0972636816-LogVol00   256M        lvm  btrfs                   a7fbb8d6-ec5d-4e88-bd8b-c686553e0dc7        

If reproducing commands are helpful let me know and I will post, but I think it's quite straight forward to recreate on a file backed loop device.

kdave commented 5 months ago

The option --all-devices is meant to be a fallback for systems without udev and such, but yeah should still work if used.

AdallomRoy commented 5 months ago

Yes, this is within a container, so doesn't have udev

kdave commented 5 months ago

This is an unhandled case (and not documented obviously). It is not intended to be used together with a device path, if the argument is a device path it's not scanned. It does not need to be a loop device and it's not releated to LVM, the same message not a valid btrfs filesystem is printed for any other mounted filesystem too.

kdave commented 5 months ago

I may be wrong still, what does not work is -d + path, with a device it works for me here so the LVM or container might be a significant factor.

kdave commented 5 months ago

Now fixed in devel. The problem was that in the combination with -d and raw device path it was not found as the caches expect the canonicalized name. Adding that -d /dev/dm-0 works.